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 can't find libjanet on NixOS #88

Open
na-sa-do opened this issue Jan 25, 2024 · 2 comments
Open

Tests can't find libjanet on NixOS #88

na-sa-do opened this issue Jan 25, 2024 · 2 comments

Comments

@na-sa-do
Copy link

na-sa-do commented Jan 25, 2024

NixOS has an unusual filesystem layout in which packages live under unique paths in /nix/store, and PATH and similar environment variables are manipulated to ensure each program can find the libraries meant for it and no others. For example, on my system ,which janet is /nix/store/n36k55y82g9qlcdxwy7v0gpjwhias7xw-janet-1.33.0/bin/janet. (If janet linked to any dynamic libraries, this would be a shell script that sets up the variables and then execs into the actual janet binary, but it doesn't so that step isn't necessary.)

Although jpm show-paths prints the correct paths, for whatever reason, when running jpm test, it defaults to /usr/local/lib/libjanet.a and fails when that file doesn't exist. Setting JANET_LIBPATH explicitly makes it work.

@sogaiu
Copy link

sogaiu commented Jan 26, 2024

Possibly related #36.

@whacked
Copy link

whacked commented Jan 28, 2024

I've encountered a related problem when trying to create an environment to build static binaries, discussion here. With sogaiu's help I created a working flake that bundles jpm which you can find here.

The problem with this flake is that jpm seems to want to install new packages under the same hierarchy as janet, so within the flake env, while you can run jpm, you cannot install any packages, because in the nix store, this hierarchy is read-only at runtime. In theory you could bundle all jpm packages you need at flake build time but this will be a hassle in pure builds because nix will disallow network access.

I took the easy way out now by doing sudo chmod +w against janet's store path (I use nix on Ubuntu so I don't know if this is harder on NixOS). My flake could be missing other configurations because even with JANET_LIBPATH running e.g. jpm install spork, it logs this

generating /nix/store/y2qg5yk96safcv0ig4l384vbikq4qz9i-janet-musl-with-jpm/jpm/.manifests/spork.jdn...
Installed as 'spork'.
copying spork to /nix/store/y2qg5yk96safcv0ig4l384vbikq4qz9i-janet-musl-with-jpm/jpm...
installing bin/janet-format to /bin/janet-format
error: could not open file /bin/janet-format with mode wb

so /nix/store/y2qg5yk96safcv0ig4l384vbikq4qz9i-janet-musl-with-jpm/jpm/.manifests/spork.jdn succeeds due to my chmod hack; but finally it fails because something is empty and it attempts to write to /bin/janet-format

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

3 participants