Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

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

Open
dnsem wants to merge 2 commits into
DeterminateSystems:mainfrom
dnsem:patch-1
Open

Fixing "sudo: nix: command not found" when upgrading nix#6
dnsem wants to merge 2 commits into
DeterminateSystems:mainfrom
dnsem:patch-1

Conversation

@dnsem

@dnsem dnsem commented Dec 29, 2023

Copy link
Copy Markdown

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.
@dnsem
dnsem requested a review from lucperkins as a code owner December 29, 2023 18:55
@netlify

netlify Bot commented Dec 29, 2023

Copy link
Copy Markdown

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.

Comment thread pages/faq.mdx Outdated

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

@antoineco antoineco Jul 24, 2024

Copy link
Copy Markdown
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants