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

Tests failing under on Nix build (Linux / maybe MacOS): crates/lovely-core/src/log.rs:51:37 called Result::unwrap() on an Err value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" } #106

Open
antipatico opened this issue Dec 31, 2024 · 4 comments

Comments

@antipatico
Copy link

antipatico commented Dec 31, 2024

Hi!
I am the (unofficial) maintainer of balatro and lovely on NixOS! A while ago I packaged balatro and lovely-injector for NixOS.

Everything seems to be in order and working, other than I have to disable tests for lovely which fails with the following error:

cargoBuildHook flags: -j 16 --target x86_64-unknown-linux-gnu --offline --profile release
   Compiling version_check v0.9.4
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling autocfg v1.1.0
   Compiling cfg-if v1.0.0
   Compiling typenum v1.17.0
   Compiling crc32fast v1.4.0
   Compiling libc v0.2.153
   Compiling serde v1.0.197
   Compiling zerocopy v0.7.32
   Compiling once_cell v1.19.0
   Compiling windows_x86_64_gnu v0.48.5
   Compiling adler v1.0.2
   Compiling memchr v2.7.1
   Compiling equivalent v1.0.1
   Compiling windows_x86_64_gnu v0.52.4
   Compiling forward-dll-derive v0.1.16
   Compiling miniz_oxide v0.7.2
   Compiling str_indices v0.4.3
   Compiling hashbrown v0.14.3
   Compiling windows-targets v0.48.5
   Compiling winnow v0.6.5
   Compiling option-ext v0.2.0
   Compiling regex-syntax v0.8.2
   Compiling smallvec v1.13.1
   Compiling windows-sys v0.48.0
   Compiling windows-targets v0.52.4
   Compiling iana-time-zone v0.1.60
   Compiling ahash v0.8.11
   Compiling generic-array v0.14.7
   Compiling memoffset v0.9.0
   Compiling num-traits v0.2.19
   Compiling ropey v1.6.1
   Compiling either v1.12.0
   Compiling flate2 v1.0.28
   Compiling aho-corasick v1.1.2
   Compiling quote v1.0.35
   Compiling same-file v1.0.6
   Compiling object v0.30.4
   Compiling syn v2.0.52
   Compiling indexmap v2.2.5
   Compiling dirs-sys v0.4.1
   Compiling log v0.4.21
   Compiling cpufeatures v0.2.12
   Compiling dirs v5.0.1
   Compiling walkdir v2.5.0
   Compiling itertools v0.13.0
   Compiling windows-result v0.1.0
   Compiling crop v0.4.2
   Compiling chrono v0.4.38
   Compiling libloading v0.8.3
   Compiling getargs v0.5.0
   Compiling regex-lite v0.1.5
   Compiling wildmatch v2.3.0
   Compiling lazy_static v1.4.0
   Compiling bitflags v1.3.2
   Compiling iced-x86 v1.21.0
   Compiling windows-core v0.54.0
   Compiling block-buffer v0.10.4
   Compiling crypto-common v0.1.6
   Compiling digest v0.10.7
   Compiling region v3.0.0
   Compiling object v0.32.2
   Compiling sha2 v0.10.8
   Compiling mmap-fixed-fixed v0.1.3
   Compiling slice-pool2 v0.4.3
   Compiling widestring v1.0.2
   Compiling regex-automata v0.4.6
   Compiling windows v0.54.0
   Compiling implib v0.3.2
   Compiling serde_derive v1.0.197
   Compiling ctor v0.2.9
   Compiling forward-dll v0.1.16
   Compiling lovely-win v0.1.0 (/build/source/crates/lovely-win)
   Compiling regex-cursor v0.1.4
   Compiling retour v0.4.0-alpha.2 (https://github.com/Hpmason/retour-rs.git#3bab630e)
   Compiling toml_datetime v0.6.5
   Compiling serde_spanned v0.6.5
   Compiling serde_ignored v0.1.10
   Compiling toml_edit v0.22.6
   Compiling toml v0.8.10
   Compiling lovely-core v0.6.0 (/build/source/crates/lovely-core)
   Compiling lovely-unix v0.1.0 (/build/source/crates/lovely-unix)
    Finished `release` profile [optimized] target(s) in 19.40s
Executing cargoInstallPostBuildHook
Finished cargoInstallPostBuildHook
Finished cargoBuildHook
Running phase: checkPhase
Executing cargoCheckHook
cargoCheckHook flags: -j 16 --profile release --target x86_64-unknown-linux-gnu --offline -- --test-threads=16
   Compiling lovely-core v0.6.0 (/build/source/crates/lovely-core)
   Compiling lovely-unix v0.1.0 (/build/source/crates/lovely-unix)
   Compiling lovely-win v0.1.0 (/build/source/crates/lovely-win)
    Finished `release` profile [optimized] target(s) in 0.74s
     Running unittests src/lib.rs (target/x86_64-unknown-linux-gnu/release/deps/lovely_core-1400d502db3d2f11)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/x86_64-unknown-linux-gnu/release/deps/lovely-06036e4c23170cc0)
