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

After removing 0.8.0 and installing 0.9.0, many nix profile commands fail #477

Open
mitchmindtree opened this issue May 24, 2023 · 13 comments
Assignees
Labels
Has workaround The issue has a workaround. Linux

Comments

@mitchmindtree
Copy link

mitchmindtree commented May 24, 2023

I'm testing the Nix installation flow (with v0.9.0) using nix-installer for a fresh Ubuntu LTS user in a VM. Here's the command used to install:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v0.9.0 | sh -s -- install

After installation succeeds and a new terminal is opened, commands like nix shell and nix run appear to work fine, however many nix profile commands fail. E.g.

$ nix profile install nixpkgs#hello
error: opening directory '/nix/var/nix/profiles/per-user/mindtree': No such file or directory

Similarly, nix profile upgrade, nix profile rollback, nix profile history all give the same error.

When inspecting the /nix/var/nix/profiles/per-user/ directory, it appears that the nix-installer only creates the root subdirectory, but no directory for the current user.

Could it be the case that nix-installer does try to create this directory for the current user, but due to the required escalated privileges during installation, this user is always root? Perhaps the fix is to add a subdirectory not only for root, but for $USER as well?

I tested this remedy by running the following:

$ sudo mkdir /nix/var/nix/profiles/per-user/mindtree
$ sudo chown mindtree /nix/var/nix/profiles/per-user/mindtree

where mindtree is the current user.

Following this, the nix profile commands appeared to work without issue.

mitchmindtree added a commit to FuelLabs/fuel.nix that referenced this issue May 24, 2023
This adds a new `book/` directory containing an mdbook for `fuel.nix`.

The new book will replace the README with a much friendlier "Quick
Start", and a more searchablei and detailed guide covering how to
install Nix, use fuel packages, and how to contribute to fuel.nix
itself.

TODO
----

- [x] Add a new "Quick Start" section with the new two-step installation approach.
- [x] Merge existing README content into subchapters.
- [x] Add a more detailed "Nix Setup" chapter for those interested in more details.
- [x] Add a section on `nix profile install` for persistent installation to the "Packages" chapter.
- [ ] Add a new "Contributing" section with details on how to add/update packages and milestones.
- [ ] Update the README to simply point to the book and Quick Start.
- [ ] Add a CI step to publish the book.
- [ ] Open an issue to remove the **NOTE:** under the `nix profile install` section required due to DeterminateSystems/nix-installer#477.
mitchmindtree added a commit to FuelLabs/fuel.nix that referenced this issue May 24, 2023
This adds a new `book/` directory containing an mdbook for `fuel.nix`.

The new book will replace the README with a much friendlier "Quick
Start", and a more searchablei and detailed guide covering how to
install Nix, use fuel packages, and how to contribute to fuel.nix
itself.

TODO
----

- [x] Add a new "Quick Start" section with the new two-step installation approach.
- [x] Merge existing README content into subchapters.
- [x] Add a more detailed "Nix Setup" chapter for those interested in more details.
- [x] Add a section on `nix profile install` for persistent installation to the "Packages" chapter.
- [ ] Add a new "Contributing" section with details on how to add/update packages and milestones.
- [ ] Update the README to simply point to the book and Quick Start.
- [ ] Add a CI step to publish the book.
- [ ] Open an issue to remove the **NOTE:** under the `nix profile install` section required due to DeterminateSystems/nix-installer#477.
@Hoverbear
Copy link
Contributor

Hmmm that's quite odd, I wonder how our systems differ...

image

I'm going to try to add some better testing around this and see if I can root out the issue.

@Hoverbear Hoverbear self-assigned this May 24, 2023
@Hoverbear
Copy link
Contributor

In theory Nix 2.15 should be making your Nix profile in $HOME/.nix-profile, not /nix/var/nix/profiles/per-user/...

@msfjarvis
Copy link

I also ran into this problem yesterday, happy to help with any tests I can run on my end to help debug this.

@Hoverbear
Copy link
Contributor

Hoverbear commented May 24, 2023

