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

rust-script fails to execute in nix #55

Closed
DavidDTA opened this issue May 21, 2022 · 4 comments
Closed

rust-script fails to execute in nix #55

DavidDTA opened this issue May 21, 2022 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@DavidDTA
Copy link

DavidDTA commented May 21, 2022

I've installed rust-script via nix like so:

nix-shell -p rust-script

In that shell, I can run the rust-script executable:

[nix-shell:~]$ rust-script --version
rust-script 0.20.0

However, if I attempt to provide a file, I get an error:

[nix-shell:~]$ rust-script ~/myscript
error: No such file or directory (os error 2)

The same problem happens with the --expr option:

[nix-shell:~]$ rust-script --expr "3"
error: No such file or directory (os error 2)

Here is a full trace:

[nix-shell:~]$ RUST_LOG=rust_script=trace rust-script ~/myscript
[2022-05-21T18:42:48Z INFO  rust_script] Arguments: Args { script: Some("/Users/dta/myscript"), script_args: [], features: None, expr: false, loop_: false, count: false, pkg_path: None, gen_pkg_only: false, cargo_output: false, clear_cache: false, debug: false, dep: [], extern_: [], force: false, unstable_features: [], build_kind: Normal, template: None, list_templates: false, toolchain_version: None }
[2022-05-21T18:42:48Z INFO  rust_script] input: File("myscript", "/Users/dta/myscript", "", 1653158268482)
[2022-05-21T18:42:48Z INFO  rust_script] prelude_items: []
[2022-05-21T18:42:48Z INFO  rust_script] id: "65f3c77206ea3caf68f2d30d"
[2022-05-21T18:42:48Z INFO  rust_script] pkg_path: "/Users/dta/Library/Caches/rust-script/projects/65f3c77206ea3caf68f2d30d"
[2022-05-21T18:42:48Z INFO  rust_script] using_cache: true
[2022-05-21T18:42:48Z INFO  rust_script::manifest] part_mani: Toml("")
[2022-05-21T18:42:48Z INFO  rust_script::manifest] source: "fn main() -> Result<(), Box<dyn std::error::Error+Sync+Send>> {\n    {\n        }\n    Ok(())\n}"
[2022-05-21T18:42:48Z INFO  rust_script::manifest] part_mani: {}
[2022-05-21T18:42:48Z INFO  rust_script::manifest] mani: {"bin": Array([Table({"name": String("myscript_65f3c77206ea3caf68f2d30d"), "path": String("myscript.rs")})]), "dependencies": Table({}), "package": Table({"authors": Array([String("Anonymous")]), "edition": String("2018"), "name": String("myscript"), "version": String("0.1.0")})}
[2022-05-21T18:42:48Z INFO  rust_script::manifest] mani_str: [[bin]]
    name = "myscript_65f3c77206ea3caf68f2d30d"
    path = "myscript.rs"
    
    [dependencies]
    
    [package]
    authors = ["Anonymous"]
    edition = "2018"
    name = "myscript"
    version = "0.1.0"
    
