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

Installation fails with empty error message #527

Closed
mwilson-ns opened this issue May 4, 2015 · 10 comments
Closed

Installation fails with empty error message #527

mwilson-ns opened this issue May 4, 2015 · 10 comments
Assignees

Comments

@mwilson-ns
Copy link

I'm having difficulty installing, and there are no error diagnostics to provide further information.

  • I'm using Arch Linux
  • uname -a: Linux octet 3.19.3-3-ARCH The sync option #1 SMP PREEMPT Wed Apr 8 14:10:00 CEST 2015 x86_64 GNU/Linux
octet :: ~ % curl https://nixos.org/nix/install | sh                                                                                                                                                                                                          
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1329  100  1329    0     0   3015      0 --:--:-- --:--:-- --:--:--  3013
unpacking Nix binary tarball for x86_64-linux from `https://nixos.org/releases/nix/nix-1.8/nix-1.8-x86_64-linux.tar.bz2'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 68.9M  100 68.9M    0     0   496k      0  0:02:22  0:02:22 --:--:--  329k
performing a single-user installation of Nix...
directory /nix does not exist; creating it by running ‘mkdir -m 0755 /nix && chown mwilson /nix’ using sudo
copying Nix to /nix/store..........................
initialising Nix database...
creating /home/mwilson/.nix-profile
installing ‘nix-1.8’
building path(s) ‘/nix/store/l1jay99nhry9n4y1d7wij405q8rp2p9p-user-environment’
killing process 13511
error: 
nix-binary-tarball-unpack/nix-1.8-x86_64-linux/install: unable to install Nix into your default profile
@domenkozar
Copy link
Member

How much ram do you have? Can you reproduce every run?

@mwilson-ns
Copy link
Author

I have 16GB of RAM. I'm able to reproduce the given error every time.

@domenkozar
Copy link
Member

cc @edolstra any ideas?

@mwilson-ns
Copy link
Author

I worked around this issue. It turns out the issue was related to my shell environment. In a file that got sourced by my shell profile I exporting a variable that performs coloring of stderr:

# STDERR coloring, if available
if [ -f "/usr/lib/libstderred.so" ]; then
    export LD_PRELOAD="/usr/lib/libstderred.so"
fi

Removing this export allowed me to install nix and successfully use it. I would still consider this a bug, but I consider this issue closed.

@edolstra
Copy link
Member

What does libstderred do exactly?

@mwilson-ns
Copy link
Author

it colors anything emitted from stderr. https://github.com/sickill/stderred

@wawe
Copy link

wawe commented Feb 11, 2016

I had the same issue, also using libstderred via LD_PRELOAD. Unsetting LD_PRELOAD, as described by @mwilson-ns, worked for me as well.

@domenkozar
Copy link
Member

Could someone figure out where does it stop/crash exactly?

@Anton-Latukha
Copy link

Anton-Latukha commented Sep 3, 2017

@domenkozar

unable to install Nix into your default profile

I'm looking in that state of tree:
Disclose what happened in install-nix-from-closure.sh:

...
echo "initialising Nix database..." >&2
if ! $nix/bin/nix-store --init; then
    echo "$0: failed to initialize the Nix database" >&2
    exit 1
fi

if ! $nix/bin/nix-store --load-db < $self/.reginfo; then
    echo "$0: unable to register valid paths" >&2
    exit 1
fi

. $nix/etc/profile.d/nix.sh

if ! $nix/bin/nix-env -i "$nix"; then
    echo "$0: unable to install Nix into your default profile" >&2
    exit 1
fi

That shows that unable to install Nix into your default profile due to . $nix/etc/profile.d/nix.sh
And it is a file:
scripts/nix-profile.sh.in:

if [ -n "$HOME" ]; then
    NIX_LINK="$HOME/.nix-profile"

    # Set the default profile.
    if ! [ -L "$NIX_LINK" ]; then
        echo "creating $NIX_LINK" >&2
        _NIX_DEF_LINK=@localstatedir@/nix/profiles/default
        @coreutils@/ln -s "$_NIX_DEF_LINK" "$NIX_LINK"
    fi

    export PATH=$NIX_LINK/bin:$NIX_LINK/sbin:$PATH

    # Subscribe the user to the Nixpkgs channel by default.
    if [ ! -e $HOME/.nix-channels ]; then
        echo "https://nixos.org/channels/nixpkgs-unstable nixpkgs" > $HOME/.nix-channels
    fi

    # Append ~/.nix-defexpr/channels/nixpkgs to $NIX_PATH so that
    # <nixpkgs> paths work when the user has fetched the Nixpkgs
    # channel.
    export NIX_PATH=${NIX_PATH:+$NIX_PATH:}nixpkgs=$HOME/.nix-defexpr/channels/nixpkgs

    # Set $SSL_CERT_FILE so that Nixpkgs applications like curl work.
    if [ -e /etc/ssl/certs/ca-bundle.crt ]; then # Fedora, NixOS
        export SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt
    elif [ -e /etc/ssl/certs/ca-certificates.crt ]; then # Ubuntu, Debian
        export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
    elif [ -e "$NIX_LINK/etc/ca-bundle.crt" ]; then # fall back to Nix profile
        export SSL_CERT_FILE="$NIX_LINK/etc/ca-bundle.crt"
    fi
fi

We can see that it's responsibility to Set the default profile, if HOME/.nix-profile is absent or not a link.

And it does:

echo "creating $NIX_LINK" >&2

creating /home/mwilson/.nix-profile

Second time this message was not present (NixOS/nixpkgs#7733):

So there is indication that this script worked.

Then happens:

...
if ! $nix/bin/nix-env -i "$nix"; then
    echo "$0: unable to install Nix into your default profile" >&2
    exit 1
fi

Than means that during invocation, nix-env -i "$nix" fails, script prints a message, and with those things we have output:

installing ‘nix-1.8’
building path(s) ‘/nix/store/l1jay99nhry9n4y1d7wij405q8rp2p9p-user-environment’
killing process 13511
error:
/install: unable to install Nix into your default profile

nix-profile.sh.in was heavilly expanded and rewritten from May of 2015: current nix-profile.sh.in.

Last discussion here was Feb 11, 2016 when wawe witnesses bug.

Then, on Apr 11, 2016 in (commit)[https://github.com/NixOS/nix/commit/af4fb6ef6169b292c7f54e4278c896cb453c56c5] wmertens heavilly rewrote script.

In related to that commit bug #414 named "nix-env doesn't auto-create per-user profile?" he created in 2014 and closed the same Apr 11, 2016 he did commit, in description he states:

If your nix-env was originally set up by https://github.com/NixOS/nix/blob/master/scripts/nix-profile.sh.in#L5-L9 then your ~/.nix-profile will point to /nix/var/nix/profiles/default.

If you then use nix-env -i ... and you don't have write access to that directory, it will fail to update your environment instead of creating a new environment under /nix/var/nix/profiles/per-user/$USER/.

It will also not give you any indication of what's happening, all you get is error: opening lock file ‘/nix/var/nix/profiles/default.lock’: Permission denied

By 'https://github.com/NixOS/nix/blob/master/scripts/nix-profile.sh.in#L5-L9' he points to that time master:

if ! [ -L "$NIX_LINK" ]; then
echo "creating $NIX_LINK" >&2
_NIX_DEF_LINK=@localstatedir@/nix/profiles/default
@coreutils@/ln -s "$_NIX_DEF_LINK" "$NIX_LINK"
fi

Since;

  1. 'nix-env -i ... will fail to update' and
  2. 'It will also not give you any indication of what's happening' and it gives 'error:' and
  3. this bug spans two years, so it is highly plausible that mwilson-ns just hit the same bug, but with effect that it resulted in just 'error:' and
  4. since we can see that mwilson-ns here used modified shell introduction line, but in (Installation fails with empty error message nixpkgs#7733) he already uses classic one, and it states $ - that means he installs Nix from a user (not root), that indicates that bug#414 applies to him (his user does not have /nix/var/nix/profiles write permissions).

In install script, directory creation uses:

if ! [ -e $dest ]; then
    cmd="mkdir -m 0755 $dest && chown $USER $dest"
    echo "directory $dest does not exist; creating it by running ‘$cmd’ using sudo" >&2
    if ! sudo sh -c "$cmd"; then
        echo "$0: please manually run ‘$cmd’ as root to create $dest" >&2
        exit 1
    fi
fi

Note that he had message:

directory /nix does not exist; creating it by running ‘mkdir -m 0755 /nix && chown mwilson /nix’ using sudo


So mwilson installs Nix from normal user that has sudoers access (probably passwordless sudoers access).
But he hits a bug #414. because after that one use of sudo - all commands executed from his user mwilson.
So he hits directory write permissions problem.
Then nix-env -i can not write to the nix/var/nix/profiles/, so in its tantrum its own child get killed. poor 13511, and in desperation nix-env commits suicide.

I think case closed here.

It is duplicate of bug #414 and already solved crime case.

@domenkozar
Copy link
Member

Closing as it seems to be resolved.

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

7 participants