thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
63 stars 4 forks source link

I can't run the flutter todo example on linux #16

Closed cipherchabon closed 3 years ago

cipherchabon commented 3 years ago

I am following the guide step by step, and when I run sh/bindgen I get this error:

2021-08-25 10:03:08,356 INFO [rid_build] Generating Dart glue code
2021-08-25 10:03:08,356 INFO [rid_build] Injecting Swift code into plugin
2021-08-25 10:03:08,360 DEBUG [rid_build::ffigen::run_ffigen] Running '"dart" "run" "ffigen" "--config" "/tmp/.tmpoThyRa/ffigen_config.yaml"' from: '"/home/marcos/Proyectos/ffi_demos/rid-examples/flutter/todo"'
thread 'main' panicked at 'Build failed: 
'dart run ffigen' failed to run successfully
stderr: The Flutter SDK is not available.

stdout: ', rid_build.rs:30:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cipherchabon commented 3 years ago

Update:

I was able to resolve the above error by modifying in the rid-build/src/ffigen/run_ffigen.rs file the value for FFIGEN_RUNNER from "dart" to "flutter pub".

const FFIGEN_RUNNER: &str = "flutter pub";

But now I have the following problem:

2021-08-25 17:55:48,565 INFO [rid_build] Injecting Swift code into plugin
2021-08-25 17:55:48,566 DEBUG [rid_build::ffigen::run_ffigen] Running '"flutter pub" "run" "ffigen" "--config" "/tmp/.tmp43kuXV/ffigen_config.yaml"' thread 'main' panicked at 'Build failed: No such file or directory (os error 2)', rid_build.rs:30:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Any help would be greatly appreciated. Thank you.

thlorenz commented 3 years ago

@cypherchabon if you made any progress with this after the changes I provided to the examples, please update here so we can resolve this issue.

cipherchabon commented 3 years ago

With the last changes you made in the examples, you can run only the dart one without problems.
However with the examples for Flutter I still have the situation raised in the issue.

cipherchabon commented 3 years ago

The error is this:

thread 'main' panicked at 'Build failed: No such file or directory (os error 2)', rid_build.rs:29:26

And line 29 is this:

let tmp_dir = tempdir().context("Failed to create tmpdir")?;

It seems to be a problem with tempfile.

thlorenz commented 3 years ago

Ah wow I hope it's not a permissions problem. Could you file an issue with the tempfile crate? Maybe they can help and/or fix the problem.

@MGlolenstine did you run into these issues as well (I think I remember you're on Linux as well)?

thlorenz commented 3 years ago

@cypherchabon realizing this is now trying to address two issues. Could you please file a separate issue for the tempfile problem so we can just focus on the flutter run vs. dart run part here?

thlorenz commented 3 years ago

Update:

I was able to resolve the above error by modifying in the rid-build/src/ffigen/run_ffigen.rs file the value for FFIGEN_RUNNER from "dart" to "flutter pub".

const FFIGEN_RUNNER: &str = "flutter pub";

You shouldn't have to change the code to get rid to work properly, so we need to find a solution that works for all cases. Afaik @MGlolenstine found dart run to work better than pub run for instance (see this commit in a related rid-examples PR.

I'd like to figure out some way that works in all cases or at least automatically figure out which command to use in a specific scenario.

But now I have the following problem:

2021-08-25 17:55:48,565 INFO [rid_build] Injecting Swift code into plugin
2021-08-25 17:55:48,566 DEBUG [rid_build::ffigen::run_ffigen] Running '"flutter pub" "run" "ffigen" "--config" "/tmp/.tmp43kuXV/ffigen_config.yaml"' thread 'main' panicked at 'Build failed: No such file or directory (os error 2)', rid_build.rs:30:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Any help would be greatly appreciated. Thank you.

I assume this is still an issue after the changes to examples? Is this caused by the tempfile problem? If so let's link this comment in the separate issue that we should create.

MGlolenstine commented 3 years ago

I haven't encountered this issue myself (the file permission one), but "dart run" is available when installing the flutter, where "pub run" is deprecated and getting removed, so I think we should be switching to the specialised commands ("dart run" and "flutter run").

I will try recreating the issue and try to debug it.

cipherchabon commented 3 years ago

@cypherchabon realizing this is now trying to address two issues. Could you please file a separate issue for the tempfile problem so we can just focus on the flutter run vs. dart run part here?

I made two separate issues and close this one.

19

20