irondash / cargokit

Integrate cargo build with flutter plugins and applications.
Other
51 stars 16 forks source link

Defaulting to stable even if default is set to nightly #25

Closed ryanhossain9797 closed 9 months ago

ryanhossain9797 commented 9 months ago

Cargokit is used by Rust In Flutter: https://github.com/cunarist/rust-in-flutter There is an ongoing issue there regarding this https://github.com/cunarist/rust-in-flutter/issues/147

Basically it seems like even is the default toolchain is set to nightly, stable is being automatically set up and used.

knopp commented 9 months ago

Right. This is a bug. Cargokit should install stable if missing, just as it installs nightly if required and missing. Cargokit will by default use stable toolchain, unless specified differently inside the cargokit.yaml file (which can be put alongside Cargo.toml). You can see example cargokit.yaml here:

https://github.com/superlistapp/super_native_extensions/blob/main/super_native_extensions/rust/cargokit.yaml

It allows you set different toolchain for debug and release builds. In this case super_native_extensions needs nightly for release build because it builds the whole std (to get smaller binaries with panic=abort).

Now the question is, whether we should ensure that stable toolchain is installed when building with stable, or detect that it is missing and just build with nightly in that case.

knopp commented 9 months ago

Actually, this should be already done. Stable toolchain should be installed automatically.

knopp commented 9 months ago

If you can provide reproducible steps (including rustup installation) I will take a look. Cargokit should install all required toolchains and targets (and components), and if it fails to it needs to be fixed.

ryanhossain9797 commented 9 months ago

Actually, this should be already done. Stable toolchain should be installed automatically.

It is installed automatically. But is that the desired behavior? What if my rust code depends on nightly?

knopp commented 9 months ago

If your crate depends on nightly, then you can put cargokit.yaml file next to Cargo.toml and tell cargokit to use nightly when building the plugin. The user should not be concerned with which toolchain the flutter plugin needs.

ryanhossain9797 commented 9 months ago

If your crate depends on nightly, then you can put cargokit.yaml file next to Cargo.toml and tell cargokit to use nightly when building the plugin. The use should not be concerned with which toolchain the flutter plugin needs.

I see. Thanks that should be sufficient.

knopp commented 9 months ago

But I think the problem is that all rustup commands right now don't specify the channel. Though for some reason when installing target for stable rust this target can then be used for nightly build, which is bit weird, but it doesn't seem to work the other way around? Still needs to be fixed though.