1

I installed some programm (xlsx2csv) using pip3. The executable of the software is in ~/.local/bin. My $PATH is defined in ~/.profile like this:

PATH="$HOME/bin:$HOME/.local/bin:$PATH"

echo $PATH
/home/bruni/bin:/home/bruni/.local/bin:/home/bruni/bin:/home/bruni/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Permissions on the executable seem ok:

bruni@bruni-Inspiron-5547:~/.local/bin$ ls -l
total 44
-rwxrwxr-x 1 bruni bruni 42501 Jul  2 12:39 xlsx2csv

bruni@bruni-Inspiron-5547:~/.local/bin$ type -a xlsx2csv 
xlsx2csv is /home/bruni/.local/bin/xlsx2csv
xlsx2csv is /home/bruni/.local/bin/xlsx2csv

Nonetheless, I cannot invoke the installed software without specifying the exact path.

:~$ xlsx2csv
-bash: /usr/bin/xlsx2csv: No such file or directory
Bruni
  • 10,542
  • 1
    Can you show the output of echo $PATH and type -a xlsx2csv? – Byte Commander Jul 02 '18 at 10:12
  • 1
    For some reason you have /home/bruni/bin:/home/bruni/.local/bin: on your PATH twice, but I doubt that would break it. Still would be worth removing the duplicate IMHO. And what exactly is the error message when you try to run the command xlsx2csv? You could also run hash -r to clear some command path caches and try again afterwards. – Byte Commander Jul 02 '18 at 10:28

1 Answers1

2

So you have the executable xlsx2csv in your ~/.local/bin folder, which is added to the $PATH variable correctly (even twice, which should be fixed, but is not critical).

It is correctly recognized as executable there, as we can see from the output of type -a xlsx2csv, which lists us all types/locations of the given command (could be e.g. shell built-in/function/alias or executable file - type help type for more info).

However, Bash believes it can be found as /usr/bin/xlsx2csv, as you see in the error when trying to invoke it.

This is a result of Bash (and other shells) using an internal hash table to speed up command look-ups. Probably the wrong entry is there because you had such an executable in that location earlier and ran it, but then it got moved or uninstalled and reinstalled int he other location.

Normally Bash resets its hash table when there are events that obviously invalidate it, like when you change the $PATH variable. It did obviously not recognize your re-installation procedure there though, but we can reset it manually:

hash -r

This command above resets Bash's command hash table and clears all the cached command location entries, forcing it to do a regular look-up in your $PATH the next time you type any command. You can see the current hash table by typing hash only. For more information, read its help by typing help hash. You can also visit What is the purpose of the hash command? (Unix & Linux SE) for more information about Bash's command location hashing.

Byte Commander
  • 107,489