Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash can't find ghc after reinstalling?

I just reinstalled Haskell Platform (here is why) and after reinstalling the Haskell Platform I get:

Drews-MacBook-Pro:Blokus-AI drewgross$ ghc
-bash: /usr/local/bin/ghc: No such file or directory

Any idea why? I suspect that this is something to do with my path or something like that but I haven't found anything weird yet. I can use ghc directly:

Drews-MacBook-Pro:Blokus-AI drewgross$ /usr/bin/ghc
ghc: no input files
Usage: For basic information, try the `--help' option.

And /usr/bin/ is in my path:

Drews-MacBook-Pro:Blokus-AI drewgross$ echo $PATH
/Users/drewgross/.rvm/gems/ruby-1.9.3-p327/bin:/Users/drewgross/.rvm/gems/ruby-1.9.3-p327@global/bin:/Users/drewgross/.rvm/rubies/ruby-1.9.3-p327/bin:/Users/drewgross/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

what else can I do?

like image 303
Drew Avatar asked Dec 11 '12 19:12

Drew


2 Answers

The bash shell caches paths to commands that you've previously used. Using which ghc won't show this (because it's external to the shell and just queries the PATH), but type is a bash-internal command that will reveal this situation, so type ghc will show something like

ghc is hashed (/usr/local/bin/ghc)

The fix is easy. Either start a new shell (where you start from scratch), or clear the cache by saying hash -r.

like image 146
kosmikus Avatar answered Nov 08 '22 21:11

kosmikus


One of your directories in your $PATH has an executable symlink which points to the no-longer-existent /usr/local/bin/ghc. To find out, type which ghc in bash. If the result is indeed a symlink, simply delete it. If it's a custom script, you may want to rename it instead of deleting in case you happen to need it later.

like image 20
us2012 Avatar answered Nov 08 '22 19:11

us2012