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

warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring #40165

Closed
wizzup opened this issue May 8, 2018 · 18 comments

Comments

@wizzup
Copy link
Contributor

wizzup commented May 8, 2018

Issue description

Recently I've got following warning when running nixos-rebuild. I can't remember change any configuration.

warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring

Despite it is just a warning, not a critical one, I still want to know how to fix it properly.

Steps to reproduce

[wizzup@ ~]$ sudo nixos-rebuild switch
[sudo] password for wizzup:
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building Nix...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building the system configuration...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
setting up tmpfiles

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.39, NixOS, 18.09pre139319.1d9330d63a5 (Jellyfish)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.0.2
  • channels(root): "nixos-18.09pre139319.1d9330d63a5"
  • channels(wizzup): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
@edolstra
Copy link
Member

edolstra commented May 8, 2018

Does this also happen if you use sudo -i?

@lprndn
Copy link
Contributor

lprndn commented May 8, 2018

Hello,
Having the same problem for the past few days on nixos-unstable. I thought I forgot to do something as it is a new install.
I can confirm that the warning doesn't appear with sudo -i

@wizzup
Copy link
Contributor Author

wizzup commented May 8, 2018

not with sudo -i

[wizzup@ ~]$ sudo -i
[sudo] password for wizzup: 

[root@earth:~]# nixos-rebuild switch
building Nix...
building the system configuration...
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
setting up tmpfiles

[root@earth:~]# logout
[wizzup@ ~]$ sudo nixos-rebuild switch 
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building Nix...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building the system configuration...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
setting up tmpfiles
[wizzup@ ~]$ 

@vcunat
Copy link
Member

vcunat commented May 8, 2018

I expect the change is a consequence of #38351.

@edolstra
Copy link
Member

edolstra commented May 8, 2018

This appears to be caused by 8ab8d9c. We shouldn't have variable references in nix.nixPath because they don't get expanded in all contexts. (Indeed it's not clear whether that's desirable at all.) Ping @grahamc.

@dezgeg
Copy link
Contributor

dezgeg commented May 8, 2018

I guess there's also a more general problem that even if the variable is expanded, a warning is printed if the user doesn't have any channels, e.g. a simple nix-build -A hello gives me:

warning: Nix search path entry '/home/tmtynkky/.nix-defexpr/channels' does not exist, ignoring

@dezgeg
Copy link
Contributor

dezgeg commented May 8, 2018

Maybe we could:

  1. Enhance Nix to expand the tilde in channel expressions, so adding "~/.nix-defexpr/channels" to nix.nixPath would work and fix the original reporter's problem.
  2. Change the profile script to create a ~/.nix-defexpr/channels -> /var/empty symlink when the user doesn't have any channels, to get rid of the warning I posted.

@cumber
Copy link
Contributor

cumber commented Jun 12, 2018

I ran nix-channel --update (even though I have no channels; I just use the main nixos channel under root). It created a symlink at ~/.nix-defexpr/channels (pointing to /nix/var/nix/profile/per-user/$USER/channels, where there is symlink to a blank manifest.nix).

This was enough to stop the warning, and seems to be the "proper" setup for a user subscribed to no channels.

My system is several nixos releases old, so having to manually do something to adjust my home dir is fine, though it took me a while to think of trying that. Perhaps the warning message could suggest this fix if the missing NIX_PATH entry being ignored is ~/.nix-defexpr/channels?

@magnetophon
Copy link
Member

@cumber
I also have no channels.
When I run nix-channel --update as a user, I get:

unpacking channels...
created 0 symlinks in user environment

When I run it as root,I get:

unpacking channels...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring

The warning remains, also at the next rebuild.

@cumber
Copy link
Contributor

cumber commented Jul 10, 2018

@magnetophon I should probably have been clearer, I was referring to dezgeg's report that you get a warning printed even in contexts where the variable is expanded, e.g.:

warning: Nix search path entry '/home/cumber/.nix-defexpr/channels' does not exist, ignoring

