Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation issue on macOS 14.0 #1953

Closed
ruby-ist opened this issue Apr 19, 2024 · 9 comments
Closed

Installation issue on macOS 14.0 #1953

ruby-ist opened this issue Apr 19, 2024 · 9 comments

Comments

@ruby-ist
Copy link

ruby-ist commented Apr 19, 2024

I've been trying to install Rustlings on my m1 macbook air but I'm facing the following compilation error again and again.

Screenshot 2024-04-19 at 1 55 01 PM

Here's the details about my spec:

$ rustc -V
rustc 1.77.2 (25ef9e3d8 2024-04-09)

$ file $(which rustc)
/Users/srira/.cargo/bin/rustc: Mach-O 64-bit executable arm64

$ file $(which rustup)
/Users/srira/.cargo/bin/rustup: Mach-O 64-bit executable arm64

$ file $(which cargo)
/Users/srira/.cargo/bin/cargo: Mach-O 64-bit executable arm64

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

OS: macOS 14.0 Sonoma
Xcode version: 15.3

I tried everything recommended on stackoverflow but had no luck, I also saw one other issue similar to this here. But that fix doesn't seem to be working for me. I also tried re-installing rust, cmake, llvm and xcode command line tools.

Edit: I have another linux machine, in which rustlings installed successfully

@mo8it
Copy link
Contributor

mo8it commented Apr 19, 2024

@ruby-ist It is unfortunate that I can't reproduce it because I don't have MacOS. It might be just a dependency problem. I recommend trying the main branch which has all dependencies updated. To do so, could you please delete the rustlings directory and run the following?

git clone --depth 1 https://github.com/rust-lang/rustlings
cd rustlings
cargo install --force --path .

Please tell me if it works :)

@ruby-ist
Copy link
Author

@mo8it That doesn't work, facing the same issue. However I found out that even though compilation failed, the cargo run command works with default installation. And cargo run watch command works as expected too. Is this a normal behaviour? I'm new to Rust. Can I continue this course with cargo run command instead of rustlings command?

@mo8it
Copy link
Contributor

mo8it commented Apr 19, 2024

Weird. It looks like a problem with the release profile then. Could you please try to run cargo run --release instead of cargo run? In that case, you would get the error again.

Could you please also post the output of the command rustup toolchain list?

Otherwise, yes, you can work with cargo run watch. Sorry for the inconvenience. I will try to ask around to debug this issue and prevent it in the future.

@ruby-ist
Copy link
Author

I ran cargo run --release command and yes, it threw the same error again.

Output of rustup toolchain list:

stable-aarch64-apple-darwin (default)

Thanks for your response @mo8it. I will continue with cargo run watch command for now.

@mo8it
Copy link
Contributor

mo8it commented Apr 19, 2024

I got a hint. Could you please share the output of the following commands?

which strip
whereis strip
echo $PATH

@mo8it
Copy link
Contributor

mo8it commented Apr 19, 2024

You might also find something helpful in rust-lang/cargo#8913 or rust-lang/rust#73908

Of course only if you are interested in fixing the issue. Otherwise, I hope that cargo run watch is good enough :)

@ruby-ist
Copy link
Author

Sure, I would be happy to help you fix the issues. Here are the outputs:

$ which strip
/opt/homebrew/opt/binutils/bin/strip

$ whereis strip
strip: /usr/bin/strip /opt/homebrew/opt/binutils/share/man/man1/strip.1

$ echo "${PATH//:/\n}"
/opt/homebrew/opt/binutils/bin
/Users/srira/.bun/bin
/Users/srira/.wasmtime/bin
/opt/homebrew/opt/openjdk/bin
/Users/srira/.gem/ruby/3.1.0/bin
/Users/srira/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/bin
/Users/srira/.rubies/ruby-3.1.0/bin
/opt/homebrew/opt/sqlite/bin
/opt/homebrew/bin
/opt/homebrew/sbin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/srira/DragonRuby
/Users/srira/.rubies/ruby-3.1.0/bin
/Users/srira/.gem/ruby/3.1.0/bin
/Users/srira/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
/Library/Apple/usr/bin
/Applications/Postgres.app/Contents/Versions/latest/bin
/Users/srira/.cargo/bin
/Users/srira/Library/Application Support/JetBrains/Toolbox/scripts

@mo8it
Copy link
Contributor

mo8it commented Apr 20, 2024

Your output shows that this has to be this bug related to stripping: dtolnay/proc-macro2#448

See this too: rust-lang/cargo#11641 (comment)

which strip should return /usr/bin/strip, not something from homebrew.

The solution would be to find out where the PATH variable is changed to prepend /opt/homebrew/opt/binutils/bin. Probably in .bash_profile, you should find something like this (prepending):

PATH="/opt/homebrew/opt/binutils/bin:$PATH"

Then, just change it to this (appending):

PATH="$PATH:/opt/homebrew/opt/binutils/bin"

This means that binaries will be looked for in /usr/bin before /opt/homebrew/opt/binutils/bin. Therefore, which strip should then return /usr/bin/strip and the compilation in the release profile should work :D

Feel free to reopen if it doesn't work.

@mo8it mo8it closed this as completed Apr 20, 2024
@ruby-ist
Copy link
Author

Thanks a lot @mo8it changing PATH variable precedence solved the issue, though I have to remove the folder and install it again. Everything is working fine now 👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants