nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.38k stars 1.7k forks source link

bug: Unable to install home-manager (NixOS, standalone) (not found in $NIX_PATH) #3091

Open NielsGx opened 2 years ago

NielsGx commented 2 years ago

Is there an existing issue for this?

Issue description

Hello,

on a VPS, fresh install built with NixOS 21.11, I updated the channel to 22.05, rebuilt, then changed my configuration.nix to have a user then on this user, I add the channel for home-manager 22.05 and update it.

but when I do "nix-shell '' -A install" I get : error: file 'home-manager' was not found in the Nix search path (add it using $NIX_PATH or -I)

I tried to reboot the vps, nothing. Also I ssh into root and then do su myuser, instead of directly connecting to myuser@ip, but this shouldn't cause issue.

I tried to mess around with $NIX_PATH but then it would return a permission error :

mktemp: failed to create directory via template ‘/run/user/0/home-manager-build.XXXXXXXXXX’: Permission denied
Uh oh, the installation failed! Please create an issue at

    https://github.com/nix-community/home-manager/issues

if the error seems to be the fault of Home Manager.

It does work if I add the channel to the root and install with it, but afaik the manual says to use a standard user, at least for the standalone install

(no, I don't want to update home-manager through nixos-rebuild)

thanks a lot for this awesome tool

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
- host os: `Linux 5.15.53, NixOS, 22.05 (Quokka), 22.05.1627.4aceab3cadf`
-  multi-user?: `no`                            
- sandbox: `yes`
- version: `nix-env (Nix) 2.8.1`
- channels(niels): `"home-manager-22.05.tar.gz"`
- channels(root): `"nixos-22.05"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

(idk why it says no to multi-user, bc I have root and a user "niels")
stale[bot] commented 1 year ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

zeratax commented 1 year ago

i have the same issue on a brand new install of 22.11

Seems this happens due to: https://github.com/NixOS/nix/issues/2033#issuecomment-1366974053

stale[bot] commented 1 year ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

mupinnn commented 2 months ago

Hello, I'm experiencing similar issue but in my case when installing home-manager.

$ nix-shell '<home-manager>' -A install
The file /home/sandbox/.config/home-manager/home.nix already exists, leaving it unchanged...

Creating initial Home Manager generation...

mktemp: failed to create directory via template ‘/run/user/1000/home-manager-build.XXXXXXXXXX’: No such file or directory
error: getting status of '/run/user/1000': No such file or directory
Uh oh, the installation failed! Please create an issue at

    https://github.com/nix-community/home-manager/issues

if the error seems to be the fault of Home Manager.
rm: cannot remove '': No such file or directory

Some information I can provide about my Nix setup:

$ echo $NIX_PATH
/home/sandbox/.nix-defexpr/channels:nixpkgs=/home/sandbox/.nix-defexpr/channels/nixpkgs

$ nix --version
nix (Nix) 2.22.1

$ nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixpkgs https://nixos.org/channels/nixpkgs-unstable

System Information

- system: `"x86_64-linux"`
- host os: `Linux 5.15.146.1-microsoft-standard-WSL2, Ubuntu, 22.04.3 LTS (Jammy Jellyfish), nobuild`
- multi-user?: `no`
- sandbox: `yes`
- version: `nix-env (Nix) 2.22.1`
- nixpkgs: `/home/sandbox/.nix-defexpr/channels/nixpkgs`
Zocker1999NET commented 2 weeks ago

(EDIT to avoid doubled notification on rather stale issue)

I further found better solutions to the problem which seem better & more stable to me, see: https://github.com/nix-community/home-manager/pull/5008#issuecomment-2205795928

TL;DR: I now just add the home-manager channel using sudo. Then everything works as expected.


Old Comment

I don’t know why, but the doc change proposed in #4518 worked for me. The suggestion is to replace the nix-shell command from the doc with following:

nix-shell ~/.nix-defexpr/channels/home-manager -A install