rustowl icon indicating copy to clipboard operation
rustowl copied to clipboard

rustowl crashes when another Rust toolchain version is used

Open siketyan opened this issue 10 months ago • 13 comments

On my setup, running cargo-owl immediately crashes with the following error, while the normal cargo check command runs successfully:

❯ rustup run stable cargo owl
error: process didn't exit successfully: `/Users/siketyan/.cargo/bin/rustowlc /Users/siketyan/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc -vV` (signal: 6, SIGABRT: process abort signal)
--- stderr
dyld[43086]: Library not loaded: @rpath/librustc_driver-c18e4301379fb818.dylib
  Referenced from: <788115DD-9822-34DB-9A24-896C6AA2016E> /Users/siketyan/.cargo/bin/rustowlc
  Reason: tried: '/Users/siketyan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/librustc_driver-c18e4301379fb818.dylib' (no such file), '/Users/siketyan/lib/librustc_driver-c18e4301379fb818.dylib' (no such file), '/usr/local/lib/librustc_driver-c18e4301379fb818.dylib' (no such file), '/usr/lib/librustc_driver-c18e4301379fb818.dylib' (no such file, not in dyld cache)

Also I tried running cargo check with the rustowlc wrapper directly, but got the same error:

❯ RUSTC_WORKSPACE_WRAPPER=(which rustowlc) cargo check
error: process didn't exit successfully: `/Users/siketyan/.cargo/bin/rustowlc /Users/siketyan/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc -vV` (signal: 6, SIGABRT: process abort signal)
--- stderr
dyld[43086]: Library not loaded: @rpath/librustc_driver-c18e4301379fb818.dylib
  Referenced from: <788115DD-9822-34DB-9A24-896C6AA2016E> /Users/siketyan/.cargo/bin/rustowlc
  Reason: tried: '/Users/siketyan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/librustc_driver-c18e4301379fb818.dylib' (no such file), '/Users/siketyan/lib/librustc_driver-c18e4301379fb818.dylib' (no such file), '/usr/local/lib/librustc_driver-c18e4301379fb818.dylib' (no such file), '/usr/lib/librustc_driver-c18e4301379fb818.dylib' (no such file, not in dyld cache)

I believe rustowl is built on the nightly-2024-10-31 toolchain, so I tried also running rustowlc on the same toolchain and it works:

❯ RUSTC_WORKSPACE_WRAPPER=(which rustowlc) cargo +nightly-2024-10-31 check
...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 44.89s

Although there is a limitation that the running toolchain version must match the building toolchain, the current behaviour is a bit confusing. It will be great if the cargo-owl wrapper checks the toolchain version, or to be documented in README at least.

My Environment:

  • macOS 15.3 24D60 arm64
  • cargo 1.84.1 (66221abde 2024-11-19)

siketyan avatar Feb 09 '25 07:02 siketyan

@siketyan Thank you for trying RustOwl!

RustOwl utilizes private functions of the Rust compiler rustc. As a result, rustowlc first attempts to link a dynamic library. This requires the rustc_driver library for nightly-2024-10-31 and cannot proceed until the linkage is complete.

Due to limitations in using the rustc API, RustOwl requires a specific nightly and fixed toolchain version. Therefore, rustowlc cannot provide a prompt.

Additionally, users must set up cargo with rustup to switch toolchains automatically. This is already documented in the README.

We will display a prompt when running cargo owl and document this behavior accordingly.

Thank you!

cordx56 avatar Feb 09 '25 11:02 cordx56

I was going to open another issue to suggest adding a check to know whether rustup / rust is already installed.

https://github.com/cordx56/rustowl/blob/main/rustowl/install.sh#L6

Because I use another tool to install it, and this could end up installing again in a different path or maybe even conflict with it.

dougg0k avatar Feb 13 '25 17:02 dougg0k

Also, I installed the tool only by using these two commands, instead of the script.

