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

nix develop nixpkgs#hello --unpack is broken when nixpkgs is a path ("Read-only filesystem") #7361

Open
cole-h opened this issue Nov 28, 2022 · 5 comments
Labels
bug new-cli Relating to the "nix" command nix-shell nix-shell, nix develop, nix print-dev-env, etc

Comments

@cole-h
Copy link
Member

cole-h commented Nov 28, 2022

Describe the bug

Running nix develop nixpkgs#hello --unpack to get an unpacked hello source directory gives me "Read-only filesystem" errors:

vin@scadrial /t/tmp.yXMNb8uiOD> nix develop nixpkgs#hello --unpack
unpacking source archive /nix/store/pa10z4ngm0g83kx9mssrqzz30s84vq7k-hello-2.12.1.tar.gz
tar: hello-2.12.1: Cannot mkdir: Read-only file system
[...]

Steps To Reproduce

  1. Run nix develop nixpkgs#hello --unpack
  2. See the pages of "Read-only filesystem" warnings, despite being in a writeable directory and filesystem.

Expected behavior

I'd expect to not see the "Read-only filesystem" errors and be dropped into a shell with access to the unpacked source.

nix-env --version output

nix-env (Nix) 2.12.0pre20221116_561440b (lazy trees branch, but also validated with the 2.11.0 release)

Additional context

N/A.

@cole-h cole-h added the bug label Nov 28, 2022
@natto1784
Copy link

natto1784 commented Nov 30, 2022

cannot reproduce with 2.12.0pre20221130_f91dc02 and 2.11.0

@cole-h
Copy link
Member Author

cole-h commented Dec 1, 2022

Interestingly, it works when I use github:nixos/nixpkgs/nixos-unstable#hello. The only difference is that I have a local registry reference for nixpkgs (https://github.com/cole-h/nixos-config/blob/37eef14c1f595001a124128ae3aa7700654d0c11/modules/config/nix.nix) (so that my system and nix shell nixpkgs#.... invocations use the same nixpkgs).

Here are the -vvvvv logs for both: https://gist.github.com/cole-h/761a3e55417ee8343a4b16d4597a3dc4

@natto1784
Copy link

that is weird because I use separate nixpkgs registries for my system and user, and it still worked

@thufschmitt
Copy link
Member

thufschmitt commented Dec 6, 2022

I can indeed reproduce it when nixpkgs is set to a local path.

That's because there's a logic to automatically cd to the right place for local flakes (#4176):

nix/src/nix/develop.cc

Lines 563 to 566 in eece14d

if (sourcePath) {
if (chdir(sourcePath->c_str()) == -1) {
throw SysError("chdir to '%s' failed", *sourcePath);
}

That behaviour makes sense in combination with #5720 for running nix develop --build somewhere inside the source tree of my flake, but in hindsight it doesn't so much when running it from outside it.

I think we could disable that at the very least when the flake is in the store.

@cole-h cole-h changed the title nix develop nixpkgs#hello --unpack appears broken ("Read-only filesystem") nix develop nixpkgs#hello --unpack is broken when nixpkgs is a path ("Read-only filesystem") Dec 6, 2022
@roberth roberth added the nix-shell nix-shell, nix develop, nix print-dev-env, etc label Dec 19, 2022
@stale stale bot added the stale label Jun 18, 2023
@cole-h
Copy link
Member Author

cole-h commented Jun 20, 2023

Not stale, still happens as of nix (Nix) 2.17.0pre20230605_9c6ede8.

@stale stale bot removed the stale label Jun 20, 2023
@fricklerhandwerk fricklerhandwerk added the new-cli Relating to the "nix" command label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new-cli Relating to the "nix" command nix-shell nix-shell, nix develop, nix print-dev-env, etc
Projects
None yet
Development

No branches or pull requests

5 participants