-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust-toolchain
affects which rustc version is used to execute a script
#31
Comments
By always specifying a cargo toolchain (the +${TOOLCHAIN} option) we avoid being affected by rust-toolchain(.toml) files. Fixes #31.
By always specifying a cargo toolchain (the +${TOOLCHAIN} option) we avoid being affected by rust-toolchain(.toml) files. Fixes #31.
By always specifying a cargo toolchain (the +${TOOLCHAIN} option) we avoid being affected by rust-toolchain(.toml) files. Fixes #31.
Thanks for reporting! I agree that rust-script should not be affected by a Resources: One possible fix is as done in #32. It always specifies the toolchain option to cargo, by defaulting to However, this will fail if:
One way to work around this would be to shell out to rustup, to try to detect if
Are there perhaps better ways? |
Interesting. Thanks for the detailed explanation. To check whether my understanding is correct: the rustup proxies are the ones that are interpreting the One thing that I noticed is, that I can work around the issue by putting the following hashbang at the top of scripts: What about this: Have
Overall, that seems like fairly desirable behavior. It is a bigger change, and it would be somewhat daunting to do it without having good tests for a few different scenarios. Since I easily might have overlooked something. cc: @casey |
Yes, exactly!
I think this makes a lot of sense. Would also help with #30 (comment), where it's desired to show build progress for the initial build, but after that run it directly with no cargo output. Will experiment with the idea! |
Just to add I pretty much run into this problem while trying to run rust scripts in my case I had a file setup called rust-toolchain.toml with the following in
Adding "--toolchain-version stable" would allow it to compile.
As a workaround so far I've been using cargo make's duckscript Although looking ahead it'd be nice if I could implement scripts using stuff such as indicatif |
Version 0.23.0 has just been released, and does it as described above, which should fix this issue - let me know if there are any problems! |
Seems to work as expected for me. 🎉 Thanks a lot for working on |
If I have a script in a directory in my
$PATH
, say/usr/local/bin/foo
, and it starts with#!/usr/bin/env rust-script
and it has the executable flag set, then I can invoke that script from anywhere in my system with$ foo
. And that usually works fine. When executing the script from a directory that has arust-toolchain
file in it, then -- to my surprise --rust-script
uses the rust toolchain version specified in therust-toolchain
file to execute the script. This feels like a bug to me, since the contents of a directory shouldn't affect what interpreter or compiler is used to run an executable in my$PATH
.An extreme example is this: If I put e.g.
1.10
into therust-toolchain
file, the rust script cannot be executed at all, sincerust-script
fails witherror: Unknown flag: '--target-dir'
.I think I would expect
rust-script
to always use the default toolchain.Is this an intended feature? Could this be changed?
The text was updated successfully, but these errors were encountered: