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

nix-env --upgrade upgrades 'nix-2.3.10' to 'nix-2.3.10-x86_64-unknown-linux-musl' #118481

Closed
fishy opened this issue Apr 4, 2021 · 20 comments
Closed

Comments

@fishy
Copy link

fishy commented Apr 4, 2021

Describe the bug
I'm running nixpkgs on Debian testing on amd64. After doing nix-channel --update && nix-env --upgrade it upgraded 'nix-2.3.10' to 'nix-2.3.10-x86_64-unknown-linux-musl'.

After that upgrade is done, nix-env --upgrade --show-trace complains about attribute 'unsafeDiscardStringContext' missing:

$ nix-env --upgrade --show-trace
error: while evaluating anonymous function at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/top-level/impure.nix:15:1, called from undefined position:
while evaluating anonymous function at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/top-level/default.nix:19:1, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/top-level/impure.nix:83:1:
while evaluating anonymous function at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/stdenv/booter.nix:42:1, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/top-level/default.nix:122:10:
while evaluating 'dfold' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/stdenv/booter.nix:60:27, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/stdenv/booter.nix:136:4:
while evaluating 'go' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/stdenv/booter.nix:63:18, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/stdenv/booter.nix:72:13:
while evaluating 'imap1' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/lists.nix:116:14, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/stdenv/booter.nix:78:30:
while evaluating 'reverseList' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/lists.nix:393:17, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/stdenv/booter.nix:85:6:
while evaluating anonymous function at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/stdenv/default.nix:7:1, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/top-level/default.nix:118:12:
while evaluating 'elaborate' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/systems/default.nix:18:15, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/pkgs/top-level/default.nix:52:17:
while evaluating 'foldl' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/lists.nix:80:20, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/systems/default.nix:149:13:
while evaluating 'foldl'' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/lists.nix:82:16, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/lists.nix:86:8:
while evaluating the attribute 'parsed.abi.assertions' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/systems/default.nix:23:7:
while evaluating 'mkSystemFromString' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/systems/parse.nix:462:24, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/systems/default.nix:23:16:
while evaluating 'mkSkeletonFromList' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/systems/parse.nix:382:24, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/systems/parse.nix:462:49:
while evaluating 'splitString' at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/strings.nix:427:23, called from /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/systems/parse.nix:462:69:
attribute 'unsafeDiscardStringContext' missing, at /nix/store/jfqj09iqymfjy7l9z1lk5pbslww8nvl0-nixpkgs-21.05pre280331.54c1e44240d/nixpkgs/lib/strings.nix:429:13

To Reproduce
Steps to reproduce the behavior:

  1. ...
  2. ...
  3. ...

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

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Notify maintainers

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result. (NOTE: this is after I did nix-env --rollback)

  • system: "x86_64-linux"
  • host os: Linux 5.10.0-5-amd64, Debian GNU/Linux, noversion
  • multi-user?: no
  • sandbox: yes
  • version: nix-env (Nix) 2.3.10
  • channels(fishy): "nixpkgs-21.05pre280331.54c1e44240d"
  • nixpkgs: /home/fishy/.nix-defexpr/channels/nixpkgs

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@symphorien
Copy link
Member

nix-env --upgrade upgrading packages to different packages because their name looks like a version bump is well known and not really fixable. cc NixOS/nixos-homepage#672
My opinionated advice: use home-manager.

The fact that nix-2.3.10-x86_64-unknown-linux-musl is broken may be viewed as a separate issue deserving further investigation.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/errors-upgrading-installing-packages-on-non-nix-os/12328/1

@Ericson2314
Copy link
Member

Definitely agree there is a larger issue here, but why on earth is the cross target coming after the version?! That is a big somewhere.

@edolstra
Copy link
Member

The issue here is that the nixStatic package has a name nix-2.3.10-x86_64-unknown-linux-musl. This should be nix-static-2.3.10. The x86_64-unknown-linux-musl part is unhelpful to the user, and in any case features should be part of the pname, not the version.

sternenseemann added a commit to sternenseemann/nixpkgs that referenced this issue Apr 13, 2021
This is a workaround for the issue a lot of people have been having
where nix-env -u would think that nixStatic was a newer version of nix
and “upgrade” it to that package, breaking setups in the process.

Reference NixOS#118481
@domenkozar
Copy link
Member

This is fixed in #119317

Check https://status.nixos.org/ for when it will reach the nixpkgs-unstable channel!

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/errors-upgrading-installing-packages-on-non-nix-os/12328/2

@sternenseemann
Copy link
Member

@DianaOlympos
Copy link
Contributor

I would like to reopen this and pin it, as it may affect a lot of people and break their install.

The fix was never release to unstable because hydra is broken on unstable. And a lot of people run unstable locally on their dev env.

