Repository: sagiegurari/cargo-make (rust)

Issue:
`CARGO` env variable does not get set when running commands
### Describe The Bug
The README describes 

> When defined with scripts (as opposed to commands), the CARGO environment variable will be defined for the requested toolchain.

Although this says it doesn't define it for commands, I think this should so that the behavior matches with running via `rustup` or `cargo +toolchain`.

### To Reproduce
`build.rs`:
```
use std::path::PathBuf;
use std::env;

fn main() {
    panic!("{:#?}", env::var("CARGO").map(PathBuf::from).unwrap());
}
```

`Makefile.toml`:
```
[tasks.nightly-build]
toolchain = "nightly"
extend = "build"
```

These commands panic with stable toolchain path:
`cargo build`
`rustup run stable cargo build`
`cargo make build`
`cargo make nightly-build`

These commands panic with nightly toolchain path:
`cargo +nightly build`
`rustup run nightly cargo build`

The issue here is that `cargo make nightly-build` should print the nightly toolchain path. Something in cargo-make is preventing it from doing that.


Pull request description:
fix: reset CARGO env var to fix wrong CARGO in commands
fixes #1059

Patch:
diff --git a/Cargo.lock b/Cargo.lock
index e62ed78c..ee387d9f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -158,7 +158,7 @@ dependencies = [
  "glob",
  "home",
  "ignore",
- "indexmap 2.2.5",
+ "indexmap 2.2.6",
  "itertools",
  "lenient_semver",
  "log",
@@ -714,9 +714,9 @@ dependencies = [
 
 [[package]]
 name = "indexmap"
-version = "2.2.5"
+version = "2.2.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4"
+checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
 dependencies = [
  "equivalent",
  "hashbrown 0.14.3",
@@ -987,7 +987,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
 dependencies = [
  "fixedbitset",
- "indexmap 2.2.5",
+ "indexmap 2.2.6",
 ]
 
 [[package]]
@@ -1078,9 +1078,9 @@ dependencies = [
 
 [[package]]
 name = "regex"
-version = "1.10.3"
+version = "1.10.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
+checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
 dependencies = [
  "aho-corasick",
  "memchr",
@@ -1411,9 +1411,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
 
 [[package]]
 name = "toml"
-version = "0.8.11"
+version = "0.8.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e"
+checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3"
 dependencies = [
  "serde",
  "serde_spanned",
@@ -1432,11 +1432,11 @@ dependencies = [
 
 [[package]]
 name = "toml_edit"
-version = "0.22.7"
+version = "0.22.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992"
+checksum = "c12219811e0c1ba077867254e5ad62ee2c9c190b0d957110750ac0cda1ae96cd"
 dependencies = [
- "indexmap 2.2.5",
+ "indexmap 2.2.6",
  "serde",
  "serde_spanned",
  "toml_datetime",
diff --git a/docs/_config.yml b/docs/_config.yml
index f6f37b40..5ded95cd 100755
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -2,4 +2,4 @@ theme: jekyll-theme-cayman
 title: cargo-make
 description: Rust task runner and build tool.
 show_downloads: false
-version: 0.37.11
+version: 0.37.10
diff --git a/src/lib/toolchain.rs b/src/lib/toolchain.rs
index 1ea79e46..4b268894 100644
--- a/src/lib/toolchain.rs
+++ b/src/lib/toolchain.rs
@@ -148,5 +148,5 @@ pub(crate) fn get_cargo_binary_path(toolchain: &ToolchainSpecifier) -> Option<St
 }
 
 pub(crate) fn remove_rust_env_vars() {
-    envmnt::remove_all(&vec!["RUSTC", "RUSTDOC", "RUSTFLAGS"]);
+    envmnt::remove_all(&vec!["CARGO", "RUSTC", "RUSTDOC", "RUSTFLAGS"]);
 }


Test patch:
diff --git a/src/lib/toolchain_test.rs b/src/lib/toolchain_test.rs
index 844d39b7..6f361a9b 100644
--- a/src/lib/toolchain_test.rs
+++ b/src/lib/toolchain_test.rs
@@ -124,16 +124,19 @@ fn get_cargo_binary_path_valid() {
 #[test]
 #[ignore]
 fn remove_rust_env_vars_existed() {
+    envmnt::set("CARGO", "bad0");
     envmnt::set("RUSTC", "bad1");
     envmnt::set("RUSTDOC", "bad2");
     envmnt::set("RUSTFLAGS", "bad3");
 
+    assert!(envmnt::exists("CARGO"));
     assert!(envmnt::exists("RUSTC"));
     assert!(envmnt::exists("RUSTDOC"));
     assert!(envmnt::exists("RUSTFLAGS"));
 
     remove_rust_env_vars();
 
+    assert!(!envmnt::exists("CARGO"));
     assert!(!envmnt::exists("RUSTC"));
     assert!(!envmnt::exists("RUSTDOC"));
     assert!(!envmnt::exists("RUSTFLAGS"));