xd009642/tarpaulin

Cargo does not handle +toolchain directives.

andriyDev opened this issue · 8 comments

I am on Windows 10, using Rust 1.76, default toolchain set to stable-x86_64-pc-windows-msvc. I ran cargo new --lib code-cov-example, cd'ed into it, and ran cargo tarpaulin and got the following message:

2024-03-17T02:39:04.649653Z  INFO cargo_tarpaulin::config: Creating config
2024-03-17T02:39:04.792126Z  INFO cargo_tarpaulin: Running Tarpaulin
2024-03-17T02:39:04.792368Z  INFO cargo_tarpaulin: Building project
2024-03-17T02:39:04.792590Z  INFO cargo_tarpaulin::cargo: Cleaning project
error: no such command: `+stable-x86_64-pc-windows-msvc`

        Cargo does not handle `+toolchain` directives.
        Did you mean to invoke `cargo` through `rustup` instead?
2024-03-17T02:39:04.894216Z ERROR cargo_tarpaulin: Cargo failed to run! Error: cargo run failed
Error: "Cargo failed to run! Error: cargo run failed"

I'm not really sure how to debug this. I also just installed tarpaulin using cargo install cargo-tarpaulin like normal.

This should only happen if you have the RUSTUP_TOOLCHAIN env var set. Which would imply that you're using rustup and + directives should work.

Just wondering do you handle your rust install via rustup? And why is that environment variable set? Just trying to understand a bit more because it will have been added to fix another users issue so I don't want to just willy-nilly remove the env var check

Looking at my Windows environment variables, I don't have RUSTUP_TOOLCHAIN set! I am using rustup for my Rust install. I even tried using Powershell to see if it would do the trick and no luck.

Sorry for the delay, I have pushed a branch with a potential fix, if you could try it out and let me know if it solves it - otherwise I'll look to different methods. The branch is fix/broken-toolchain-directives

Doing too many PRs at once and merged this one. It's a change I likely would have merged anyway... But yeah it's in develop now!

Okay this is released, I'll close the issue but if it still persists feel free to reopen

Ah dang, I lost track of this, sorry! I just upgraded to v0.29.0. Looks like the issue is still occuring :/

@xd009642 I don't think I'm able to reopen this issue.

Ok I decided to clone the repo and tinker with it. I just printed all my environment variables and RUSTUP_TOOLCHAIN is there clear as day. However running env in Git bash, or Get-ChildItem env: in Powershell does not include this variable. Very odd!

I believe I know what the issue is: I have rustup installed to a non-default directory E:\\Programs\RustUp. tarpaulin includes the +toolchain directive if .rustup is not in the path. Instead, we should be using the RUSTUP_HOME environment variable if it is present.