mattwparas / steel

An embedded scheme interpreter in Rust
Apache License 2.0
1.22k stars 55 forks source link

`cargo run -- install.scm` fails with `os error 2`: no such file or directory #182

Closed cgahr closed 6 months ago

cgahr commented 8 months ago

currently nix build and nix shell does not work.

Running either command errors with

> error: package `clap_builder v4.5.2` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.72.1
> Either upgrade to rustc 1.74 or newer, or use
> cargo update -p clap_builder@4.5.2 --precise ver
> where `ver` is the latest version of `clap_builder` supporting rustc 1.72.1

This is easily fixable by updating flake.lock (i.e. calling nix flake update).

After updating, nix build and nix shell now fails with a SteelErr with message

"Struct getter expected Ok, found Gc(UserDefinedStruct { fields: [Error: Io: No such file or directory (os error 2)], type_descriptor: StructTypeDescriptor(1) }), (Err Error: Io: No such file or directory (os error 2))"
full output
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/ry52wmz97b9il1ixg60gk1zgmjr5pqfw-source
source root is source
Executing cargoSetupPostUnpackHook
Finished cargoSetupPostUnpackHook
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
Executing cargoSetupPostPatchHook
Validating consistency between /build/source/Cargo.lock and /build/cargo-vendor-dir/Cargo.lock
Finished cargoSetupPostPatchHook
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
Executing cargoBuildHook
++ env CC_X86_64_UNKNOWN_LINUX_GNU=/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin/cc CXX_X86_64_UNKNOWN_LINUX_GNU=/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin/c++ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin/cc CC_X86_64_UNKNOWN_LINUX_GNU=/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin/cc CXX_X86_64_UNKNOWN_LINUX_GNU=/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin/c++ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin/cc CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu HOST_CC=/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin/cc HOST_CXX=/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin/c++ cargo build -j 8 --target x86_64-unknown-linux-gnu --frozen --profile release
   Compiling autocfg v1.1.0
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.153
   Compiling cfg-if v1.0.0
   Compiling smallvec v1.13.1
   Compiling serde v1.0.197
   Compiling parking_lot_core v0.9.9
   Compiling scopeguard v1.2.0
   Compiling crossbeam-utils v0.8.19
   Compiling version_check v0.9.4
   Compiling log v0.4.21
   Compiling once_cell v1.19.0
   Compiling syn v1.0.109
   Compiling indexmap v1.9.3
   Compiling lock_api v0.4.11
   Compiling num-traits v0.2.18
   Compiling cc v1.0.90
   Compiling signal-hook v0.3.17
   Compiling ahash v0.8.11
   Compiling num-bigint v0.4.4
   Compiling quote v1.0.35
   Compiling hashbrown v0.12.3
   Compiling typenum v1.17.0
   Compiling syn v2.0.52
   Compiling core_extensions v1.5.3
   Compiling unicode-width v0.1.11
   Compiling rustix v0.38.31
   Compiling bitflags v1.3.2
   Compiling getrandom v0.2.12
   Compiling num-integer v0.1.46
   Compiling parking_lot v0.12.1
   Compiling signal-hook-registry v1.4.1
   Compiling rand_core v0.6.4
   Compiling mio v0.8.11
   Compiling crossbeam-channel v0.5.12
   Compiling slab v0.4.9
   Compiling num-rational v0.4.1
   Compiling zerocopy v0.7.32
   Compiling core_extensions_proc_macros v1.5.3
   Compiling tstr_proc_macros v0.2.2
   Compiling linux-raw-sys v0.4.13
   Compiling paste v1.0.14
   Compiling bitflags v2.4.2
   Compiling serde_json v1.0.114
   Compiling tstr v0.2.3
   Compiling signal-hook-mio v0.2.3
   Compiling psm v0.1.21
   Compiling codegen v0.2.0
   Compiling abi_stable_shared v0.11.0
   Compiling crossbeam-epoch v0.9.18
   Compiling typed-arena v2.0.2
   Compiling hashbrown v0.14.3
   Compiling thiserror v1.0.57
   Compiling memchr v2.7.1
   Compiling itoa v1.0.10
   Compiling ryu v1.0.17
   Compiling utf8parse v0.2.1
   Compiling bitmaps v2.1.0
   Compiling crossbeam-deque v0.8.5
   Compiling crossterm v0.23.2
   Compiling repr_offset v0.2.2
   Compiling dashmap v5.5.3
   Compiling as_derive_utils v0.11.0
   Compiling num-iter v0.1.44
   Compiling stacker v0.1.15
   Compiling crossbeam-queue v0.3.11
   Compiling im-rc v15.1.0
   Compiling generational-arena v0.2.9
   Compiling libloading v0.7.4
   Compiling termcolor v1.4.1
   Compiling byteorder v1.5.0
   Compiling option-ext v0.2.0
   Compiling const_panic v0.2.8
   Compiling futures-task v0.3.30
   Compiling pin-utils v0.1.0
   Compiling ppv-lite86 v0.2.17
   Compiling arrayvec v0.5.2
   Compiling strsim v0.11.0
   Compiling futures-core v0.3.30
   Compiling pin-project-lite v0.2.13
   Compiling fxhash v0.2.1
   Compiling dirs-sys v0.4.1
   Compiling pretty v0.12.3
   Compiling crossbeam v0.8.4
   Compiling rand_chacha v0.3.1
   Compiling coolor v0.5.0
   Compiling sized-chunks v0.6.5
   Compiling serde_derive v1.0.197
   Compiling thiserror-impl v1.0.57
   Compiling futures-macro v0.3.30
   Compiling rand_xoshiro v0.6.0
   Compiling minimad v0.10.0
   Compiling iana-time-zone v0.1.60
   Compiling either v1.10.0
   Compiling home v0.5.9
   Compiling chrono v0.4.35
   Compiling which v4.4.2
   Compiling futures-util v0.3.30
   Compiling rand v0.8.5
   Compiling termimad v0.21.1
   Compiling steel-derive v0.5.0 (/build/source/crates/steel-derive)
   Compiling abi_stable_derive v0.11.3
   Compiling dirs v5.0.1
   Compiling codespan-reporting v0.11.1
   Compiling aho-corasick v1.1.2
   Compiling anstyle-parse v0.2.3
   Compiling quickscope v0.2.0
   Compiling futures-executor v0.3.30
   Compiling dirs-sys-next v0.1.2
   Compiling im-lists v0.8.0
   Compiling nibble_vec v0.1.0
   Compiling anstyle-query v1.0.2
   Compiling radix_fmt v1.0.0
   Compiling weak-table v0.3.2
   Compiling anstyle v1.0.6
   Compiling endian-type v0.1.2
   Compiling regex-syntax v0.8.2
   Compiling colorchoice v1.0.0
   Compiling anstream v0.6.13
   Compiling radix_trie v0.2.1
   Compiling dirs-next v2.0.0
   Compiling fd-lock v3.0.13
   Compiling nix v0.25.1
   Compiling lazy_static v1.4.0
   Compiling clap_lex v0.7.0
   Compiling unicode-segmentation v1.11.0
   Compiling heck v0.4.1
   Compiling clap_derive v4.5.0
   Compiling regex-automata v0.4.6
   Compiling rustyline v10.1.1
   Compiling clap_builder v4.5.2
   Compiling steel-gen v0.2.0 (/build/source/crates/steel-gen)
   Compiling regex v1.10.3
   Compiling num-complex v0.4.5
   Compiling hashbrown v0.13.2
   Compiling steel-core v0.6.0 (/build/source/crates/steel-core)
   Compiling bincode v1.3.3
   Compiling lasso v0.7.2
   Compiling abi_stable v0.11.3
   Compiling num v0.4.1
   Compiling colored v2.1.0
   Compiling steel-parser v0.6.0 (/build/source/crates/steel-parser)
   Compiling rustyline-derive v0.7.0
   Compiling is-terminal v0.4.12
   Compiling humantime v2.1.0
   Compiling clap v4.5.2
   Compiling env_logger v0.10.2
   Compiling async-ffi v0.5.0
   Compiling steel-repl v0.6.0 (/build/source/crates/steel-repl)
   Compiling steel-doc v0.6.0 (/build/source/crates/steel-doc)
   Compiling steel-interpreter v0.6.0 (/build/source)
    Finished release [optimized] target(s) in 3m 49s
