Updating packages doesn't work

Hi,
I have installed nix-env on my macOS and i am trying to update my packages and specific yt-dlp package using nix-env -u command but it doesn’t update, it doesn’t even gives an error or any message at all.

Latest version on NIX website is 2023.02.17
https://search.nixos.org/packages?channel=22.11&show=yt-dlp&from=0&size=50&sort=relevance&type=packages&query=yt-dlp

My current version is:
2023.01.06

What am i doing wrong?

Have you updated the channels before updating packages? Also https://stop-using-nix-env.privatevoid.net/

What command will update the channels?
And i will check your link TNX

As you used nix-env you are probably using channels.

Then the command would be (sudo)nix-channel --update. Depending on whether you want to update your users or roots channels.

It might be that you haven’t set up any channels so far, but are “locked” on an initial expression provided by the installer which isn’t updateable.

In this case you need to first set up a channel to use.

This is what i am receiving:

warning: $HOME ('/Users/username') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
unpacking channels...
warning: $HOME ('/Users/username') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')

And what channel i should add to just to being able to install and update from NIX library?

That output looks like you were using sudo.

Depending on the exact setup, this might have worked to update what nix-env is using.

1 Like

Thanks! using sudo solved my problem!

What problem exactly?

As nix can be used as a user space package manager, there is rarely need for sudo actually.

I mean i have tried before nix-channel --update and then nix-env -u and nothing changed. Only after using sudo nix-channel --update i was able to update packages using nix-env -u.

I have to be honest though, the fact that nix channel complained about HOME being incorrect makes me wonder what is going on.

At the same time, I never liked MacOS default for sudo to keep (most of) the environment…

It causes a lot of trouble in general that could have been avoided…

A single unthought sudo can make half of your users HOME root owned…

1 Like