The behaviour I'm seeing is that nix commands run as my own user (nix run, nix-env, etc) print a warning with my home folder spelled out in full, but running sudo nixos-rebuild prints a warning with the text $HOME in the path.

The cause of the former seems to be an "improper" state for no subscribed channels (nonexistent channels symlink instead of a symlink to a folder with a blank manifest), and I found that can be resolved by the step I mentioned. I still get the $HOME warnings on nixos-rebuild, but not warnings on every nix command now.

@jb55
Copy link
Contributor

jb55 commented Jul 30, 2018

mkdir -p ~/.nix-defexpr/channels workaround to silence the annoying message on every command

@cumber
Copy link
Contributor

cumber commented Jul 30, 2018

@jb55 That works, but I went with letting nix-channel --update to avoid potential problems down the road. It seems nix wants the user channels folder to be a symlink to stuff it manages under /nix/var/nix/ (or equivalent on non-Nixos setups). If I later do want a user-level channel subscription, the nix command to set that up is probably expecting to do some work under /nix/var/nix/ and then overwrite a symlink, which could fail if the symlink is actually a real folder.

dtzWill added a commit to dtzWill/nixpkgs that referenced this issue Aug 20, 2018
environment.sessionVariables cannot refer to the values of env vars,
and as a result this has caused problems in a variety of scenarios.

One use for these is that they're injected into /etc/profile,
elewhere these are used to populate an 'envfile' for pam
(`pam 5 pam_env.conf`) which mentions use of HOME being
potentially problematic.

Anyway if the goal is to make things easier for users,
simply do the NIX_PATH modification as extraInit.

