fornwall / rust-script

Run Rust files and expressions as scripts without any setup or compilation step.
https://rust-script.org
Apache License 2.0
1.23k stars 41 forks source link

No such file or directory (os error 2) #85

Open joshcangit opened 1 year ago

joshcangit commented 1 year ago

Version 0.23.0 keeps giving me an error whenever I run a script.

error: No such file or directory (os error 2)

Had to use the previous version for it to work.

Version info:

cargo 1.68.1
rustc 1.68.1 (8460ca823 2023-03-20) (built from a source tarball)

Get readelf -p .comment

String dump of section '.comment':
  [     0]  mold 1.11.0 (compatible with GNU ld)
  [    25]  Android (9352603, based on r450784d1) clang version 14.0.7 (https://android.googlesource.com/toolchain/llvm-project 4c603efb0cca074e9238af8b4106c30add4418f6)
joshcangit commented 1 year ago

However on my PC, it works fine.

String dump of section '.comment':
  [     0]  GCC: (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0
  [    2b]  mold 1.11.0 (cca255e6be069cdbc135c83fd16036d86b98b85e; compatible with GNU ld)
joshcangit commented 1 year ago

Also to add, Rust is now broken on Termux Android.

termux/termux-packages#15851

After the libllvm package updated from 15.0.7-3 to 16.0.0, the rust package had to be removed.

This was just 2 days after I posted this issue. I'll try to test this again after Rust is fixed.

joshcangit commented 1 year ago

Nope, 0.23.0 still won't work. This issue still persists in later versions.

Something changed after 0.22.0 that caused it to stop working. https://github.com/fornwall/rust-script/compare/0.22.0...0.23.0

Tried running with this configuration.

[build]
RUSTFLAGS = ["-Clink-arg=-Wl,-rpath=/data/data/com.termux/files/usr/lib", "-Clink-arg=-Wl,--enable-new-dtags"]

Also won't work.

tennox commented 1 year ago

Are you installing rust-script via Nix or similar? I realized that using it via nix this error occurs, but via cargo install it works. :thinking:

joshcangit commented 1 year ago

Are you installing rust-script via Nix or similar?

I'm using the rust package installed by apt in Termux. No, I didn't install Nix-on-Droid.

joshcangit commented 9 months ago

Could this be an issue regarding glibc? Termux uses Bionic libc so if this requires glibc it won't work.

migel commented 9 months ago

I get this error when CARGO_BUILD_TARGET is defined (I use it to compile to musl). The binary is built in the $HOME/.cache/rust-script/binaries/$CARGO_BUILD_TARGET directory and I can run it manually, so probably rust-script is not looking in the correct build directory when cross compiling.

joshcangit commented 9 months ago

Same here. I use CARGO_BUILD_TARGET=aarch64-linux-android to get Rust to work on Termux.

Thought it was just rust-script that hard coded pathnames to follow the Linux File System.