Trouble installing nix on Ubuntu 20.04.3 LTS

Trying to follow the install instructions for nix and I am getting a “curl (23) Failure writing output to destination”. It’s trying to write to ./tmp and I checked the permissions. I even tried taking ownership of the folder and still no luck. Here is my output after running bash <(curl -L https://nixos.org/nix/install)

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  2619  100  2619    0     0   3469      0 --:--:-- --:--:-- --:--:--  3469
downloading Nix 2.3.15 binary tarball for x86_64-linux from 'https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz' to '/tmp/nix-binary-tarball-unpack.TPM2cTukvX'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file 
Warning: /tmp/nix-binary-tarball-unpack.TPM2cTukvX/nix-2.3.15-x86_64-linux.tar.
Warning: xz: No such file or directory
  0 25.6M    0  1406    0     0   4808      0  1:33:22 --:--:--  1:33:22  4815
curl: (23) Failure writing output to destination
/dev/fd/63: failed to download 'https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz'

I have about 230GB free on the SSD so it’s not a space issue. Any help would be much appreciated.

You presumably need whatever package provides xz. (installer: also test for xz to unpack by pmiddend · Pull Request #3431 · NixOS/nix · GitHub alerts about this condition more clearly, but it hasn’t quite been released, yet)

1 Like

It appears I have xz installed:

$ xz --version
xz (XZ Utils) 5.2.4
liblzma 5.2.4

Are you running fish shell?

No. Just a fresh install of Ubuntu and the standard terminal.

Have you tried it more than once?

Haha. I have tried about 100 times at this point. Also did a couple reboots just in case.

The first warning is:

Warning: Failed to create the file

That’s why I thought is was a permissions issue at first.

I don’t recall seeing any specific cases like this. You can either wait to see if someone who has turns up, or start debugging.

I think you could use bash -x or sh -x to see which command is running at the outer level when it fails.

Here is the output with bash -x :

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  2619  100  2619    0     0   3326      0 --:--:-- --:--:-- --:--:--  3326
+ umask 0022
++ mktemp -d -t nix-binary-tarball-unpack.XXXXXXXXXX
+ tmpDir=/tmp/nix-binary-tarball-unpack.AfvqG8211t
+ trap cleanup EXIT INT QUIT TERM
+ case "$(uname -s).$(uname -m)" in
++ uname -s
++ uname -m
+ system=x86_64-linux
+ hash=aae346f0ee447efa042c38e320aee0368e3c6c7fa331d76f708bbe8539f694fa
+ url=https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz
++ basename /tmp/nix-binary-tarball-unpack.AfvqG8211t/nix-2.3.15-x86_64-linux.tar.xz
+ tarball=/tmp/nix-binary-tarball-unpack.AfvqG8211t/nix-2.3.15-x86_64-linux.tar.xz
+ require_util curl 'download the binary tarball'
+ command -v curl
+ require_util tar 'unpack the binary tarball'
+ command -v tar
++ uname -s
+ '[' Linux '!=' Darwin ']'
+ require_util xz 'unpack the binary tarball'
+ command -v xz
+ echo 'downloading Nix 2.3.15 binary tarball for x86_64-linux from '\''https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz'\'' to '\''/tmp/nix-binary-tarball-unpack.AfvqG8211t'\''...'
downloading Nix 2.3.15 binary tarball for x86_64-linux from 'https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz' to '/tmp/nix-binary-tarball-unpack.AfvqG8211t'...
+ curl -L https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz -o /tmp/nix-binary-tarball-unpack.AfvqG8211t/nix-2.3.15-x86_64-linux.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file 
Warning: /tmp/nix-binary-tarball-unpack.AfvqG8211t/nix-2.3.15-x86_64-linux.tar.
Warning: xz: No such file or directory
  0 25.6M    0  1406    0     0   5996      0  1:14:52 --:--:--  1:14:52  5982
curl: (23) Failure writing output to destination
+ oops 'failed to download '\''https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz'\'''
+ echo /dev/fd/63: 'failed to download '\''https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz'\'''
/dev/fd/63: failed to download 'https://releases.nixos.org/nix/nix-2.3.15/nix-2.3.15-x86_64-linux.tar.xz'
+ exit 1
+ cleanup
+ rm -rf /tmp/nix-binary-tarball-unpack.AfvqG8211t

Well I wiped the drive and did another fresh install of Ubuntu. This time I had no problems. Not sure what I did differently but it seems to work now. :question: :question: :question:

I ran into this today as well. I solved it by installing curl through apt instead of snap:

sudo snap remove curl
sudo apt install curl

Credit to this askubuntu post: 20.04 - curl: (23) Failure writing output to destination - Ask Ubuntu

2 Likes

Thanks for connecting the dots here. It looks like this was an older report of the issue in Nix installation fails on Ubuntu 20.04 · Issue #6199 · NixOS/nix · GitHub