Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nix-shell error - mkdir: cannot create directory '/nix/store/...': Read-only file system

Tags:

nixos

I'm using nix-shell to debug my package. The configure script looks like this:

configurePhase = ''
  mkdir -p $out
  ...
'';

When running via nix-build, this code is OK, but when running with nix-shell I cannot create $out directory when running configurePhase

mkdir: cannot create directory '/nix/store/...': Read-only file system

I understand why that happens, but how to fix this?

like image 412
danbst Avatar asked Jul 22 '15 09:07

danbst


1 Answers

This happens because $out points to /nix/store/... which is mounted as readonly.

As Eelco Dolstra pointed, there are at leasy two ways to fix this:

  • Don't create $out in configurePhase, do it in installPhase instead.

  • Set $out to some different value.

You can set $out variable with

nix-shell --command "export out=/tmp/foo; return"
like image 189
danbst Avatar answered Nov 09 '22 08:11

danbst