diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fe3e7e..93233de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,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 diff --git a/src/main.rs b/src/main.rs index 32934dc..2169c41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,10 +52,8 @@ struct Args { build_kind: BuildKind, template: Option, 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, #[cfg(windows)] @@ -1153,15 +1151,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 { 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 { diff --git a/tests/scripts/ignores-rust-toolchain/rust-toolchain b/tests/scripts/ignores-rust-toolchain/rust-toolchain new file mode 100644 index 0000000..c123105 --- /dev/null +++ b/tests/scripts/ignores-rust-toolchain/rust-toolchain @@ -0,0 +1 @@ +invalid-rust-version diff --git a/tests/scripts/ignores-rust-toolchain/test.rs b/tests/scripts/ignores-rust-toolchain/test.rs new file mode 100644 index 0000000..0101dd6 --- /dev/null +++ b/tests/scripts/ignores-rust-toolchain/test.rs @@ -0,0 +1 @@ +std::process::exit(0);