nix icon indicating copy to clipboard operation
nix copied to clipboard

"cannot write modified lock file" in repl when loading a flake via `:lf`

Open DavHau opened this issue 3 years ago • 2 comments

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

DavHau avatar Feb 06 '22 07:02 DavHau

I'm seeing this as well. Any idea why it happens?

OliverEvans96 avatar May 03 '22 22:05 OliverEvans96

This doesn't seem to be specific to nix repl, but to happen with all repos that don't include a flake.lock.

lheckemann avatar Aug 01 '22 21:08 lheckemann

Faced this problem too.

A bit of context, I was trying digging into github:nix-community/poetry2nix flake but faced this.

  1. Since nix 2.10.0+ this is the way to load the nix repl :
nix repl --expr 'import <nixpkgs> {}'
  1. 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

PedroRegisPOAR avatar Oct 17 '22 20:10 PedroRegisPOAR

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.

izelnakri avatar Sep 07 '23 02:09 izelnakri

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.

RobFisher avatar Oct 28 '23 23:10 RobFisher