Wednesday, May 15, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 10926  / 1 Year ago, thu, may 25, 2023, 12:14:31

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".


More From » command-line

 Answers
2

The problem isn't with your PATH, it's with how you're trying to display it. The first thing in a command line is the command you're running. If you just type $PATH, the shell will try to run your PATH as a command, and it's not a command -- it's a colon-delimited list of directories to look for commands in. Since there's no actual command by that name, you get an error. (And since it's looking for an executable file corresponding to that command, the error you get is "No such file or directory").


To display the value of a shell varible like PATH correctly, use e.g. echo "$PATH" (or if it might contain backslashes/escapes, use printf '%s
' "$PATH"
instead). You can sometimes omit the double-quotes around variable references, but not always, so it's safer to just get in the habit of double-quoting variable references. And I mean always, not just in echo commands. See here, here, and here for more explanation.


For PATH specifically, it's often easier to see it if it's broken up into separate directories; you can use the tr command to turn the colon delimiters into newlines. Compare these two examples:


$ echo "$PATH"
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games

$ echo "$PATH" | tr ':' '
'
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/local/games
/usr/games

[#2108] Thursday, May 25, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rmodmi

Total Points: 390
Total Questions: 122
Total Answers: 111

Location: Venezuela
Member since Mon, Oct 18, 2021
3 Years ago
;