New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use configured compiler for cabal sandbox hc-pkg #2859

Merged
merged 3 commits into from Oct 12, 2015

Conversation

Projects
None yet
3 participants
@adamgundry
Copy link
Contributor

adamgundry commented Oct 11, 2015

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!

Use configured compiler for cabal sandbox hc-pkg
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.
@@ -791,3 +797,18 @@ configCompilerAux' configFlags =
configCompilerAuxEx configFlags
--FIXME: make configCompilerAux use a sensible verbosity
{ configVerbosity = fmap lessVerbose (configVerbosity configFlags) }

-- | Try to read the most recently configured compiler from the

This comment has been minimized.

@23Skidoo

23Skidoo Oct 11, 2015

Member

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

This comment has been minimized.

@adamgundry

adamgundry Oct 11, 2015

Contributor

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

This comment has been minimized.

Copy link
Member

23Skidoo commented Oct 11, 2015

Looks OK.

@luite

This comment has been minimized.

Copy link
Member

luite commented Oct 11, 2015

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

This comment has been minimized.

Copy link
Member

luite commented Oct 11, 2015

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

@luite

This comment has been minimized.

Copy link
Member

luite commented Oct 11, 2015

Erm, next time I should build the correct branch first

@luite

This comment has been minimized.

Copy link
Member

luite commented Oct 11, 2015

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

This comment has been minimized.

Copy link
Contributor

adamgundry commented Oct 11, 2015

I'm on it.

Prevent bogus warning in cabal exec
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

This comment has been minimized.

Copy link
Contributor

adamgundry commented Oct 11, 2015

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

@luite

This comment has been minimized.

Copy link
Member

luite commented Oct 12, 2015

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

@23Skidoo

This comment has been minimized.

Copy link
Member

23Skidoo commented Oct 12, 2015

LGTM, merging.

23Skidoo added a commit that referenced this pull request Oct 12, 2015

Merge pull request #2859 from adamgundry/fix-sandbox-hcpkg
Use configured compiler for cabal sandbox hc-pkg

@23Skidoo 23Skidoo merged commit 146d736 into haskell:master Oct 12, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@23Skidoo

This comment has been minimized.

Copy link
Member

23Skidoo commented Oct 12, 2015

Merged, thanks!

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