nix icon indicating copy to clipboard operation
nix copied to clipboard

typing "nix-env -i" should not try to install every single package

Open kevinburke opened this issue 10 years ago • 13 comments

I did this by accident and was alarmed to find 5000 packages starting to download onto my machine, which seems wasteful from a bandwidth and a disk space perspective, given that few people would actually want every package on their machine.

A better approach would be to exit with the error message "Please specify a package to install", optionally with instructions on how to download everything.

kevinburke avatar Jul 26 '14 18:07 kevinburke

I've come to like this feature; nix-env -q queries everything, nix-env -u updates everything, and so logically nix-env -i should install everything.

On the other hand, it would be nice to have a "5000 packages will be installed, 10 GB will be downloaded, ... Continue? [y/n]" prompt like apt-get, as currently that information scrolls offscreen very quickly.

Mathnerd314 avatar Jul 27 '14 00:07 Mathnerd314

That would also be acceptable..

kevinburke avatar Jul 27 '14 03:07 kevinburke

I recently hit an issue due to this behavior. In #3227 I was calling nix-env -i $(nix-build something), in the event of a build failure, nix-env will nicely start to install everything. In most cases it just leads to a difficult to understand error, in some cases it uses a lot of space / bandwidth.

guibou avatar Dec 12 '19 11:12 guibou

I marked this as stale due to inactivity. → More info

stale[bot] avatar Feb 15 '21 23:02 stale[bot]

I think this should still be addressed!

alarsyo avatar Apr 11 '21 17:04 alarsyo

Copying subscribers from duplicate #1334: @copumpkin @Diti @ericsagnes @shlevy @vcunat

nh2 avatar May 18 '21 16:05 nh2

I marked this as stale due to inactivity. → More info

stale[bot] avatar Nov 16 '21 11:11 stale[bot]

This should still be addressed.

Diti avatar Nov 16 '21 11:11 Diti

Just got into this situation by following the instructions in the official docs available after installation.

6.2 Ad-Hoc Package Management

Packages come from the NixOS channel. You typically upgrade a package by updating to the latest version of the NixOS channel:

nix-channel --update nixos and then running nix-env -i again

I run update and then nix-env -i.

RoboBurned avatar Jan 19 '22 21:01 RoboBurned

Not stale.

Diti avatar Mar 13 '23 01:03 Diti

just made this mistake, surprised it hasnt been fixed in so long

echoptic avatar Aug 28 '23 23:08 echoptic

Here's the culprit: https://github.com/NixOS/nix/blob/b7e712f9fd3b35e7b75180fcfbe90dce6c9b06a4/src/nix-env/nix-env.cc#L325-L327

If no positional parameter is specified, args stays empty. Unfortunately, simply replacing that by a throw Error("No package specified") would not do the trick, as installing/querying things from specified sources would have to be taken into account. For example you can do nix-env -if ./stuff.nix to install all derivations from that file.

@RoboBurned in the meantime the issue with the manual suggesting to use nix-env -i to beginners will be addressed by implementing https://github.com/NixOS/nix/issues/7769.

fricklerhandwerk avatar Sep 28 '23 23:09 fricklerhandwerk

Almost 10 years later, and I did this mistake as well.

introspectionism avatar Feb 18 '24 20:02 introspectionism