I'm going to do some more experimenting since we now have multiple reports! Thanks so much.

Could you let me know if it was also on Ubuntu LTS?

@msfjarvis
Copy link

I'm going to do some more experimenting since we now have multiple reports! Thanks so much.

Could you let me know if it was also on Ubuntu LTS?

This was on Linux Mint 21.1, which is using the Ubuntu 22.04 LTS package base.

@mitchmindtree
Copy link
Author

In theory Nix 2.15 should be making your Nix profile in $HOME/.nix-profile, not /nix/var/nix/profiles/per-user/...

Interesting, I noticed that .nix-profile was there, thought it was just a symlink to /nix/var/nix/profiles/per-user/$USER which didn't exist.

I ran /nix/nix-installer uninstall and noticed that the .nix-profile file still remained, so this time I manually deleted it to see if it would get recreated by the installer.

This time, I noticed that the installer didn't add any .nix-profile file itself.

I tried running nix profile install nixpkgs#hello, and this time it worked!

I checked $HOME/.nix-profile and it looks like Nix has created the file, though this time with the following symlink: .nix-profile -> /home/mindtree/.local/state/nix/profiles/profile.

I've been re-using this VM to /nix/nix-installer uninstall and then re-install again from scratch over and over. The current installer I'm using is v0.9.0, whereas I've previously run v0.8.0 on this same VM. Is it possible that a previous version of the installer used an older version of Nix that behaved different w.r.t. creating $HOME/.nix-profile? 🤔

@msfjarvis
Copy link

Can confirm the same observation, uninstalling with v0.8.0, deleting $HOME/.nix-profile and reinstalling with v0.9.0 does indeed work correctly. In previous tests I had skipped the .nix-profile deletion and encountered the broken behaviour.

@Hoverbear
Copy link
Contributor

Yup I can confirm this:

ana@ephemeral-ubuntu:~$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v0.8.0 | sh -s -- install
info: downloading installer https://install.determinate.systems/nix/tag/v0.8.0/nix-installer-x86_64-linux
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
Nix install plan (v0.8.0)
Planner: linux (with default settings)

Planned actions:
* Create directory `/nix`
* Fetch `https://releases.nixos.org/nix/nix-2.13.3/nix-2.13.3-x86_64-linux.tar.xz` to `/nix/temp-install-dir`
* Create build users (UID 30000-30032) and group (GID 30000)
* Create a directory tree in `/nix`
* Move the downloaded Nix into `/nix`
* Setup the default Nix profile
* Place the Nix configuration in `/etc/nix/nix.conf`
* Configure the shell profiles
* Configure Nix daemon related settings with systemd
* Remove directory `/nix/temp-install-dir`


Proceed? ([Y]es/[n]o/[e]xplain): y
 INFO Step: Create directory `/nix`
 INFO Step: Provision Nix
 INFO Step: Configure Nix
 INFO Step: Configure Nix daemon related settings with systemd
 INFO Step: Remove directory `/nix/temp-install-dir`
Nix was installed successfully!
To get started using Nix, open a new shell or run `. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh`

ana@ephemeral-ubuntu:~$ ls -lah .nix-profile
ls: cannot access '.nix-profile': No such file or directory
ana@ephemeral-ubuntu:~$ . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
ana@ephemeral-ubuntu:~$ ls -lah .nix-profile
ls: cannot access '.nix-profile': No such file or directory
ana@ephemeral-ubuntu:~$ nix run nixpkgs#hello
Hello, world!
ana@ephemeral-ubuntu:~$ ls -lah .nix-profile
ls: cannot access '.nix-profile': No such file or directory
ana@ephemeral-ubuntu:~$ nix profile install nixpkgs#hello
ana@ephemeral-ubuntu:~$ ls -lah .nix-profile
lrwxrwxrwx 1 ana ana 42 May 25 10:23 .nix-profile -> /nix/var/nix/profiles/per-user/ana/profile
ana@ephemeral-ubuntu:~$ /nix/nix-installer uninstall
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
Nix uninstall plan (v0.8.0)

Planner: linux (with default settings)

