Terrible error messages from missing defexpr components #715

Open
opened 2025-03-05 06:36:30 +00:00 by git-north · 5 comments

Describe the bug

A clear and concise description of what the bug is.

I can't install packages via nix-env but can with nix-shell

Steps To Reproduce

  • run nix-env -iA nixpkgs.hello
  • error: attribute 'nixpkgs' in selection path 'nixpkgs.hello' not found inside path '', whose contents are: { \_combineChannels = [ ]; }

note that nix-shell -p hello works as expected

Expected behavior

A clear and concise description of what you expected to happen.

nix --version output

nix (Lix, like Nix) 2.92.0
System type: aarch64-linux
Additional system types:
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/north/.config/nix/nix.conf:/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix

Additional context

OS: Fedora Linux Asahi Remix 41 (Workstation Edition) aar4
Host: Apple MacBook Pro (16-inch, M2 Max, 2023)
Kernel: Linux 6.12.12-400.asahi.fc41.aarch64+16k

Add any other context about the problem here.

## Describe the bug > A clear and concise description of what the bug is. > I can't install packages via nix-env but can with nix-shell ## Steps To Reproduce - run `nix-env -iA nixpkgs.hello` - `error: attribute 'nixpkgs' in selection path 'nixpkgs.hello' not found inside path '', whose contents are: { \_combineChannels = [ ]; }` note that `nix-shell -p hello` works as expected ## Expected behavior A clear and concise description of what you expected to happen. ## `nix --version` output nix (Lix, like Nix) 2.92.0 System type: aarch64-linux Additional system types: Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/north/.config/nix/nix.conf:/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix ## Additional context OS: Fedora Linux Asahi Remix 41 (Workstation Edition) aar4 Host: Apple MacBook Pro (16-inch, M2 Max, 2023) Kernel: Linux 6.12.12-400.asahi.fc41.aarch64+16k Add any other context about the problem here.
Owner

This is definitely some nonsense with channels on the machine. It's unlikely to be a bug.

The symptom you're seeing is one caused by the channel 'nixos' in the nix "default expression" (if that sounds unhinged and confusing, I agree!) not being present. See "Default Nix expression" in the nix-env man page. This is a separate thing (which nearly nobody uses today) from the NIX_PATH resolution of stuff like <nixpkgs> that is used by nix-shell -p (which makes up a funny expression string).

This error message is certainly terrible, but I suspect it to be an improvement over what it used to be, because horrible errors from this command ring a bell.

Practically, the upshot of all this is you want to use nix-env -f '<nixpkgs>' -iA hello instead. Yes that's clunky. The more reasonable thing to use is flakey-profile, which completely eliminates most of these terrible commands.

This is definitely some nonsense with channels on the machine. It's unlikely to be a bug. The symptom you're seeing is one caused by the channel 'nixos' in the nix "default expression" (if that sounds unhinged and confusing, I agree!) not being present. See "Default Nix expression" in the nix-env man page. This is a separate thing (which nearly nobody uses today) from the NIX_PATH resolution of stuff like `<nixpkgs>` that is used by nix-shell -p (which makes up a funny expression string). This error message is certainly terrible, but I suspect it to be an improvement over what it used to be, because horrible errors from this command ring a bell. Practically, the upshot of all this is you want to use `nix-env -f '<nixpkgs>' -iA hello` instead. Yes that's clunky. The more reasonable thing to use is flakey-profile, which completely eliminates most of these terrible commands.
jade added this to the Error reporting project 2025-03-05 07:57:14 +00:00
jade changed title from I can't install packages via nix-env but can with nix-shell to Terrible error messages from missing defexpr components 2025-03-05 07:57:50 +00:00
Author

Oh wow, I had read some solutions and thought the "<nixpkgs>" was something I needed to change to something and the error message usually had something inside the ' '

After trying running the command I can confirm it works. Thank you so much

Oh wow, I had read some solutions and thought the "\<nixpkgs\>" was something I needed to change to _something_ and the error message usually had something inside the ' ' After trying running the command I can confirm it works. Thank you so much
Owner

You've actually run into an error message I rewrote myself this release. If there's any wording tweaks you can think of that would eliminate some confusion, those would be helpful.

(note that saying explicitly that it's defexpr resolution failure is definitely something that would help but that's a separate problem, the error message you saw is what you get for all -A missing attributes)

You've actually run into an error message I rewrote myself this release. If there's any wording tweaks you can think of that would eliminate some confusion, those would be helpful. (note that saying explicitly that it's defexpr resolution failure is definitely something that would help but that's a separate problem, the error message you saw is what you get for all -A missing attributes)

has the message been changed / improved since the issue was opened?

has the message been changed / improved since the issue was opened?
Owner

It did not change AFAIK.

It did not change AFAIK.
Sign in to join this conversation.
No milestone
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#715
No description provided.