Executing cargoInstallPostBuildHook
Finished cargoInstallPostBuildHook
Finished cargoBuildHook
buildPhase completed in 3 minutes 50 seconds
@nix { "action": "setPhase", "phase": "installPhase" }
Running phase: installPhase
Executing cargoInstallHook
/build/source/cogs /build/source
cogs directory does not exist, creating now...
Package is not currently installed.
=> Installing:  '#hash((package-name . steel/lists) (path . "/build/source/cogs/lists") (version . "0.1.0") (dependencies . ())) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/lists 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/lists

Package is not currently installed.
=> Installing:  '#hash((path . "/build/source/cogs/command-line") (version . "0.1.0") (package-name . steel/command-line) (dependencies . ())) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/command-line 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/command-line

Package is not currently installed.
=> Installing:  '#hash((package-name . steel/sorting) (version . "0.1.0") (dependencies . ()) (path . "/build/source/cogs/sorting")) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/sorting 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/sorting

Package is not currently installed.
=> Installing:  '#hash((dependencies . ()) (package-name . steel/collections) (path . "/build/source/cogs/collections") (version . "0.1.0")) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/collections 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/collections

Package is not currently installed.
=> Installing:  '#hash((package-name . steel/tests) (dependencies . ()) (version . "0.1.0") (path . "/build/source/cogs/tests")) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/tests 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/tests