rustup toolchain install nightly-2024-10-31 --component rust-src rustc-dev llvm-tools-preview
cargo +nightly-2024-10-31 install --locked --git https://github.com/cordx56/rustowl
❯ cargo install --list | grep owl                                                                                                                                                                          
rustowl v0.1.1 (https://github.com/cordx56/rustowl#37f63146):
    cargo-owl
    cargo-owlsp
    rustowlc

dougg0k avatar Feb 13 '25 17:02 dougg0k

Does rustowl require the artifacts that were built in ./target/ to be produced by the same compiler version?

At least on Nix, it should be relatively easy to bundle rustowl binary with exactly same toolchain version it requires, so I wonder if spending time attempting it is worth it.

dpc avatar Feb 13 '25 19:02 dpc

Also, I installed the tool only by using these two commands, instead of the script.

rustup toolchain install nightly-2024-10-31 --component rust-src rustc-dev llvm-tools-preview
cargo +nightly-2024-10-31 install --locked --git https://github.com/cordx56/rustowl

Thank you for your opinion! I feel that the toolchain should be specified in a single place, which is currently rustowl/rust-toolchain.toml.

cordx56 avatar Feb 14 '25 21:02 cordx56

Currently, it doesnt seem to be possible to read from toolchain.toml when installing through cargo install. If that were possible, it would help in not need the additional comand or many others.

https://github.com/rust-lang/rustup/issues/2696

dougg0k avatar Feb 14 '25 21:02 dougg0k

I think so that. this related to #19

cordx56 avatar Feb 14 '25 21:02 cordx56

I'm a Rust beginner. Did I make any configuration errors?

$ git clone [email protected]:cordx56/rustowl.git
$ cd rustowl/rustowl
➜  rustowl git:(main)$ cargo install --path . --locked
info: syncing channel updates for 'nightly-2024-10-31-x86_64-apple-darwin'
error: no release found for 'nightly-2024-10-31'
➜  rustowl git:(main)$ rustup toolchain list
stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin (default)
➜  rustowl git:(main)$ rustc --version
rustc 1.86.0-nightly (a567209da 2025-02-13)

hzbd avatar Feb 16 '25 06:02 hzbd

hmm, it seems to be right. Are you installed rustup via official script?

cordx56 avatar Feb 16 '25 13:02 cordx56

I'm also getting this error

kaplanelad avatar Feb 18 '25 08:02 kaplanelad

Had same error one I installed via official script. The toolchain was downloaded, and I can see it on the list, but maybe it wasn't used to actually compile rustowl?

>  rustup toolchain list 
stable-aarch64-apple-darwin
nightly-2024-10-31-aarch64-apple-darwin
nightly-aarch64-apple-darwin (default)

because when I later manually compiled it:

> git clone https://github.com/cordx56/rustowl.git
> cd rustowl/rustowl
> rustup default nightly-2024-10-31-aarch64-apple-darwin
> cargo install --path . --locked

like hzbd said above, everything works now.

the only fail here is that the 2024-10-31 version does not have edition2024 which I started using (for no specific reason, but why use nightly if not for staying on the bleeding edge:) and now I had to remove it from Cargo.toml

alichnerowicz-splunk avatar Feb 18 '25 09:02 alichnerowicz-splunk

The rustc_private feature, which RustOwl heavily relies on, requires a nightly toolchain.

If you set up rustup using the official Rust script, the toolchain will be selected automatically.

cordx56 avatar Feb 18 '25 10:02 cordx56

I am unable to debug it further, but I see that toolchain was installed when running install.sh script, BUT I suspect it was not used to compile rustowl and instead the one I had as default was -- which happened to be nightly too, just latest.

However it happened, after installing via script cargo-owl was crashing, after manually setting up nightly-2024-10-31-aarch64-apple-darwin as default, and recompiling, it works.

alichnerowicz-splunk avatar Feb 18 '25 10:02 alichnerowicz-splunk

🤖 Bot: Issue has not seen activity in 30 days and will therefore be marked as stale. It will be closed in 7 days if no further response is found.

github-actions[bot] avatar Jul 22 '25 07:07 github-actions[bot]

Maybe this problem is already fixed in the process of other enhancements. We made so many changes since this issue was created.

Can we close this issue?

cordx56 avatar Aug 04 '25 22:08 cordx56