busti
September 28, 2021, 9:36pm
1
I would like to use a nix shell environment to compile a project that needs emscripten. I have added the emscripten
package to it.
I am trying to execute em++ but it fails to build a cache in the /nix
directory.
Read-only file system: '/nix/store/<hash>-emscripten-2.0.27/share/emscripten/cache/ports
Is this a bug in the package itself? I guess it should be build in a way that would make it write that cache somewhere else.
Or am I doing something wrong?
1 Like
busti
September 30, 2021, 2:20am
2
It seems like it is intended behavior of the package itself, especially when it is being used in building other packages. However the current behavior does not work for interactive shell usage.
See the attached issue for more info and a workaround for development usage:
opened 05:13PM - 29 Sep 21 UTC
closed 05:49PM - 22 May 22 UTC
0.kind: bug
### 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.
1. `git clone https://github.com/ocornut/imgui.git`
2. `cd examples/example_emscripten_opengl3`
3. create a file named `shell.nix` with the following contents:
```shell.nix
{pkgs ? import <nixpkgs> {}}: pkgs.mkShell {
nativeBuildInputs = with pkgs; [
gnumake gcc
];
buildInputs = with pkgs; [
emscripten
];
}
```
4. run `nix-shell`
5. run `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:
```
$ make
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
Traceback (most recent call last):
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/em++.py", line 14, in <module>
sys.exit(emcc.run(sys.argv))
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/emcc.py", line 1074, in run
linker_inputs = phase_compile_inputs(options, state, newargs, input_files)
File "/nix/store/dqxic3j7csd4ywn94n4smmnz55p039g3-python3-3.9.6/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/emcc.py", line 2436, in phase_compile_inputs
compile_source_file(i, input_file)
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/emcc.py", line 2416, in compile_source_file
cmd = get_clang_command(input_file)
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/emcc.py", line 2357, in get_clang_command
return get_compiler(use_cxx(src_file)) + get_cflags(options, state.orig_args) + compile_args + [src_file]
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/emcc.py", line 879, in get_cflags
system_libs.add_ports_cflags(cflags, settings)
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/tools/system_libs.py", line 1969, in add_ports_cflags
port.get(Ports, settings, shared)
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/tools/ports/sdl2.py", line 23, in get
ports.fetch_project('sdl2', 'https://github.com/emscripten-ports/SDL2/archive/' + TAG + '.zip', SUBDIR, sha512hash=HASH)
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/tools/system_libs.py", line 1765, in fetch_project
fullname = os.path.join(Ports.get_dir(), name)
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/tools/system_libs.py", line 1746, in get_dir
shared.safe_ensure_dirs(dirname)
File "/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/tools/utils.py", line 27, in safe_ensure_dirs
os.makedirs(dirname, exist_ok=True)
File "/nix/store/dqxic3j7csd4ywn94n4smmnz55p039g3-python3-3.9.6/lib/python3.9/os.py", line 225, in makedirs
mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/nix/store/ajv94air67dbyjramrjlv0y6j969hsyx-emscripten-2.0.27/share/emscripten/cache/ports'
make: *** [Makefile:70: main.o] Error 1
```
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
- system: `"x86_64-linux"`
- host os: `Linux 5.13.4, NixOS, 21.11 (Porcupine)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.3.15`
- channels(root): `"nixos-21.11pre318500.51bcdc4cdaa"`
- channels(mbust): `""`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
1 Like
Thank you, I was also trying to use emscripten from the command line nix-shell -p emscripten
I got the same error OSError: [Errno 30] Read-only file system:
for the emscripten cache
your quick fix still works for emscripten 3.1.45