Planned actions:
* Unconfigure Nix daemon related settings with systemd
* Unconfigure the shell profiles
* Remove the Nix configuration in `/etc/nix/nix.conf`
* Unset the default Nix profile
* Remove the directory tree in `/nix`
* Remove Nix users and group
* Remove the directory `/nix`


Proceed? ([Y]es/[n]o/[e]xplain): y
 INFO Revert: Remove directory `/nix/temp-install-dir`
 INFO Revert: Configure Nix daemon related settings with systemd
 INFO Revert: Configure Nix
 INFO Revert: Provision Nix
 INFO Revert: Create directory `/nix`
Nix was uninstalled successfully!

ana@ephemeral-ubuntu:~$ ls -lah .nix-profile
lrwxrwxrwx 1 ana ana 42 May 25 10:23 .nix-profile -> /nix/var/nix/profiles/per-user/ana/profile
ana@ephemeral-ubuntu:~$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v0.9.0 | sh -s -- install
info: downloading installer https://install.determinate.systems/nix/tag/v0.9.0/nix-installer-x86_64-linux
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
Nix install plan (v0.9.0)
Planner: linux (with default settings)

Planned actions:
* Create directory `/nix`
* Fetch `https://releases.nixos.org/nix/nix-2.15.0/nix-2.15.0-x86_64-linux.tar.xz` to `/nix/temp-install-dir`
* Create group `nixbld` (GID 30000)
* Create a directory tree in `/nix`
* Move the downloaded Nix into `/nix`
* Setup the default Nix profile
* Place the Nix configuration in `/etc/nix/nix.conf`
* Configure the shell profiles
* Configure Nix daemon related settings with systemd
* Remove directory `/nix/temp-install-dir`


Proceed? ([Y]es/[n]o/[e]xplain): y
 INFO Step: Create directory `/nix`
 INFO Step: Provision Nix
 INFO Step: Configure Nix
 INFO Step: Configure Nix daemon related settings with systemd
 INFO Step: Remove directory `/nix/temp-install-dir`
Nix was installed successfully!
To get started using Nix, open a new shell or run `. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh`

ana@ephemeral-ubuntu:~$ nix profile install nixpkgs#hello
error: opening directory '/nix/var/nix/profiles/per-user/ana': No such file or directory
ana@ephemeral-ubuntu:~$ ls -lah .nix-profile
lrwxrwxrwx 1 ana ana 42 May 25 10:23 .nix-profile -> /nix/var/nix/profiles/per-user/ana/profile

Now to decide how to deal with it... Short of scanning all users home directories for that file and removing it, I'm not sure how we'd repair it...

@Hoverbear Hoverbear added the Has workaround The issue has a workaround. label May 25, 2023
@Hoverbear Hoverbear changed the title After fresh installation, many nix profile commands fail After removing 0.8.0 and installing 0.9.0, many nix profile commands fail May 26, 2023
@Hoverbear Hoverbear added this to the 0.9.2 milestone May 26, 2023
mitchmindtree added a commit to FuelLabs/fuel.nix that referenced this issue May 30, 2023
This adds a new `book/` directory containing an mdbook for `fuel.nix`.

The new book will replace the README with a much friendlier "Quick
Start", and a more searchablei and detailed guide covering how to
install Nix, use fuel packages, and how to contribute to fuel.nix
itself.

TODO
----

- [x] Add a new "Quick Start" section with the new two-step installation approach.
- [x] Merge existing README content into subchapters.
- [x] Add a more detailed "Nix Setup" chapter for those interested in more details.
- [x] Add a section on `nix profile install` for persistent installation to the "Packages" chapter.
- [ ] Add a new "Contributing" section with details on how to add/update packages and milestones.
- [ ] Update the README to simply point to the book and Quick Start.
- [ ] Add a CI step to publish the book.
- [ ] Open an issue to remove the **NOTE:** under the `nix profile install` section required due to DeterminateSystems/nix-installer#477.
mitchmindtree added a commit to FuelLabs/fuel.nix that referenced this issue Jun 1, 2023
This adds a new `book/` directory containing an mdbook for `fuel.nix`.

