Today I noticed that my path has an entry No such file or directory
at the end, which causing other problems.
My path looks like this: /home/geneorama/gems/bin:/home/geneorama/anaconda3/bin:/home/geneorama/.local/bin:/home/geneorama/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory
I can't figure out what's adding it, and would like to know how to troubleshoot it.
I checked .bashrc
and didn't notice any problems. The .bashrc
adds anaconda and Ruby as expected.
Based on this great answer on how the PATH is set, I checked my ~/.profile
file. The profile script just runs .bashrc, and adds $HOME/bin
and $HOME/.local/bin
to the path. Those paths are only added if they exist, and they do.
I read what I could understand of man login
. This led me to check /etc/login.defs
, but that looked very vanilla. I don't have any of the other files mentioned in the login help.
Any ideas how to troubleshoot where this is happening?
EDIT: Jan 11, 2021
Based on the comments I edited the question to say that I had checked ~.profile
.
I also made a very simple version of ~.bashrc
, rebooted, and ran bash with the debug commands. The PATH
is still corrupted.
geneorama@computer:~$ bash -x ~/.bashrc
+ HISTCONTROL=ignoreboth
+ shopt -s histappend
+ HISTSIZE=9999999
+ HISTFILESIZE=999999999
+ shopt -s checkwinsize
geneorama@computer:~$ $PATH
bash: /home/geneorama/.local/bin:/home/geneorama/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory
EDIT: Jan 11, 2021 (second edit today)
I also noticed that I can't fix the error by manually setting the path or by logging in as root. I tried using export
and setting the path using a quoted string (I don't know if it matters or the best way).
geneorama@computer:~$ $PATH
bash: /home/geneorama/gems/bin:/home/geneorama/anaconda3/bin:/home/geneorama/.local/bin:/home/geneorama/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory
geneorama@computer:~$ PATH="/home/geneorama/gems/bin:/home/geneorama/anaconda3/bin:/home/geneorama/.local/bin:/home/geneorama/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
geneorama@computer:~$ $PATH
bash: /home/geneorama/gems/bin:/home/geneorama/anaconda3/bin:/home/geneorama/.local/bin:/home/geneorama/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: No such file or directory
geneorama@computer:~$ sudo su -
[sudo] password for geneorama:
root@ativ4-v18:~# $PATH
-bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory
root@ativ4-v18:~# logout
geneorama@computer:~$ export PATH=/home/geneorama/gems/bin:/home/geneorama/anaconda3/bin:/home/geneorama/.local/bin:/home/geneorama/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
geneorama@computer:~$ $PATH
bash: /home/geneorama/gems/bin:/home/geneorama/anaconda3/bin:/home/geneorama/.local/bin:/home/geneorama/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: No such file or directory
Also looked in /etc/environment/
and /etc/environment.d/
. The first was empty and the second had two files 90atk-adaptor.conf
and 90qt-a11y.conf
, but they do not seem to be affecting the path.
EDIT: Jan 11, 2021 (third edit today)
Even when I manually set my path to be just /sbin
and /bin
I get the error. At this point I don't understand if the error message is actually on my path or printing along with the path.
geneorama@computer:~$ export PATH=/sbin:/bin
geneorama@computer:~$ $PATH
bash: /sbin:/bin: No such file or directory
EDIT: Jan 12, 2021
Originally I was getting an error in Jekyll. Some sites said that my error was caused by spaces in $PATH
. When I (improperly) printed my $PATH
I thought that something was trying to add a path that I had deleted. I thought that I had uninstalled something improperly.
The spaces being printed were part of an error message, not part of the $PATH
.
Apparently Jekyll was corrupted, and the solution was to apt remove
it and then reinstall it.
Along the way I learned that the path variable is modified in many non-obvious ways. The answer to my question was essentially "print your $PATH correctly".
One day someone may ask "how to I debug / profile edits to my $PATH?", and someone may mark it as a duplicate. It's not a duplicate of this question. This question turned out to be "how do I print $PATH".
bash -x ~/.bashrc
.