@domenkozar domenkozar reopened this Apr 15, 2021
@domenkozar domenkozar pinned this issue Apr 15, 2021
@domenkozar
Copy link
Member

I'm working on unblocking the channel.

@fabaff fabaff unpinned this issue Apr 15, 2021
@domenkozar
Copy link
Member

Done

@magthe
Copy link
Contributor

magthe commented Apr 16, 2021

Are there any instructions on how to fix it on a local install?

My nix-env --upgrade is still erroring out with

error: attribute 'unsafeDiscardStringContext' missing, at /nix/store/swryhbsm4cfwfr61g67gmladvigmpw68-nixpkgs-src/lib/strings.nix:730:5
(use '--show-trace' to show detailed location information)

@sternenseemann
Copy link
Member

I think people had success with using nix-env --rollback until they had a matching nix-daemon and nix version again.

@domenkozar
Copy link
Member

You need to update nixpkgs, if you're using channels that's nix-channel --update.

If you're using niv see https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html

@mgudemann
Copy link

Is there another solution apart from nix-env --rollback? I don't seem to have an old-enough generation available.

@domenkozar
Copy link
Member

Assuming you're on linux you could try:

$(nix-store -r /nix/store/frrxf7qwl5dixa9p591wx9029pv8v066-nix-2.3.10)/bin/nix-env --upgrade

@mgudemann
Copy link

@domenkozar thanks, this helped

@ghost
Copy link

ghost commented Feb 21, 2022

I am still encountering this issue with cross-compiled copies of nix. This is necessary for a repeatable bootstrap process on mips64el.

$ nix-build /nix/nixpkgs/ -A pkgsCross.mips64el-linux-gnuabi64.nixStatic
/nix/store/la7rzvxm7wgwqjqz397lrmbgbkwfl653-nix-static-mips64el-unknown-linux-musl-2.3.16

and then on the target machine:

$ /nix/store/la7rzvxm7wgwqjqz397lrmbgbkwfl653-nix-static-mips64el-unknown-linux-musl-2.3.16/bin/nix-env -iA hello
error: attribute 'unsafeDiscardStringContext' missing, at /nix/nixpkgs/lib/strings.nix:442:13
(use '--show-trace' to show detailed location information)

Can anybody enlighten me as to why the name of the directory in which the nix binary lives causes this error?

Is there a better way to use nixpkgs to cross-compile a standalone nix binary that will work on a system that does not yet have a /nix/store?

Also, nix expects to find certain non-executable resources (like the *.nix files in share/nix/) using a path which is hardwired at compile time. Is there a way to override that path at runtime, in order to explain to nix that it has been moved to a different location?

In the past I have used the Debian compiler/assembler/libraries to compile nix from source code, then used that to bootstrap. That's how I originally got mips64el working. However that process was tricky and not very repeatable, and as part of the upstreaming process I'd really like to have a documented bootstrap process that starts by using an amd64 machine to cross-compile the nix binary that will be used for bootstrapping. I'm having quite a difficult time doing that.

@ghost ghost mentioned this issue Feb 21, 2022
13 tasks
@sternenseemann
Copy link
Member

I think in your case the issue is rather that what nix assumes to be <nixpkgs> doesn't exist, namely the /nix/nixpkgs directory, which is not a special /nix path, but rather has been created by you manually on your other machine, I assume. Seems that maybe NIX_PATH leaked into the mips machine or the nix binary.

@ghost
Copy link

ghost commented Feb 22, 2022

I think in your case the issue is rather that what nix assumes to be <nixpkgs> doesn't exist, namely the /nix/nixpkgs directory,

Unfortunately that is not the issue; I copied (git clone) /nix/nixpkgs from the machine which built nix to the machine on which I'm running it.

$ ls /nix/nixpkgs/lib/strings.nix
/nix/nixpkgs/lib/strings.nix

The path /nix/nixpkgs is getting picked up from ~/.nix-defexpr/default.nix, which I deliberately set. I tried removing that file and indicating the location of nixpkgs manually, and got the same error:

$ /nix/store/la7rzvxm7wgwqjqz397lrmbgbkwfl653-nix-static-mips64el-unknown-linux-musl-2.3.16/bin/nix-env -f /nix/nixpkgs/ -iA hello
error: attribute 'unsafeDiscardStringContext' missing, at /nix/nixpkgs/lib/strings.nix:442:13
(use '--show-trace' to show detailed location information)

I'm quite sure something is wonky with the binary that is being built, rather than the environment in which it is running.

@ghost
Copy link

ghost commented Feb 23, 2022

I was able to work around this by simply using nix 2.4 instead, in case that helps anybody else.

nix-build -A pkgsCross.mips64el-linux-gnuabi64.pkgsStatic.nix_2_4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants