"/dev/fd/63 No such file or directory"

I've been trying to run a command in chroot (pretty new to this), and I get the following output.

root@hostname:~ # bash <(wget -q0 https://raw.githubusercontent.com/ubports/unity8-desktop-install-tools/master/install.sh) 
bash: /dev/fd/63: No such file or directory root

Solution 1:

TL;DR: copy the /root folder outside chroot into the chroot directory

The <(...) operator is known as process substitution and is a way to run command, output of which goes into anonymous pipe. That's what /dev/fd/63 is. The idea is to allow external command ( here it's bash ) to treat another commands output as if it was a file. Generally the form would be to use < to redirect that pseudo-file object into bash's input stream.

bash < <(wget -q0 https://raw.githubusercontent.com/ubports/unity8-desktop-install-tools/master/install.sh)

This is generally no different from wget https://stuff.com/blah | bash. In both cases, it's generally not recommended to use such commands unless you're hundred percent sure the script you're downloading isn't from sketchy source and isn't malware.

However, since you've mentioned running command in chroot and the script outputs No such file or directory root, and because bash allows running scripts as bash script.sh here your script is being executed, but there's no directory named root in your chroot. You could just fix it via sudo cp -R /root chrootdir. For better results I'd suggest just reading the script first, see what it needs, and copy that to the chroot folder, and only then run the script locally within the folder. No need to run wget multiple times

So the script works. Errors in shell scripting generally in form <shell>: <command user typed>: error message so the script being temporarily stored as /dev/fd/63 and runs, it just doesn't find what it needs.

See also,

  • What's the difference between <<, <<< and < < in bash?

  • Why does the error message for two colons as a command (::) in bash have three colons, but a single colon give no output?

Solution 2:

Error message

/dev/fd/63 No such file or directory

Problem source

Indeed the directory /dev/fd/ did not exist on that machine.

Solution

The solution was to create a symbolic link from /proc/self/fd to /dev/fd like so:

ln -s /proc/self/fd /dev/fd

Process substitution <(..) wouldn't work on QNAP without this.