[2022-05-21T18:42:48Z INFO  rust_script] input_meta: PackageMetadata { path: Some("/Users/dta/myscript"), modified: Some(1653158268482), template: None, debug: false, deps: [], prelude: [], features: None, manifest_hash: "a8e53ac300f30974d4a72844ff059f9142643863", script_hash: "56ecf0b760b401c9aa37b7ff226399b2b988b458" }
[2022-05-21T18:42:48Z DEBUG rust_script] meta_path: "/Users/dta/Library/Caches/rust-script/projects/65f3c77206ea3caf68f2d30d/metadata.json"
[2022-05-21T18:42:48Z INFO  rust_script] action: InputAction { cargo_output: false, force_compile: false, emit_metadata: true, execute: true, pkg_path: "/Users/dta/Library/Caches/rust-script/projects/65f3c77206ea3caf68f2d30d", using_cache: true, toolchain_version: None, metadata: PackageMetadata { path: Some("/Users/dta/myscript"), modified: Some(1653158268482), template: None, debug: false, deps: [], prelude: [], features: None, manifest_hash: "a8e53ac300f30974d4a72844ff059f9142643863", script_hash: "56ecf0b760b401c9aa37b7ff226399b2b988b458" }, old_metadata: Some(PackageMetadata { path: Some("/Users/dta/myscript"), modified: Some(1653158268482), template: None, debug: false, deps: [], prelude: [], features: None, manifest_hash: "a8e53ac300f30974d4a72844ff059f9142643863", script_hash: "56ecf0b760b401c9aa37b7ff226399b2b988b458" }), manifest: "[[bin]]\nname = \"myscript_65f3c77206ea3caf68f2d30d\"\npath = \"myscript.rs\"\n\n[dependencies]\n\n[package]\nauthors = [\"Anonymous\"]\nedition = \"2018\"\nname = \"myscript\"\nversion = \"0.1.0\"\n", script: "fn main() -> Result<(), Box<dyn std::error::Error+Sync+Send>> {\n    {\n        }\n    Ok(())\n}", build_kind: Normal }
[2022-05-21T18:42:48Z INFO  rust_script] creating pkg dir...
[2022-05-21T18:42:48Z INFO  rust_script] generating Cargo package...
[2022-05-21T18:42:48Z DEBUG rust_script] overwrite_file("/Users/dta/Library/Caches/rust-script/projects/65f3c77206ea3caf68f2d30d/Cargo.toml", _, Some("a8e53ac300f30974d4a72844ff059f9142643863"))
[2022-05-21T18:42:48Z DEBUG rust_script] .. hashes match
[2022-05-21T18:42:48Z DEBUG rust_script] overwrite_file("/Users/dta/Library/Caches/rust-script/projects/65f3c77206ea3caf68f2d30d/myscript.rs", _, Some("56ecf0b760b401c9aa37b7ff226399b2b988b458"))
[2022-05-21T18:42:48Z DEBUG rust_script] .. hashes match
[2022-05-21T18:42:48Z INFO  rust_script] emitting metadata...
[2022-05-21T18:42:48Z DEBUG rust_script] meta_path: "/Users/dta/Library/Caches/rust-script/projects/65f3c77206ea3caf68f2d30d/metadata.json"
[2022-05-21T18:42:48Z INFO  rust_script] disarming pkg dir cleanup...
[2022-05-21T18:42:48Z INFO  rust_script] running `cargo run`
[2022-05-21T18:42:48Z INFO  rust_script] cleaning cache with max_age: 604800000
[2022-05-21T18:42:48Z INFO  rust_script] cutoff:            1652553768992 ms
[2022-05-21T18:42:48Z INFO  rust_script] checking: "/Users/dta/Library/Caches/rust-script/projects/d2ff9865f1eaa9644ad89e24"
[2022-05-21T18:42:48Z INFO  rust_script] meta_mtime:        1653158506101 ms
[2022-05-21T18:42:48Z INFO  rust_script] checking: "/Users/dta/Library/Caches/rust-script/projects/65f3c77206ea3caf68f2d30d"
[2022-05-21T18:42:48Z INFO  rust_script] meta_mtime:        1653158568990 ms
[2022-05-21T18:42:48Z INFO  rust_script] checking: "/Users/dta/Library/Caches/rust-script/projects/469150566bd728fc90b4adf6"
[2022-05-21T18:42:48Z INFO  rust_script] meta_mtime:        1653157831910 ms
[2022-05-21T18:42:48Z INFO  rust_script] checking: "/Users/dta/Library/Caches/rust-script/projects/e4e0ddc7731ab1b525ef66f2"
[2022-05-21T18:42:48Z INFO  rust_script] meta_mtime:        1653157605894 ms
[2022-05-21T18:42:48Z INFO  rust_script] checking: "/Users/dta/Library/Caches/rust-script/projects/871fdb4f6a736fff1ddcba23"
[2022-05-21T18:42:48Z INFO  rust_script] meta_mtime:        1653158135317 ms
[2022-05-21T18:42:48Z INFO  rust_script] done cleaning cache.
error: No such file or directory (os error 2)
@fornwall
Copy link
Owner

@DavidDTA Could you retry with the latest version - just released version 0.23.0? If the problem persists, could you perhaps use strace to see where the problem is (which file or directory does not exist)?

@fornwall fornwall added bug Something isn't working help wanted Extra attention is needed labels Mar 25, 2023
@DavidDTA
Copy link
Author

I'm afraid I no longer have a nix setup, and won't be able to retry

@bcdroid
Copy link

bcdroid commented Mar 25, 2023

I had had the same problem, but it appears to now work without problems with both 0.22.0 and 0.23.0. Thank you!

@fornwall
Copy link
Owner

@DavidDTA & @bcdroid: Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants