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

Fixing "sudo: nix: command not found" when upgrading nix #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dnsem
Copy link

@dnsem dnsem commented Dec 29, 2023

I installed nix 2.15 on Ubuntu 22.04 using DeterminateSystems installer. When trying to upgrade nix I got "sudo: nix: command not found". This workaround allowed me to successfully upgrade nix - it is using environment of normal user when running command as root user.

I installed nix 2.15 on Ubuntu 22.04 using DeterminateSystems installer. When trying to upgrade nix I got "sudo: nix: command not found". This workaround allowed me to successfully upgrade nix - it is using environment of normal user when running command as root user.
Copy link

netlify bot commented Dec 29, 2023

Deploy Preview for flakehub-docs ready!

Name Link
🔨 Latest commit fc668de
🔍 Latest deploy log https://app.netlify.com/sites/flakehub-docs/deploys/66a140640501920008b5cfe8
😎 Deploy Preview https://deploy-preview-6--flakehub-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

pages/faq.mdx Outdated
@@ -11,7 +11,7 @@ We at [Determinate Systems][detsys] recommend using Nix **2.18.1** or newer in c
You can upgrade Nix using the [`upgrade-nix`][upgrade-nix] command. To upgrade to Nix 2.18.1:

```shell
sudo nix upgrade-nix \
sudo -E env "PATH=$PATH" nix upgrade-nix \
Copy link
Contributor

@antoineco antoineco Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. -E preserves the entire environment, so there is no need to add env ... to the command.

Besides, it would be safer to preserve just the PATH variable instead of the entire environment, as a good practice:

Suggested change
sudo -E env "PATH=$PATH" nix upgrade-nix \
sudo --preserve-env=PATH nix upgrade-nix \

Removed '-E' flag as running with modified PATH is enough
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants