Bruno
Bruno

Reputation: 864

Where does Cabal install a package globally on a Mac?

In macOS, if I execute

cabal install foo --global

where does cabal install the foo package?

Upvotes: 1

Views: 1004

Answers (2)

Thomas M. DuBuisson
Thomas M. DuBuisson

Reputation: 64740

There is no one place GHC stores global data—it depends on the configuration and that will vary by where you got GHC from (nixpkgs, Homebrew (brew), MacPorts, raw from GHCHQ, etc.). For your particular case, you can get information as described by DanielWagner:

ghc-pkg describe unix --global

And some simple shell scripting can extract the specific information you desire:

ghc-pkg describe unix --global | egrep '^pkgroot' | cut -d' ' -f2

Output:

"/usr/local/Cellar/ghc/8.4.1/lib/ghc-8.4.1"

Or:

% nix-shell -p ghc
ghc-pkg describe unix --global | egrep '^pkgroot' | cut -d' ' -f2

Output:

"/nix/store/z0ypzmbhn6m0l2adzm8szcd72z7kwy04-ghc-8.0.2/lib/ghc-8.0.2"

Upvotes: 2

anon
anon

Reputation:

The setting for your user is in ~/.cabal/config, in the install-dirs global section, under prefix:. (E.g. on Linux, it is pre-set to /usr/local.)

Although in my cabal, for some reason --global does the same thing as --user, according to the man page.

I would avoid using it.

Upvotes: 0

Related Questions