Nixpkgs: How can I fix a corrupt manifest.nix?

Created on 4 Sep 2016  Â·  8Comments  Â·  Source: NixOS/nixpkgs

Issue description

I'm really not sure when or what happened, but suddenly my nix-env is unusable!

nix-env -q
error: syntax error, unexpected $end, at /nix/store/0722zxv7zijaljpkrx342rjyjf56k979-env-manifest.nix:1:1

I couldn't find anything to fix it! I tried:

sudo nix-store --verify --repair --check-contents
reading the Nix store...
checking path existence...
checking hashes...
path ‘/nix/store/0722zxv7zijaljpkrx342rjyjf56k979-env-manifest.nix’ was modified! expected hash ‘632ec35215ef2d5e7adc4698e87db5ee331c21633f5a4a351e10a7e249c6dd00’, got ‘77ac62e2629d8e45f624589c0c8bf99e24b3a722349bf1e79bc186008534e246’
error: cannot repair path ‘/nix/store/0722zxv7zijaljpkrx342rjyjf56k979-env-manifest.nix’

I tried to ask on IRC or search the chat logs but couldn't really find any help anywhere. Is anyone knowledgeable enough to fix this kind of issue!?

Most helpful comment

This was helpful in diagnosing my issue:

# any nix-env command, including the one ran by home-manager
error: syntax error, unexpected $end, at /nix/store/ry2b0qwvhdvdlmrrkawj9c6xiy9d6krs-env-manifest.nix:1:1

For home-manager users, see what is populating your profile:

nix-store -q --references ~/.nix-profile

look for home-manager-path, mine was:

/nix/store/ghj6r1157710pdw113rmfg1nj46f0f7s-home-manager-path

To remove the broken manifest:

$ sudo rm -r /nix/var/nix/profiles/per-user/user/profile-*-link

then I could run home-manager again (using the path from earlier):

/nix/store/ghj6r1157710pdw113rmfg1nj46f0f7s-home-manager-path/bin/home-manager switch

Everything works as intended now

All 8 comments

can you pastebin the contents of the manifest.nix?

It's empty.

On Sun, Sep 4, 2016, 04:16 cleverca22 [email protected] wrote:

can you pastebin the contents of the manifest.nix?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/NixOS/nixpkgs/issues/18279#issuecomment-244597232,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAdNji1fuSOGxU0klDbVKE4e5i3BbkoSks5qmqhrgaJpZM4J0emV
.

ah, then your only option is nix-env --rollback to switch to the previous version

It says no environment older than the current one exists... :(

To anyone this happens to (corrupt profile + garbage-collected other profiles), you can delete your corrupt profile. First you might want to remember what was installed:

nix-store -q --references ~/.nix-profile

Then wipe the corrupted profiles out:

sudo rm /nix/var/nix/profiles/per-user/yourname/profile
sudo rm /nix/var/nix/profiles/per-user/yourname/profile-*-link

Then start again from scratch.

Thanks to clever and vcunat for helping me!

This was helpful in diagnosing my issue:

# any nix-env command, including the one ran by home-manager
error: syntax error, unexpected $end, at /nix/store/ry2b0qwvhdvdlmrrkawj9c6xiy9d6krs-env-manifest.nix:1:1

For home-manager users, see what is populating your profile:

nix-store -q --references ~/.nix-profile

look for home-manager-path, mine was:

/nix/store/ghj6r1157710pdw113rmfg1nj46f0f7s-home-manager-path

To remove the broken manifest:

$ sudo rm -r /nix/var/nix/profiles/per-user/user/profile-*-link

then I could run home-manager again (using the path from earlier):

/nix/store/ghj6r1157710pdw113rmfg1nj46f0f7s-home-manager-path/bin/home-manager switch

Everything works as intended now

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/home-manager-stopped-working-on-my-non-nixos/6023/15

sudo rm -r /nix/var/nix/profiles/per-user/user/profile-*-link

Be careful of doing this if you use home-manager via configuration.nix; it will break your shell, and there is no home-manager-path/bin/home-manager.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

teto picture teto  Â·  3Comments

sid-kap picture sid-kap  Â·  3Comments

yawnt picture yawnt  Â·  3Comments

matthiasbeyer picture matthiasbeyer  Â·  3Comments

copumpkin picture copumpkin  Â·  3Comments