Package is not currently installed.
=> Installing:  '#hash((version . "0.1.0") (path . "/build/source/cogs/srfi") (package-name . srfi) (dependencies . ())) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/srfi 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/srfi

Package is not currently installed.
=> Installing:  '#hash((dependencies . ()) (package-name . steel/fs) (version . "0.1.0") (path . "/build/source/cogs/fs")) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/fs 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/fs

Package is not currently installed.
=> Installing:  '#hash((version . "0.1.0") (package-name . steel/time) (path . "/build/source/cogs/time") (dependencies . ())) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/time 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel/time

Package is not currently installed.
=> Installing:  '#hash((path . "/build/source/cogs/installer") (dependencies . ()) (version . "0.1.0") (package-name . installer)) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/installer 
✅ Installed package to: /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/installer

Package is not currently installed.
=> Installing:  '#hash((path . "/build/source/cogs/slack") (version . "0.1.0") (dependencies . ('#hash((#:path . "../libs/steel-websockets") (#:name . steel-websockets)) '#hash((#:path . "../libs/steel-webrequests") (#:name . steel-webrequests)))) (package-name . slack/websocket)) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/slack/websocket 
=> Installing:  '#hash((version . "0.1.0") (package-name . steel-websockets) (dependencies . ()) (path . "../libs/steel-websockets") (dylibs . ('#hash((#:name . "steel-websockets") (#:workspace-root . "../..") (#:subdir . "libs/steel-websockets"))))) 
=> Copied package over to:  /nix/store/lh4y0sjnnqqmwmrzn91lbhfqim1md3ap-steel-interpreter-0.6.0/lib/cogs/steel-websockets 
Attempting to install:  '#hash((#:name . "steel-websockets") (#:workspace-root . "../..") (#:subdir . "libs/steel-websockets")) 
Running dylib build in:  ../libs/steel-websockets/../../libs/steel-websockets 
error[E03]: TypeMismatch
   ┌─ install.scm:11:1
   │
11 │ 
   │   Struct getter expected Ok, found Gc(UserDefinedStruct { fields: [Error: Io: No such file or directory (os error 2)], type_descriptor: StructTypeDescriptor(1) }), (Err Error: Io: No such file or directory (os error 2))

Error: SteelErr { repr: Repr { kind: TypeMismatch, message: "Struct getter expected Ok, found Gc(UserDefinedStruct { fields: [Error: Io: No such file or directory (os error 2)], type_descriptor: StructTypeDescriptor(1) }), (Err Error: Io: No such file or directory (os error 2))", span: Some(2535..2544), stack_trace: Some(DehydratedStackTrace { stack_trace: [DehydratedCallContext { span: Some(0..0) }, DehydratedCallContext { span: Some(0..0) }, DehydratedCallContext { span: None }, DehydratedCallContext { span: Some(0..0) }, DehydratedCallContext { span: Some(2161..2172) }, DehydratedCallContext { span: Some(0..0) }, DehydratedCallContext { span: Some(1555..1563) }, DehydratedCallContext { span: Some(0..0) }, DehydratedCallContext { span: Some(2161..2172) }, DehydratedCallContext { span: Some(1555..1563) }, DehydratedCallContext { span: Some(2182..2186) }, DehydratedCallContext { span: Some(2426..2452) }] }) } }
/nix/store/v099hqvw5z87423p4hz1vfhzaqa07dii-stdenv-linux/setup: line 131: pop_var_context: head of shell_variables not a function context

