-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
Emscripten tries to write to /nix/store #139943
Comments
Emscripten's compilation model clashes a bit with nix. For obvious reasons, emscripten requires wasm-compiled libc and libc++ libraries. Vanilla emscripten compiles these libraries on demand when they are first needed (this is called caching, and the compiled library is stored in the cache directory). In nix, this approach is very unsatisfactory because it means that emscripten would recompile libc again from scratch in every derivation that uses emscripten (because using an outside cache would of course make the derivation nonreproducible). Therefore we are creating a read-only cache during the emscripten build that contains "all possible" pre-compiled versions of libc and libc++ (there are different builds depending on whether you exceptions enabled or not, etc.). Sometimes we are missing one such combination, maybe this is the case here. |
Thanks to @yu-re-ka for providing me with a quick-fix for this:
@gebner I see how this approach is necessary to provide an experience that is satisfactory for nixos. Whatever the case, I am personally not trying to create a nixos package, but instead want to use emscripten on the command line. Could this behavior perhaps be implemented into the package so that using emscripten in private projects does not fail with cryptic error messages? |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/emscripten-tries-to-write-to-nix/15263/2 |
To the best of my knowledge, no, it doesn't. It only caches libc and libc++. You are responsible to provide other libraries (like you would with libfoo.so for a native target).
This is an interesting idea. Maybe we should just add a line here to check if there is a precompiled file available. (That is, first try the emscripten package and then fall back to the emscripten cache in the home directory.) |
Good suggestion. |
I marked this as stale due to inactivity. → More info |
Note that #172207 attempts to resolve this by just creating a local dot directory for each package. I'm not sure how else this could be addressed with a more global system-wide cache given the restrictions on previous derivations being writable. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/improving-an-emscripten-yarn-dev-shell-flake/33045/1 |
This worked for me: { pkgs ? import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz";
sha256 = "10wn0l08j9lgqcw8177nh2ljrnxdrpri7bp0g7nvrsn9rkawvlbf";
}) {}
}:
pkgs.mkShell {
EM_CONFIG = pkgs.writeText ".emscripten" ''
EMSCRIPTEN_ROOT = '${pkgs.emscripten}/share/emscripten'
LLVM_ROOT = '${pkgs.emscripten.llvmEnv}/bin'
BINARYEN_ROOT = '${pkgs.binaryen}'
NODE_JS = '${pkgs.nodejs-18_x}/bin/node'
CACHE = '${toString ./.cache}'
'';
buildInputs = [
pkgs.emscripten
];
} |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/emscripten-tries-to-write-to-nix/15263/3 |
Describe the bug
I am trying to compile a project which (among other things) uses emscripten.
I have created a custom
shell.nix
file to create a development environment for the project.Executing the makefile fails when it gets to compiling the emscripten part of the project with the following error message:
OSError: [Errno 30] Read-only file system: '/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/cache/ports'
Steps To Reproduce
The project makes use of the open source project imgui. One of it's examples can be used to reproduce the error message.
git clone https://github.com/ocornut/imgui.git
cd examples/example_emscripten_opengl3
shell.nix
with the following contents:nix-shell
make
Expected behavior
The command succeeds resulting in a compiled executable of the example project.
Real behavior
The execution of
make
fails with the following error:During building of the example project make tries to execute the command:
em++ -DIMGUI_DISABLE_FILE_FUNCTIONS -I../.. -I../../backends -Wall -Wformat -Os -s USE_SDL=2 -s DISABLE_EXCEPTION_CATCHING=1 -c -o main.o main.cpp
which fails with the error:
OSError: [Errno 30] Read-only file system: '/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/cache/ports'
Notify maintainers
@qknight
@matthewbauer
Metadata
"x86_64-linux"
Linux 5.13.4, NixOS, 21.11 (Porcupine)
yes
yes
nix-env (Nix) 2.3.15
"nixos-21.11pre318500.51bcdc4cdaa"
""
/nix/var/nix/profiles/per-user/root/channels/nixos
The text was updated successfully, but these errors were encountered: