Skip to content

Use configured compiler for cabal sandbox hc-pkg - #2859

Merged
23Skidoo merged 3 commits into
haskell:masterfrom
adamgundry:fix-sandbox-hcpkg
Oct 12, 2015
Merged

23Skidoo merged 3 commits into
haskell:masterfrom
adamgundry:fix-sandbox-hcpkg

Conversation

@adamgundry

Copy link
Copy Markdown
Member

For most commands (e.g. cabal install), the package-db field in cabal.sandbox.config is ignored, and the path is reconstructed from the prefix and current compiler instead. This is arguably the right behaviour, because the right package DB depends on the arch/compiler, so it doesn't make sense to specify only one. This commit makes cabal sandbox hc-pkg behave similarly, to avoid invoking ghc-pkg on an incompatible package DB (fixes #1935).

Moreover, the compiler version to use is now picked up from the most recently configured compiler, if any. Otherwise, the global default compiler is used, as before.

I think the package-db field should probably be removed from cabal.sandbox.config completely, but I haven't yet investigated this.

@luite hopefully this will make cabal configure -w ghcjs && cabal sandbox hc-pkg list just do the right thing; please yell if not!

For most commands (e.g. `cabal install`), the `package-db` field in
`cabal.sandbox.config` is ignored, and the path is reconstructed
from the `prefix` and current compiler instead.  This is arguably
the right behaviour, because the right package DB depends on the
arch/compiler, so it doesn't make sense to specify only one.  This
commit makes `cabal sandbox hc-pkg` behave similarly, to avoid
invoking ghc-pkg on an incompatible package DB (fixes haskell#1935).

Moreover, the compiler version to use is now picked up from the
most recently configured compiler, if any.  Otherwise, the global
default compiler is used, as before.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this function can be also used in other places in this file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered this too, which is why I factored it out as a separate function. But I haven't really investigated the other uses of configCompilerAux', configCompilerAuxEx, and so on...

@23Skidoo

Copy link
Copy Markdown
Member

Looks OK.

@luite

luite commented Oct 11, 2015

Copy link
Copy Markdown
Member

Hmm, it doesn't appear to quite work correctly for GHCJS. Packages end up in the correct package db, but cabal sandbox hc-pkg list does not seem to read the configured compiler. Setting the default compiler to ghcjs with a line compiler: ghcjs in a local cabal.config file makes the command appear to use the correct dir, but the package list is empty.

I'll investigate a bit more.

@luite

luite commented Oct 11, 2015

Copy link
Copy Markdown
Member

Oh I was looking at the wrong thing, it is using ghcjs-pkg correctly, but passes the wrong path.

@luite

luite commented Oct 11, 2015

Copy link
Copy Markdown
Member

Erm, next time I should build the correct branch first

@luite

luite commented Oct 11, 2015

Copy link
Copy Markdown
Member

cabal sandbox hc-pkg appears to work now. cabal sandbox exec does not seem to use the currently configured compiler. can this be fixed in the same way?

@adamgundry

Copy link
Copy Markdown
Member Author

I'm on it.

The GHC[JS]_PACKAGE_PATH and CABAL_SANDBOX_PACKAGE_PATH environment
variables contain colon-separated lists of package DBs, so it doesn't
make sense to call doesDirectoryExist on the colon-separated list.
Instead, this just checks for the existence of the sandbox package DB.
@adamgundry

Copy link
Copy Markdown
Member Author

Now cabal exec should be fixed, and a bogus warning that it was generating is now suppressed.

@luite

luite commented Oct 12, 2015

Copy link
Copy Markdown
Member

Works ok here with GHCJS / ghcjs-pkg. I'd be happy to merge this if no one objects.

@23Skidoo

Copy link
Copy Markdown
Member

LGTM, merging.

23Skidoo added a commit that referenced this pull request Oct 12, 2015
Use configured compiler for cabal sandbox hc-pkg
@23Skidoo
23Skidoo merged commit 146d736 into haskell:master Oct 12, 2015
@23Skidoo

Copy link
Copy Markdown
Member

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sandbox-config's package-db path contains hardcoded GHC version

3 participants