47

I want to run the following on ubunt 20.04:

sh <(curl -L https://nixos.org/nix/install) --daemon

what I got is this:

sh <(curl -L https://nixos.org/nix/install) --daemon
  % 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  4046  100  4046    0     0  16782      0 --:--:-- --:--:-- --:--:--   98k
downloading Nix 2.5.1 binary tarball for x86_64-linux from 'https://releases.nixos.org/nix/nix-2.5.1/nix-2.5.1-x86_64-linux.tar.xz' to '/tmp/nix-binary-tarball-unpack.KPhkYw21Nn'...
  % 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.KPhkYw21Nn/nix-2.5.1-x86_64-linux.tar.x
Warning: z: No such file or directory
  0 27.1M    0  1103    0     0  10753      0  0:44:05 --:--:--  0:44:05 10813
curl: (23) Failure writing output to destination
/dev/fd/63: failed to download 'https://releases.nixos.org/nix/nix-2.5.1/nix-2.5.1-x86_64-linux.tar.xz'

When I have a look at /dev/fd/ I see a bunch of files marked inaccessible:

enter image description here

I guess this has something to do with the failure to download. Am I right? What can I do against it? I am just a 'normal' ubuntu user, this kind of stuff exceeds my ubuntu-knowledge.

UPDATE: Even if I run the whole thing as root the result remains the same:

enter image description here

Sanyifejű
  • 1,721
  • 3
    Probably you have to download inside your home folder, where you have enough permissions. Also note that /dev/fb/ and /dev/fd/ are different objects. Which guide do you follow? Do you have sudo permissions on this computer? – N0rbert Jan 14 '22 at 17:40
  • Try adding the option -s to curl. Maybe then you will notice this: "Warning: Failed to create the file" and "Failure writing output to destination" . – Luuk Jan 14 '22 at 18:31
  • @N0rbert, yes, I do have sudo permission, but id does not seem to help. I am trying to follow this : https://nixos.org/download.html. Forgive me for my stupid question, but I am now in pr@server (probably due to a earlier installation which no longer matters).From here how to get to get to pr@home, or home? – Sanyifejű Jan 14 '22 at 18:57
  • @Luuk sh <(curl -s -L https://nixos.org/nix/install) --daemon Unfortunately makes no difference – Sanyifejű Jan 14 '22 at 19:00
  • 1
    You can enter exit to exit from SSH session. Or simply open new local terminal instance with Ctrl+Alt+T. – N0rbert Jan 14 '22 at 19:08
  • @N0rbert Unfortunately it's permanent. A new terminal also takes me to pr@server. Even after reboot. – Sanyifejű Jan 15 '22 at 08:11
  • You can try the "Installing from a binary tarball" which is mentioned in this document: Installing a Binary Distribution. – Luuk Jan 15 '22 at 11:21

3 Answers3

115

After a very long research I found a useful hint.

Can't write to a hidden path using Curl

Basically snap curl is useless. Uninstall it properly. Get the proper apt curl, and everything works like a charm.

$ sudo snap remove curl
$ sudo apt install curl
learner
  • 2,004
Sanyifejű
  • 1,721
  • 2
    Great advice. One problem though for me: I'm on ubuntu 22.04 and I removed snap curl. Problem is the alias 'curl' seems to remain and I have to manually type /usr/bin/curl if i want to use the apt installed version. Anyone know how to remove the snap curl alias? – Code True Aug 20 '22 at 16:34
  • 1
    @jb1, I don't know why its still considering snap installed curl. But I suggest you to take a look inside "environment" file with sudo vi /etc/environment. And see how does the value of PATH variable looks like.

    Precisely, "/usr/bin" should appear first, and later "/snap/bin" should present. Mine looks like this.

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

    – learner Sep 17 '22 at 03:55
  • 4
    Same here when running pyenv install under Ubutnu 22.04.1. Resolved following your advice. – Fanta Oct 10 '22 at 14:59
  • 3
    this problem still exist in ubuntu 22.04 – sam Nov 28 '22 at 09:37
  • Snaps strike again! What a POS... – CrazyPyro Jul 10 '23 at 20:31
  • Same problem, same solution: Ubuntu 23.04. – A. L. Flanagan Sep 04 '23 at 15:33
  • I literally don't understand this at all.. but this fixes it. – Duncan Finney Oct 04 '23 at 11:27
  • I think the issue is related to how the snap store installs the command in the system. It seems like it's not correctly elevating the permission of the curl command itself when installing. So this is causing for some installation with directories like home in the ubuntu machine. – Rajendrasinh Parmar Dec 26 '23 at 19:24
3

In my case

$ sudo snap remove curl

didn't worked. So I had to remove it via apt-get like these:

$ sudo apt-get remove curl

Than installed it again.

$ sudo apt install curl

My problems solved.

Tech
  • 131
0

I faced the same error and below I shared how to fix.

First notice either you're logged-in as root@your-server-ip user or some other user@ip like debian@your-server-ip account.

In my case, I was logged-in as debian@vps-1a7c9 and try to run command using sudo and without sudo but got error curl: (23) Failure writing output to destination

How to Fix: run command sudo su to login as root this will change the current user to root user and terminals will look like root@your-server-ip.

Even this user debian@your-server-ip is an administrator account, but terminal return curl error, and after changing it to root@ all errors gone and commands worked. Means you're required to login as root.

  • The question says: UPDATE: Even if I run the whole thing as root the result remains the same It seems like you haven't read it. – karel Feb 25 '23 at 17:15