Skip to content

Always specify cargo toolchain #32

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
# Run twice to test problem with expression caching
./tests/scripts/test-runner.sh
./tests/scripts/test-runner.sh
(cd tests/scripts/ignores-rust-toolchain && ../../../target/debug/rust-script test.rs)

check-format:
runs-on: ubuntu-latest
Expand Down
15 changes: 7 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ struct Args {
build_kind: BuildKind,
template: Option<String>,
list_templates: bool,
// This is a String instead of an
// enum since one can have custom
// toolchains (ex. a rustc developer
// will probably have `stage1`).
// This is a String instead of an enum since one can have custom
// toolchains (ex. a rustc developer will probably have `stage1`):
toolchain_version: Option<String>,

#[cfg(windows)]
Expand Down Expand Up @@ -1155,15 +1153,16 @@ Constructs a Cargo command that runs on the script package.
fn cargo(
cmd_name: &str,
manifest: &str,
maybe_toolchain_version: Option<&str>,
toolchain_version: Option<&str>,
meta: &PackageMetadata,
script_args: &[String],
run_quietly: bool,
) -> MainResult<Command> {
let mut cmd = Command::new("cargo");
if let Some(toolchain_version) = maybe_toolchain_version {
cmd.arg(format!("+{}", toolchain_version));
}

// Always specify a toolchain to avoid being affected by rust-version(.toml) files:
cmd.arg(format!("+{}", toolchain_version.unwrap_or("stable")));

cmd.arg(cmd_name);

if cmd_name == "run" && run_quietly {
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/ignores-rust-toolchain/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid-rust-version
1 change: 1 addition & 0 deletions tests/scripts/ignores-rust-toolchain/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
std::process::exit(0);