Skip to content

Custom ghc-options lost when calling cabal build in sandbox #2236

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

Closed
snoyberg opened this issue Nov 19, 2014 · 5 comments
Closed

Custom ghc-options lost when calling cabal build in sandbox #2236

snoyberg opened this issue Nov 19, 2014 · 5 comments

Comments

@snoyberg
Copy link
Collaborator

Actions:

  1. Set up a project that has a warning in it when compiled with -Wall (I took acme-missiles and removed a type signature).
  2. cabal sandbox init.
  3. cabal install --ghc-options="-Wall -Werror"
  4. As expected, above fails due to warning
  5. cabal build

Expected: fails again

Actual: Get the surprising output:

$ cabal build
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring acme-missiles-0.3...
Building acme-missiles-0.3...
Preprocessing library acme-missiles-0.3...
[1 of 2] Compiling Acme.Missiles    ( Acme/Missiles.hs, dist/build/Acme/Missiles.o )

Acme/Missiles.hs:17:1: Warning:
    Top-level binding with no type signature: launchMissiles :: IO ()
[2 of 2] Compiling Acme.Missiles.STM ( Acme/Missiles/STM.hs, dist/build/Acme/Missiles/STM.o )
In-place registering acme-missiles-0.3...

Note that during testing, I switched between a cabal-install compiled with Cabal-1.20.0.0 and Cabal-1.20.0.2, and got the error message:

cabal: You need to re-run the 'configure' command. The version of Cabal being
used has changed (was Cabal-1.20.0.0, now Cabal-1.20.0.2). Additionally the
compiler is different (was ghc-7.4, now ghc-7.8) which is probably the cause
of the problem.
ubuntu@picard-precise:~/Desktop/acme-missiles-0.3$ cabal --version
cabal-install version 1.20.0.3
using version 1.20.0.2 of the Cabal library 
@lspitzner
Copy link
Collaborator

I think i can explain this behaviour: There is configure and there is install. Both take a common set of parameters, but they act independently:

  1. Options to configure affect future commands such as build, test, bench, run, repl, but not install
  2. Options to install only affect the current command and are not persisted in any way.

The effect of 2) was displayed above; the effect of 1) can be seen if you first cabal configure --ghc-options="-Wall -Werror" and then plain cabal install, which does not error out, either.

I will not present an opinion if this behaviour is sensible. Regardless, the documentation needs improvement.

Is the behaviour without a sandbox different? I refuse to test that :D

@snoyberg
Copy link
Collaborator Author

Yup, behaves as I would have expected without a sandbox, meaning the subsequent cabal build fails. So while your explanation of the behavior seems to be accurate, it only applies to sandboxed builds.

@lspitzner
Copy link
Collaborator

the Cabal version error seems sensible to me; the configuration data format may change between versions and may be incompatible. And one does not change cabal-install that often, normally..

@lspitzner
Copy link
Collaborator

Ok, interesting; that seems to be inconsistent indeed.

@23Skidoo
Copy link
Member

So this is a duplicate of #2106. cabal build and cabal install in a sandbox use different build directories (see #1281 for the reason why).

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

No branches or pull requests

3 participants