rust-lang / rustlings

:crab: Small exercises to get you used to reading and writing Rust code!
https://rustlings.cool
MIT License
52.95k stars 10.05k forks source link

rustling rampup for .asdf users #1533

Closed Liferenko closed 5 months ago

Liferenko commented 1 year ago

Hello! I guess we need to add in README an info how to start when your Rust has been installed via asdf.

It wasn't that obvious from first glance why rustlings run tests1 said zsh: commang not found: rustlings. I've added $PATH in my .zshrc - did not help.

Looks (and feels) like the core of the problem lays somewhere in .asdf because I've installed rust via ASDF. I bet I'm not the only one who faces this asdf-related issue at the step 0 of rust journey.

> dotfiles git:(master): rustlings
> zsh: command not found: rustlings
> dotfiles git:(master): which cargo
> /Users/macbook/.asdf/shims/cargo
Liferenko commented 1 year ago

Looks like if you've installed Rust via asdf, the PATH should look like this export PATH=/Users/username/.asdf/shims:$PATH

because the last few sentences in rustlings/install.sh said WARNING: Please check that you have '/Users/macbook/.cargo/bin' in your PATH environment variable!

Is it correct?

pkbyron commented 1 year ago

I am getting a similar error. I have asdf rust installed with cargo version 1.71.0, rustup 1.26.0. Both are in the /Users/user/.asdf/shims/. path when I run the which command.

Install works without error, but can't run the program...

%> rustlings
zsh: command not found: rustlings

Workaround

As a work around, it shouldn't surprise one to find the release binary in the [path to rustlings]/rustlings/target/release directory. I just call this direct e.g. ./target/release/rustlings list

hope that helps...

shadows-withal commented 1 year ago

I will say that I am of the general opinion that Rust, if not installed via a system package manager, should be installed via Rustup, as it's the project's official tool, and also includes a release track and components system, which is indispensable for advanced uses. I'm not sure how asdf handles shims, but unless they actually modify Cargo's source code, Cargo will always install binaries into ~/.cargo/bin.

rochaalexandre commented 11 months ago

I had this issue as well I fixed it by configuring the PATH variable with asdf path to the rust version and the shims folder. export PATH=$HOME/.local/bin/:/usr/local/bin/:$HOME/.asdf/installs/rust/stable/bin/:$HOME/.asdf/shims/:$PATH After this I executed the script to install the rustlings again and it worked

mansorkonrrado commented 8 months ago

I am getting a similar error. I have asdf rust installed with cargo version 1.71.0, rustup 1.26.0. Both are in the /Users/user/.asdf/shims/. path when I run the which command.

Install works without error, but can't run the program...

%> rustlings
zsh: command not found: rustlings

Workaround

As a work around, it shouldn't surprise one to find the release binary in the [path to rustlings]/rustlings/target/release directory. I just call this direct e.g. ./target/release/rustlings list

hope that helps...

In my case, this is ths solution! Thank you!

mo8it commented 5 months ago

Closing because of the solution in the comments.