PS: the popd in line 41 in flake.nix seems to throw an error too, see the last line of the log

EDIT: I investigated this further. This is not a nix flake error! Instead this seems to originate from running cargo run -- install.scm from contributing.scm too! To me it looks like steel-websockets or steel-regex fails to install (depending on which machine I use)

mattwparas commented 8 months ago

Sorry I'm just seeing this! I don't develop on nix - but I'm guessing something with the flake.nix file isn't including the libs directory

cgahr commented 8 months ago

You probably missed my last edit :) I could reproduce this issue on a non nixos too!

mattwparas commented 8 months ago

You're right - I did miss the edit! Can you try this:

git clone https://github.com/mattwparas/steel.git &&
cd steel &&
mkdir -p .steel/cogs && mkdir -p .steel/native && # Creates this directory too 
export STEEL_HOME="$(pwd)/.steel" &&
cargo build &&
cargo install --path crates/cargo-steel-lib &&
pushd cogs &&
cargo run -- install.scm &&
popd &&
cargo test --all

I had thought that I would create that additional directory automatically; but it seems like I don't!

cgahr commented 8 months ago

This seems to give me the same error as before:

Package is not currently installed.
=> Installing:  '#hash((package-name . slack/websocket) (dependencies . ('#hash((#:path . "../libs/steel-websockets") (#:name . steel-websockets)) '#hash((#:name . steel-webrequests) (#:path . "../libs/steel-webrequests")))) (version . "0.1.0") (path . "/home/cgahr/coding/steel/tmp/steel/cogs/slack")) 
=> Copied package over to:  /home/cgahr/coding/steel/tmp/steel/.steel/cogs/slack/websocket 
=> Installing:  '#hash((dependencies . ()) (version . "0.1.0") (dylibs . ('#hash((#:name . "steel-websockets") (#:workspace-root . "../..") (#:subdir . "libs/steel-websockets")))) (path . "../libs/steel-websockets") (package-name . steel-websockets)) 
=> Copied package over to:  /home/cgahr/coding/steel/tmp/steel/.steel/cogs/steel-websockets 
Attempting to install:  '#hash((#:name . "steel-websockets") (#:workspace-root . "../..") (#:subdir . "libs/steel-websockets")) 
Running dylib build in:  ../libs/steel-websockets/../../libs/steel-websockets 
error[E03]: TypeMismatch
   ┌─ install.scm:11:1
   │
11 │ 
   │   Struct getter expected Ok, found Gc(UserDefinedStruct { fields: [Error: Io: No such file or directory (os error 2)], type_descriptor: StructTypeDescriptor(1) }), (Err Error: Io: No such file or directory (os error 2))
mattwparas commented 8 months ago

Okay so I'm realizing there might be more that needs to be done. In order to install dylibs we'll need the dylib installer which is installed separately as a cargo extension (eventually it doesn't need to be) - that is located under crates/cargo-steel-lib. Can you first try to install that with cargo install --path crates/cargo-steel-lib and then run the installer?

Apologies that this is all undocumented; this one slipped past me I think. There could be other things that I'm missing as well but that would be the first step to try debugging this

cgahr commented 8 months ago

Don't worry, as much is expected! So far, I enjoy steel very much. Looking forward to build helix plugins with it!

I'll keep you posted.

EDIT: I got is working! I think the issue stems from ~/.cargo/bin not being in my path. Hence, installing cargo-steel-lib went fine but it couldn't be found afterward. So in the end, this problem only exists for nix and on systems where ~/.cargo/bin is not on the path.

If it is okay for you, I'll create a PR updating flake.nix so that everything just works and close this issue then.

mattwparas commented 8 months ago

That sounds great! Thank you for investigating, I really appreciate it.

In the future I will most likely remove the need for cargo-steel-lib at all in the installation process and expose all of that behavior in steel itself to make things simpler, one less thing to need installed

Borwe commented 7 months ago

Okay so I'm realizing there might be more that needs to be done. In order to install dylibs we'll need the dylib installer which is installed separately as a cargo extension (eventually it doesn't need to be) - that is located under crates/cargo-steel-lib. Can you first try to install that with cargo install --path crates/cargo-steel-lib and then run the installer?

Apologies that this is all undocumented; this one slipped past me I think. There could be other things that I'm missing as well but that would be the first step to try debugging this

Thanks, had similar problem, but not using nix, just plain ubuntu, this fixed it.