thread '<unnamed>' panicked at crates/lovely-core/src/log.rs:51:37:
called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at core/src/panicking.rs:221:5:
panic in a function that cannot unwind
stack backtrace:
   0:     0x555555670fa9 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2f5a6b58013db6e9
   1:     0x5555556946c3 - core::fmt::write::hfa96557f28429d69
   2:     0x555555659b23 - std::io::Write::write_fmt::h37f3912886494215
   3:     0x555555670df3 - std::sys::backtrace::BacktraceLock::print::h82a3e77ee14f93d1
   4:     0x555555662704 - std::panicking::default_hook::{{closure}}::h4089ac0fd21dfdaa
   5:     0x5555556624e8 - std::panicking::default_hook::hde6b2b92b4b8a422
   6:     0x555555662b74 - std::panicking::rust_panic_with_hook::h04d84002b0e420ae
   7:     0x555555671c56 - std::panicking::begin_panic_handler::{{closure}}::hf0b93ce775256187
   8:     0x5555556711d9 - std::sys::backtrace::__rust_end_short_backtrace::h13db8456c52fd998
   9:     0x55555566279c - rust_begin_unwind
  10:     0x5555555721cd - core::panicking::panic_nounwind_fmt::hb0e640aeb48a1ef8
  11:     0x555555572262 - core::panicking::panic_nounwind::h748de3548a6142ec
  12:     0x555555572325 - core::panicking::panic_cannot_unwind::h63fdedee79346b5b
  13:     0x555555572aa3 - lovely::construct___rust_ctor___ctor::construct___rust_ctor___ctor::h45dfcb60ae8aa5be
  14:     0x7ffff7c2a32e - __libc_start_main_alias_2
  15:     0x555555572ad5 - _start
  16:                0x0 - <unknown>
thread caused non-unwinding panic. aborting.
error: test failed, to rerun pass `-p lovely-unix --lib`

Caused by:
  process didn't exit successfully: `/build/source/target/x86_64-unknown-linux-gnu/release/deps/lovely-06036e4c23170cc0 --test-threads=16` (signal: 6, SIGABRT: process abort signal)
error: builder for '/nix/store/f0yr7hp9xl7h7vr8bab1m5s6x3vc6krj-lovely-injector-0.6.0.drv' failed with exit code 101;
       last 50 log lines:
       >    Compiling toml_edit v0.22.6
       >    Compiling toml v0.8.10
       >    Compiling lovely-core v0.6.0 (/build/source/crates/lovely-core)
       >    Compiling lovely-unix v0.1.0 (/build/source/crates/lovely-unix)
       >     Finished `release` profile [optimized] target(s) in 19.40s
       > Executing cargoInstallPostBuildHook
       > Finished cargoInstallPostBuildHook
       > Finished cargoBuildHook
       > Running phase: checkPhase
       > Executing cargoCheckHook
       > cargoCheckHook flags: -j 16 --profile release --target x86_64-unknown-linux-gnu --offline -- --test-threads=16
       >    Compiling lovely-core v0.6.0 (/build/source/crates/lovely-core)
       >    Compiling lovely-unix v0.1.0 (/build/source/crates/lovely-unix)
       >    Compiling lovely-win v0.1.0 (/build/source/crates/lovely-win)
       >     Finished `release` profile [optimized] target(s) in 0.74s
       >      Running unittests src/lib.rs (target/x86_64-unknown-linux-gnu/release/deps/lovely_core-1400d502db3d2f11)
       >
       > running 0 tests
       >
       > test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
       >
       >      Running unittests src/lib.rs (target/x86_64-unknown-linux-gnu/release/deps/lovely-06036e4c23170cc0)
       > thread '<unnamed>' panicked at crates/lovely-core/src/log.rs:51:37:
       > called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
       > note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       > thread '<unnamed>' panicked at core/src/panicking.rs:221:5:
       > panic in a function that cannot unwind
       > stack backtrace:
       >    0:     0x555555670fa9 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2f5a6b58013db6e9
       >    1:     0x5555556946c3 - core::fmt::write::hfa96557f28429d69
       >    2:     0x555555659b23 - std::io::Write::write_fmt::h37f3912886494215
       >    3:     0x555555670df3 - std::sys::backtrace::BacktraceLock::print::h82a3e77ee14f93d1
       >    4:     0x555555662704 - std::panicking::default_hook::{{closure}}::h4089ac0fd21dfdaa
       >    5:     0x5555556624e8 - std::panicking::default_hook::hde6b2b92b4b8a422
       >    6:     0x555555662b74 - std::panicking::rust_panic_with_hook::h04d84002b0e420ae
       >    7:     0x555555671c56 - std::panicking::begin_panic_handler::{{closure}}::hf0b93ce775256187
       >    8:     0x5555556711d9 - std::sys::backtrace::__rust_end_short_backtrace::h13db8456c52fd998
       >    9:     0x55555566279c - rust_begin_unwind
       >   10:     0x5555555721cd - core::panicking::panic_nounwind_fmt::hb0e640aeb48a1ef8
       >   11:     0x555555572262 - core::panicking::panic_nounwind::h748de3548a6142ec
       >   12:     0x555555572325 - core::panicking::panic_cannot_unwind::h63fdedee79346b5b
       >   13:     0x555555572aa3 - lovely::construct___rust_ctor___ctor::construct___rust_ctor___ctor::h45dfcb60ae8aa5be
       >   14:     0x7ffff7c2a32e - __libc_start_main_alias_2
       >   15:     0x555555572ad5 - _start
       >   16:                0x0 - <unknown>
       > thread caused non-unwinding panic. aborting.
       > error: test failed, to rerun pass `-p lovely-unix --lib`
       >
       > Caused by:
       >   process didn't exit successfully: `/build/source/target/x86_64-unknown-linux-gnu/release/deps/lovely-06036e4c23170cc0 --test-threads=16` (signal: 6, SIGABRT: process abort signal)
       For full logs, run 'nix log /nix/store/f0yr7hp9xl7h7vr8bab1m5s6x3vc6krj-lovely-injector-0.6.0.drv'.

