5

I installed parcellite in Ubuntu (downloaded from http://parcellite.sourceforge.net/)

After installing from sources, sudo make install, I can see that it is installed at below location.

However, when I try to run it, it tries to run it from another path. Why is that?

user$ which parcellite
/usr/local/bin/parcellite

user$ parcellite -h
bash: /usr/bin/parcellite: No such file or directory

$PATH is as below

/home/user/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

I tried changing ownership of executable as follows. Still the problem persists.

user$ ls -l /usr/local/bin/parcellite 
-rwxr-xr-x 1 root root 452K Oct  7 21:00 /usr/local/bin/parcellite
user$sudo chown user:user /usr/local/bin/parcellite
user$ ls -l /usr/local/bin/parcellite 
-rwxr-xr-x 1 user user 452K Oct  7 21:01 /usr/local/bin/parcellite

I had an older version of parcellite installed. But I removed it prior to installing new version.


Update: @Fox's solution works. But any idea why which command gives correct path, despite hashNOT being updated?

xxx374562
  • 304

1 Answers1

6

If you had a version installed, then installed another version elsewhere, then your shell will have cached (hashed) the original path. You can clear this cache with hash -r. Then the next time you run the command it will be rehashed with the new path.

Note that this cache is not global, if you have several running shells you will have to update each of them.

As to why which sees the correct path, "Why not use which" is a good source of information, but the short answer is that which is an external command that doesn't see the shell's path cache.

Fox
  • 8,193
  • Thanks! This worked! I had earlier tried sudo updatedb but that didn't work. I think that hash commands needs to run automatically each time a program is installed. – xxx374562 Oct 09 '18 at 03:50
  • 1
    More info about hash was found here. https://unix.stackexchange.com/questions/86012/what-is-the-purpose-of-the-hash-command

    hash is a bash built-in command. The hash table is a feature of bash that prevents it from having to search $PATH every time you type a command by caching the results in memory. The table gets cleared on events that obviously invalidate the results (such as modifying $PATH)

    – xxx374562 Oct 09 '18 at 03:53
  • Any idea why which command gives correct path, despite hashNOT being updated? – xxx374562 Oct 09 '18 at 03:56