The new book will replace the README with a much friendlier "Quick
Start", and a more searchablei and detailed guide covering how to
install Nix, use fuel packages, and how to contribute to fuel.nix
itself.

TODO
----

- [x] Add a new "Quick Start" section with the new two-step installation approach.
- [x] Merge existing README content into subchapters.
- [x] Add a more detailed "Nix Setup" chapter for those interested in more details.
- [x] Add a section on `nix profile install` for persistent installation to the "Packages" chapter.
- [ ] Add a new "Contributing" section with details on how to add/update packages and milestones.
- [ ] Update the README to simply point to the book and Quick Start.
- [ ] Add a CI step to publish the book.
- [ ] Open an issue to remove the **NOTE:** under the `nix profile install` section required due to DeterminateSystems/nix-installer#477.
mitchmindtree added a commit to FuelLabs/fuel.nix that referenced this issue Jun 2, 2023
This adds a new `book/` directory containing an mdbook for `fuel.nix`.

The new book will replace the README with a much friendlier "Quick
Start", and a more searchablei and detailed guide covering how to
install Nix, use fuel packages, and how to contribute to fuel.nix
itself.

TODO
----

- [x] Add a new "Quick Start" section with the new two-step installation approach.
- [x] Merge existing README content into subchapters.
- [x] Add a more detailed "Nix Setup" chapter for those interested in more details.
- [x] Add a section on `nix profile install` for persistent installation to the "Packages" chapter.
- [ ] Add a new "Contributing" section with details on how to add/update packages and milestones.
- [ ] Update the README to simply point to the book and Quick Start.
- [ ] Add a CI step to publish the book.
- [ ] Open an issue to remove the **NOTE:** under the `nix profile install` section required due to DeterminateSystems/nix-installer#477.
mitchmindtree added a commit to FuelLabs/fuel.nix that referenced this issue Jun 2, 2023
This adds a new `book/` directory containing an mdbook for `fuel.nix`.

The new book will replace the README with a much friendlier "Quick
Start", and a more searchable and detailed guide covering how to install
Nix, use fuel packages, and how to contribute to fuel.nix itself.

Closes #59.

TODO
----

- [x] Add a new "Quick Start" section with the new two-step installation
approach.
- [x] Merge existing README content into subchapters.
- [x] Add a more detailed "Nix Setup" chapter for those interested in
more details.
- [x] Add a section on `nix profile install` for persistent installation
to the "Packages" chapter.
- [x] Add a new "Contributing" section with details on how to add/update
packages and milestones.
- [x] Update the README to simply point to the book and Quick Start.
- [x] Add a CI step to publish the book.
- ~Open an issue to remove the **NOTE:** under the `nix profile install`
section required due to DeterminateSystems/nix-installer#477.~ It seems
this issue only occurs if a previous Nix installation existed but was
not cleaned up properly. The `note` has been updated.
@Hoverbear
Copy link
Contributor

After chatting with @edolstra I think we might try to improve the error which nix offers here.

@hybras
Copy link

hybras commented Aug 28, 2023

I've also been running into this the last few months, the (very easy) workaround worked. Iirc a macos upgrade broke my nix install, so I reinstalled

@shriv
Copy link

shriv commented Feb 18, 2024

Hiya, I'm facing this issue but unsure how to fix. Any suggestions? Thanks!

> nix profile install nixpkgs#nix-direnv
error: opening directory '/nix/var/nix/profiles/per-user/ravis': No such file or directory

@shriv
Copy link

shriv commented Feb 19, 2024

I figured it out. I just needed to remove the old .nix-profile and re-run the profile daemon. The nix profile installs now run without errors at least..!

> rm .nix-profile
> . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

@sambacha
Copy link

I figured it out. I just needed to remove the old .nix-profile and re-run the profile daemon. The nix profile installs now run without errors at least..!

> rm .nix-profile
> . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

Can confirm that this resolved the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has workaround The issue has a workaround. Linux
Projects
None yet
Development

No branches or pull requests

6 participants