Problem setting up Rust environment

Hi,
I have previously had the Rust environment set up and working. But it is now some time ago and I’m trying to update this environment.
I have reinstalled rustup, placed cargo-concordium.exe (renamed without version) in a folder in my PATH and am now trying to see if I can reach “cargo concordium” in the terminal in VS Code.

I’m getting an error though:

error: the 'cargo.exe' binary, normally provided by the 'cargo' component, is not applicable to the 'stable-x86_64-pc-windows-gnu' toolchain

Anyone has an idea?

The error is only when calling rust-concordium or using cargo in general?

It is in fact also when calling just “cargo” from the terminal in VS Code.

When I was installing rustup, I also did:

rustup target add wasm32-unknown-unknown

Which resulted in the following:

info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date

Any ideas as to what is wrong?

Try changing the toolchain as some of them do not have all binaries pre-installed

Hi @petlan,

This seems to be related to https://github.com/rust-lang/rustup/issues/988.
The TL;DR is:

Usually just doing a rustup component remove NAME && rustup component add NAME will fix things. Sometimes removing the entire toolchain will be needed. In rare cases uninstalling rustup entirely will be needed.

So you can try rustup component remove cargo && rustup component add cargo.

Let me know if you run into more trouble :blush:

/ Kasper

Doing that gives me this:

rustup component remove cargo
info: removing component 'cargo'
info: rolling back changes
error: failure removing component 'cargo-x86_64-pc-windows-gnu', directory does not exist: 'bin/cargo.exe'
rustup component add cargo
info: component 'cargo' for target 'x86_64-pc-windows-gnu' is up to date

I tried to reinstall rustup but it makes no changes to the outcome.

Okay. It seems like antivirus software might also cause this issue: Toolchain corruption on windows - help - The Rust Programming Language Forum

I am not sure what else you can try, if that doesn’t work. But since it is a general Rust tooling issue (and not related to Concordium), perhaps you can try posting a question on users.rust-lang.org.

Posted there but my post is stuck in anti-spam at the moment on that forum until someone releases it.

Okay, and have you tried temporarily disabling your antivirus or using a different one? The solution to the issue I linked to was to use something other than Avast antivirus.

I have tried that yes. I did have Avast installed at some point, so this factor could be in play. I don’t have that anymore though and haven’t had for some time.

Currently have an AV-exception on the .cargo folder.

But still even with AV-disabled I get:

cargo --help
error: the 'cargo.exe' binary, normally provided by the 'cargo' component, is not applicable to the 'stable-x86_64-pc-windows-gnu' toolchain

Even if I navigate to the /bin folder and call it from there, where all the exe files are.

I have now fixed the problem I think, using the advice I got from Kornel at the Rust forum.
rustup update and rustup default stable was all it took it seems - that is, if the below looks correct.

rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-gnu'
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: latest update on 2022-08-11, rust version 1.63.0 (4b91a6ea7 2022-08-08)
info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
 16.4 MiB /  16.4 MiB (100 %)   6.8 MiB/s in  2s ETA:  0s
info: downloading component 'rls'
info: downloading component 'rust-src'
info: downloading component 'rust-analysis'
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 18.3 MiB /  18.3 MiB (100 %)   6.6 MiB/s in  2s ETA:  0s
info: downloading component 'rust-std'
 24.0 MiB /  24.0 MiB (100 %)   6.8 MiB/s in  3s ETA:  0s
info: downloading component 'rustc'
 54.9 MiB /  54.9 MiB (100 %)   6.5 MiB/s in  8s ETA:  0s
info: downloading component 'rustfmt'
info: removing previous version of component 'rust-std' for 'wasm32-unknown-unknown'
info: removing previous version of component 'rls'
info: removing previous version of component 'rust-src'
info: removing previous version of component 'rust-analysis'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'rust-std' for 'wasm32-unknown-unknown'
 16.4 MiB /  16.4 MiB (100 %)  10.6 MiB/s in  6s ETA:  0s
info: installing component 'rls'
info: installing component 'rust-src'
info: installing component 'rust-analysis'
info: installing component 'clippy'
info: installing component 'rust-docs'
 18.3 MiB /  18.3 MiB (100 %)   2.1 MiB/s in 10s ETA:  0s
info: installing component 'rust-std'
 24.0 MiB /  24.0 MiB (100 %)  10.6 MiB/s in  2s ETA:  0s
 54.9 MiB /  54.9 MiB (100 %)  11.8 MiB/s in  4s ETA:  0s
info: installing component 'rustfmt'
info: checking for self-updates

  stable-x86_64-pc-windows-gnu unchanged - rustc 1.63.0 (4b91a6ea7 2022-08-08)
   stable-x86_64-pc-windows-msvc updated - rustc 1.63.0 (4b91a6ea7 2022-08-08) (from rustc 1.54.0 (a178d0322 2021-07-26))

info: cleaning up downloads & tmp directories
rustup default stable
info: using existing install for 'stable-x86_64-pc-windows-msvc'
info: default toolchain set to 'stable-x86_64-pc-windows-msvc'

  stable-x86_64-pc-windows-msvc unchanged - rustc 1.63.0 (4b91a6ea7 2022-08-08)
cargo --help
Rust's package manager

USAGE:
    cargo [+toolchain] [OPTIONS] [SUBCOMMAND]

OPTIONS:
    -V, --version               Print version info and exit
        --list                  List installed commands
        --explain <CODE>        Run `rustc --explain CODE`
    -v, --verbose               Use verbose output (-vv very verbose/build.rs output)
    -q, --quiet                 Do not print cargo log messages
        --color <WHEN>          Coloring: auto, always, never
        --frozen                Require Cargo.lock and cache are up to date
        --locked                Require Cargo.lock is up to date
        --offline               Run without accessing the network
        --config <KEY=VALUE>    Override a configuration value
    -Z <FLAG>                   Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for
                                details
    -h, --help                  Print help information

Some common cargo commands are (see all commands with --list):
    build, b    Compile the current package
    check, c    Analyze the current package and report errors, but don't build object files
    clean       Remove the target directory
    doc, d      Build this package's and its dependencies' documentation
    new         Create a new cargo package
    init        Create a new cargo package in an existing directory
    add         Add dependencies to a manifest file
    run, r      Run a binary or example of the local package
    test, t     Run the tests
    bench       Run the benchmarks
    update      Update dependencies listed in Cargo.lock
    search      Search registry for crates
    publish     Package and upload this package to the registry
    install     Install a Rust binary. Default location is $HOME/.cargo/bin
    uninstall   Uninstall a Rust binary

See 'cargo help <command>' for more information on a specific command.

Hi @petlan,

That’s great to hear! :tada:
Now you can get back to the smart contracts :wink:

Have a nice day

/ Kasper

1 Like