I am no Rust expert, but I think the problem is because the test is trying to create the log directory in the home folder of the user which is obviously not available in any standard sandboxed build environment such as Nix.

Unfortunately, my rust knowledge gets me only this far. It would be great if this can be fixed, so that tests can run on linux too!

Thank you for the amazing work.

@antipatico
Copy link
Author

Exporting a temp directory as home still results in a crash:

>      Running unittests src/lib.rs (target/x86_64-unknown-linux-gnu/release/deps/lovely-06036e4c23170cc0)
       > INFO - [♥] Lovely 0.6.0
       > thread '<unnamed>' panicked at crates/lovely-core/src/lib.rs:79:47:
       > Failed to parse argument.: DoesNotRequireValue(Long("test-threads"))
       > note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       > thread '<unnamed>' panicked at core/src/panicking.rs:221:5:
       > panic in a function that cannot unwind
       > stack backtrace:
       >    0:     0x555555670fa9 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2f5a6b58013db6e9
       >    1:     0x5555556946c3 - core::fmt::write::hfa96557f28429d69
       >    2:     0x555555659b23 - std::io::Write::write_fmt::h37f3912886494215
       >    3:     0x555555670df3 - std::sys::backtrace::BacktraceLock::print::h82a3e77ee14f93d1
       >    4:     0x555555662704 - std::panicking::default_hook::{{closure}}::h4089ac0fd21dfdaa
       >    5:     0x5555556624e8 - std::panicking::default_hook::hde6b2b92b4b8a422
       >    6:     0x555555662b74 - std::panicking::rust_panic_with_hook::h04d84002b0e420ae
       >    7:     0x555555671c56 - std::panicking::begin_panic_handler::{{closure}}::hf0b93ce775256187
       >    8:     0x5555556711d9 - std::sys::backtrace::__rust_end_short_backtrace::h13db8456c52fd998
       >    9:     0x55555566279c - rust_begin_unwind
       >   10:     0x5555555721cd - core::panicking::panic_nounwind_fmt::hb0e640aeb48a1ef8
       >   11:     0x555555572262 - core::panicking::panic_nounwind::h748de3548a6142ec
       >   12:     0x555555572325 - core::panicking::panic_cannot_unwind::h63fdedee79346b5b
       >   13:     0x555555572aa3 - lovely::construct___rust_ctor___ctor::construct___rust_ctor___ctor::h45dfcb60ae8aa5be
       >   14:     0x7ffff7c2a32e - __libc_start_main_alias_2
       >   15:     0x555555572ad5 - _start
       >   16:                0x0 - <unknown>
       > thread caused non-unwinding panic. aborting.
       > error: test failed, to rerun pass `-p lovely-unix --lib`
       >
       > Caused by:
       >   process didn't exit successfully: `/build/source/target/x86_64-unknown-linux-gnu/release/deps/lovely-06036e4c23170cc0 --test-threads=16` (signal: 6, SIGABRT: process abort signal)
       For full logs, run 'nix log /nix/store/cncpsc72daxk8gvvp2sa56xga37ng1vb-lovely-injector-0.6.0.drv'.

@ethangreen-dev
Copy link
Owner

Hey @antipatico, thanks for your report. I think it's reasonable to include a way to disable the logfile. Would an environment variable be convenient?

@antipatico
Copy link
Author

I actually worked around the home issue by setting the HOME environment variable to a temporary directory. Unfortunately, the tests still fail.

@ethangreen-dev
Copy link
Owner

Arg parsing is at fault here, specifically https://docs.rs/getargs/latest/getargs/enum.Error.html#variant.DoesNotRequireValue. I'll tweak things so that operation doesn't cause an explicit panic.

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