#Error running yew app with tauri cli next branch

41 messages ยท Page 1 of 1 (latest)

wispy shore
#

Sounds like you need to add native-tls to your Cargo.toml.

(I may be wrong I'm new to this)

onyx kindle
#

Sounds to me like not having updated versions. You should have the latest version numbers in Cargo.toml as well as install the latest CLI version

onyx kindle
#

What do you have as beforeDevCommand and do you have trunk installed?

#

Specifically Amr's version as it has some fixes

#

If you run trunk serve and open that IP in your browser can you see the frontend?

#

You CAN use the "normal" version, it's just that Amr's version has one or two little tweaks to make it work better with Tauri

onyx kindle
#

Should work best if you set it to 0.0.0.0 in your configs

#

Then it should be exposed at 192.168.0.82 automatically

#

Just to be clear here 192.168.0.82 is your computers IP, right? The 0 is a bit unusual to see is all, just so it's not some other internal IP of some kind

#

What's the error message for openssl?

#

I want to say that this can be resolved by adding the native-tls or native-tls-vendored feature flags to tauri in Cargo.toml

#

What's the error?

#

That's one heck of an error

#

Spontaneously all I can really say is that your system seems to be set up a bit weirdly, e.g. that you're missing dependencies or have weird environment variables that messes things up

If you want to verify that it's your system that's messed up and not your project you can use my devcontainer to just try to build your project. If your project builds with the devcontainer at least you'll know for sure that it's your system you need to fix and not your code
https://github.com/simonhyll/devcontainer

#

https://next--tauri.netlify.app/next/guides/getting-started/prerequisites/linux

sudo apt update
sudo apt install libwebkit2gtk-4.1-dev \
    build-essential \
    curl \
    wget \
    libssl-dev \
    libgtk-3-dev \
    libayatana-appindicator3-dev \
    librsvg2-dev

That along with
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
Plus the Android SDK should be everything you need on your system

#

You can check the Dockerfile in my devcontainer setup to see how I set up a Ubuntu system from scratch with all dependencies and improvements I do there

onyx kindle
#

Looks like you're trying to compile a version 1 Tauri project using version 2 without first migrating to the new style ๐Ÿ™‚
https://youtu.be/HMvzjK4KH1w

Today we'll be looking at some of the changes you'll need to make to your project in order to migrate from a version 1 project to a version 2 alpha project. Note that I'll make another video later once version 2 is stable where I go more in-depth into the topic, here I'll just cover the most basic of basics and try to get you 99% of the way.
htt...

โ–ถ Play video
#

Don't be alarmed by the 36 minute length of the video, the changes are actually fairly small you have to make. It's mainly adding a [lib] section properly and moving code from main.rs to lib.rs

#

Everything goes into lib.rs, or into other modules. Your main.rs should be extremely minimal (which btw in any Rust project you make is the case, you should always keep main.rs as small as possible and put all your code elsewhere and expose it using lib.rs)

#

screams out loud and runs away because of your 400 line main.rs

#

Some CLI argument handling in main.rs is fine to have, which can sometimes make it anywhere between like 10 and 200 lines of code depending on which crate you use for argument parsing and how many arguments you have, but in general, any code that actually does anything shouldn't be in main.rs. If the full size of your project is just those 400 lines, that's one thing, then you've made a relatively small project and it's just good that you don't overcomplicate it, but "serious" projects should really keep main.rs as minimal as possible

#

Here's an example lib.rs file. Based on the output I think #[cfg_attr(mobile, tauri::mobile_entry_point)] might not be in the right place to decorate a pub fn run() function

use tauri::{Manager, WindowEvent};
use window_shadows::set_shadow; // window shadow plugin

#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![greet])
        .on_window_event(|e| { // workaround to make resizing more reactive
            if let WindowEvent::Resized(_) = e.event() {
                std::thread::sleep(std::time::Duration::from_nanos(1));
            }
        })
        .setup(|app| {
            let window = app.get_window("main").unwrap();

            #[cfg(any(windows, target_os = "macos"))]
            set_shadow(&window, true).unwrap(); // uses the window shadow plugin to make an undecorated window look more native

            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
onyx kindle
#

That env variable is handled automagically

#

So try again without having it explicitly defined

#

Now it is at least, we fixed it ๐Ÿ™‚

#

Are all dependencies (including tauri-build) updated to their latest versions along with the cli? And have you ran cargo update? Because that issue existed in older v2 versions

#

I believe it should be like alpha.4 for tauri-build and alpha.8 for tauri and the cli

#

Yep 4 for build and 8 for tauri is latest

#

Tauri build should be in build dependencies. Do you have a build.rs script?

#

[build-dependencies]
tauri-build = "2.0.0-alpha.4"

#

๐Ÿ˜…

#

Possibly ๐Ÿ˜… Though if I had to guess those issues weren't causes by this. Might be, but shouldnt be, if you could at all fix them in other ways than updating the version nr

#

So hopefully the other fixes were actually needed anyway

#

Yaaay!!

#

That should be related to the IP configuration of your frontend, or that your device isnt on the correct network, or potentially a firewall setting somewhere

#

Whatever you have in tauri.conf.json gets overridden for Android afaik

#

Connection refused should mean that either A) the correct IP wasnt used either by the client or your frontend server or B) something prevented the connection, like different networks or firewalls

#

NICE!! And just in time for me to go to sleep so my thumbs can get some rest, god I hate typing on my phone x)

#

No problem ๐Ÿค—โค๏ธ