This fixes the annoying problems generated by the current approach
(NixOS#40165 and others) while hopefully serving the original goal.

One way to check if things are borked is to try:

$ sudo env | grep NIX_PATH

Which (before this change) prints NIX_PATH variable with
an unexpanded $HOME in the value.

-------

This does mean the following won't contain user channels for 'will':
$ sudo -u will nix-instantiate --eval -E builtins.nixPath

However AFAICT currently they won't be present either,
due to unescaped $HOME.  Unsure if similar situation for other users
of sessionVariables (not sudo) work with current situation
(if they exist they will regress after this change AFAIK).
dtzWill added a commit to dtzWill/nixpkgs that referenced this issue Aug 23, 2018
environment.sessionVariables cannot refer to the values of env vars,
and as a result this has caused problems in a variety of scenarios.

One use for these is that they're injected into /etc/profile,
elewhere these are used to populate an 'envfile' for pam
(`pam 5 pam_env.conf`) which mentions use of HOME being
potentially problematic.

Anyway if the goal is to make things easier for users,
simply do the NIX_PATH modification as extraInit.

This fixes the annoying problems generated by the current approach
(NixOS#40165 and others) while hopefully serving the original goal.

One way to check if things are borked is to try:

$ sudo env | grep NIX_PATH

Which (before this change) prints NIX_PATH variable with
an unexpanded $HOME in the value.

-------

This does mean the following won't contain user channels for 'will':
$ sudo -u will nix-instantiate --eval -E builtins.nixPath

However AFAICT currently they won't be present either,
due to unescaped $HOME.  Unsure if similar situation for other users
of sessionVariables (not sudo) work with current situation
(if they exist they will regress after this change AFAIK).

(cherry picked from commit fa67ca1)
@alexeymuranov
Copy link
Contributor

I've got these warnings after upgrading NixOS to 18.09.

@gavinfernandes2012
Copy link

I've got this on unstable as well : 19.03pre151837.ca2ba44cab4 (Koi)
Neither

mkdir -p ~/.nix-defexpr/channels

nor

ln -s /var/empty ~/.nix-defexpr/channels

silences it.

@grahamc grahamc added this to the 18.09 milestone Sep 16, 2018
dtzWill added a commit to dtzWill/nixpkgs that referenced this issue Sep 24, 2018
environment.sessionVariables cannot refer to the values of env vars,
and as a result this has caused problems in a variety of scenarios.

One use for these is that they're injected into /etc/profile,
elewhere these are used to populate an 'envfile' for pam
(`pam 5 pam_env.conf`) which mentions use of HOME being
potentially problematic.

Anyway if the goal is to make things easier for users,
simply do the NIX_PATH modification as extraInit.

This fixes the annoying problems generated by the current approach
(NixOS#40165 and others) while hopefully serving the original goal.

One way to check if things are borked is to try:

$ sudo env | grep NIX_PATH

Which (before this change) prints NIX_PATH variable with
an unexpanded $HOME in the value.

-------

This does mean the following won't contain user channels for 'will':
$ sudo -u will nix-instantiate --eval -E builtins.nixPath

However AFAICT currently they won't be present either,
due to unescaped $HOME.  Unsure if similar situation for other users
of sessionVariables (not sudo) work with current situation
(if they exist they will regress after this change AFAIK).

(cherry picked from commit fa67ca1)
matthewbauer pushed a commit that referenced this issue Sep 24, 2018
environment.sessionVariables cannot refer to the values of env vars,
and as a result this has caused problems in a variety of scenarios.

One use for these is that they're injected into /etc/profile,
elewhere these are used to populate an 'envfile' for pam
(`pam 5 pam_env.conf`) which mentions use of HOME being
potentially problematic.

Anyway if the goal is to make things easier for users,
simply do the NIX_PATH modification as extraInit.

This fixes the annoying problems generated by the current approach
(#40165 and others) while hopefully serving the original goal.

One way to check if things are borked is to try:

$ sudo env | grep NIX_PATH

Which (before this change) prints NIX_PATH variable with
an unexpanded $HOME in the value.

-------

This does mean the following won't contain user channels for 'will':
$ sudo -u will nix-instantiate --eval -E builtins.nixPath

However AFAICT currently they won't be present either,
due to unescaped $HOME.  Unsure if similar situation for other users
of sessionVariables (not sudo) work with current situation
(if they exist they will regress after this change AFAIK).

(cherry picked from commit fa67ca1)
@matthewbauer
Copy link
Member

Fix applied in ee582a3.

grahamc pushed a commit that referenced this issue Sep 30, 2018
environment.sessionVariables cannot refer to the values of env vars,
and as a result this has caused problems in a variety of scenarios.

One use for these is that they're injected into /etc/profile,
elewhere these are used to populate an 'envfile' for pam
(`pam 5 pam_env.conf`) which mentions use of HOME being
potentially problematic.

Anyway if the goal is to make things easier for users,
simply do the NIX_PATH modification as extraInit.

This fixes the annoying problems generated by the current approach
(#40165 and others) while hopefully serving the original goal.

One way to check if things are borked is to try:

$ sudo env | grep NIX_PATH

Which (before this change) prints NIX_PATH variable with
an unexpanded $HOME in the value.

-------

This does mean the following won't contain user channels for 'will':
$ sudo -u will nix-instantiate --eval -E builtins.nixPath

However AFAICT currently they won't be present either,
due to unescaped $HOME.  Unsure if similar situation for other users
of sessionVariables (not sudo) work with current situation
(if they exist they will regress after this change AFAIK).
@vcunat
Copy link
Member

vcunat commented Oct 4, 2018

Seems fixed now on 18.09 and master. And 18.03 shouldn't suffer from this IIRC.

@vcunat vcunat closed this as completed Oct 4, 2018
@toraritte
Copy link
Contributor

toraritte commented May 3, 2019

Got this warning on fresh NixOS 19.03 install, without any configs touched. @cumber 's comment (i.e., nix-channel --update) solved it.

@nixos-discourse
Copy link

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

https://discourse.nixosstag.fcio.net/t/warning-nix-search-path-entry-nix-var-nix-profiles-per-user-root-channels-does-not-exist-ignoring/5170/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests