4

For some strange reason, I'm getting a "No such file or directory" error for my $PATH variable. I have tried to edit my path using export, changing it from what it was originally to every permutation from a single directory path to the original.

When there is one directory (e.g., export PATH=/bin), I get "/bin: Is a Directory". But once I add more than one directory (e.g., export PATH=/bin:/sbin), I get "No such file or directory".

I'm curious to see what the cause of this issue is!

3 Answers 3

2

RE; your comment:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/u‌sr/local/mysql/bin: No such file or directory will be generated if you have a line which says:

$PATH

maybe on its own, or maybe you have $PATH=.... That is, the shell is trying to execute a program named:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/u‌sr/local/mysql/bin

Lose the $ on the left-hand side.

Sign up to request clarification or add additional context in comments.

Comments

1

I'm not sure you are using the export variant. You almost certainly have spaces in there and you shouldn't, as per the following transcript:

pax> PATH= /bin
bash: /bin: is a directory

pax> PATH= /bin/sbin
bash: /bin/sbin: No such file or directory

The first is caused because you're setting the path temporarily to an empty string while attempting to run that directory. That's because you can do things like:

pax> xyzzy=1

pax> echo $xyzzy
1

pax> xyzzy=2 bash -c 'echo $xyzzy'
2

pax> echo $xyzzy
1

In other words, it's a way of changing an environment variable for a single command, and having it automatically revert when the command is finished.

The second case is simply because there is no /bin/sbin directory. So it detects that before it complains about the fact that you're trying to run a directory.

Setting a variable in bash is a no-space thing (unless you have spaces in your directory names, in which case they should be quoted). In addition, they need to be colon-sparated. Hence you're looking for things like:

PATH=/bin
PATH=/bin:/sbin
PATH="/bin:/sbin:/directory with spaces in it:$HOME/bin"

1 Comment

whoops, the second issue bin/sbin was an error on my part when writing the question my actual export is correct (I think!) here is the content of $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin: No such file or directory I am also aware that it is a no space operation but the issue might come from. $PATH is also edited by editing the .bash_profile
0

The export function will only change the variable for the current terminal session.

Write your PATH inside ~/.bash_profile if you want to change it permanently.

For this modification to work you have to close your current terminal and reopen it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.