"cannot write modified lock file" in repl when loading a flake via `:lf`
Describe the bug
When I load a flake in nix repl via :lf, nix throws the error: cannot write modified lock file.
Steps To Reproduce
> nix shell nix
> nix repl
Welcome to Nix 2.7.0pre20220203_bd383d1. Type :? for help.
nix-repl> :lf home-manager/release-21.11
error: cannot write modified lock file of flake 'flake:home-manager/release-21.11' (use '--no-write-lock-file' to igno
> nix repl --no-write-lock-file
error: unrecognised flag '--no-write-lock-file'
Try 'nix --help' for more information.
Expected behavior
load the flake and load its attributes
nix-env --version output
nix-env (Nix) 2.7.0pre20220203_bd383d1
I'm seeing this as well. Any idea why it happens?
This doesn't seem to be specific to nix repl, but to happen with all repos that don't include a flake.lock.
Faced this problem too.
A bit of context, I was trying digging into github:nix-community/poetry2nix flake but faced this.
- Since nix 2.10.0+ this is the way to load the
nix repl:
nix repl --expr 'import <nixpkgs> {}'
- Trying to load poetry2nix flake:
:lf github:nix-community/poetry2nix
Outputs this error:
nix-repl> :lf github:nix-community/poetry2nix
error: cannot write modified lock file of flake 'github:nix-community/poetry2nix' (use '--no-write-lock-file' to ignore)
Some metadata
nix \
run \
nixpkgs#nix-info -- --markdown
- system:
"x86_64-linux" - host os:
Linux 5.15.53, NixOS, 22.11 (Raccoon), 22.11.20220715.65fae65 - multi-user?:
yes - sandbox:
yes - version:
nix-env (Nix) 2.10.2 - nixpkgs:
/nix/var/nix/profiles/per-user/root/channels/nixos
This issue/bug seems to exist on nix v2.17.
I even tried to run the repl with $ nix --experimental-features flakes repl I still get the same errors mentioned above.
I don't fully understand what I am doing but running nix flake info seemed to create the flake.lock file and after that :lf . worked in nix repl.