“cabal install cabal-install” doesn't update cabal version in OSX

荒凉一梦 提交于 2019-12-03 12:16:18

There are two ways of making cabal install packages globally. Note that, as a result, cabal may require sudo.

This command will install <PACKAGE> globally:

$ cabal install <PACKAGE> --global

As a more general solution, edit the file ~/.cabal/config and set user-install to False. This will automatically set the --global flag so you can just write cabal install <PACKAGE> without any worry. Here's a snippet of my config file:

...
-- split-objs: False
-- executable-stripping: True
user-install: False
-- package-db:
-- flags:
...

You may also want to set root-cmd to sudo if it's not already, so that cabal will automatically prompt for the root password when it encounters a permission problem.

There's some more info online here.

I see that there's an updated cabal at ~/Library/Haskell/bin, so I could replace /usr/bin/cabal with a symbolic link to this copy or I could copy this binary to /usr/bin.

I'm still interested if there is a more elegant/canonical way to make sure the new cabal is what gets used by default.

TLDR: Try running hash -r

Bash has a PATH hashtable that maps commands to the location of binaries. You may still have an old version of cabal installed somewhere in your PATH (possibly in a sandbox). Since cabal is not a new command, the hashtable will keep serving up the old version. hash -r rebuilds the hashtable, so the shell will correctly find the new version (providing it appears earlier in your path than the old one).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!