-
Notifications
You must be signed in to change notification settings - Fork 696
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
Inconsistent 'freeze' behaviour #1896
Comments
Paging @benarmston. |
The only part of snap that has a dependency on $ cabal sandbox hc-pkg -- unregister snap
$ cabal freeze
Resolving dependencies...
$ mv cabal.config cabal.config.unregistered
$ diff -u cabal.config.before cabal.config.unregistered (Just to be clear, the diff command provides no output.) Running freeze with the If my understanding is correct, this is related to #779 and will be fixed when that is. @tibbe does my understanding here and of #779 sound reasonable. |
@benarmston I'm a bit unfamiliar with this part of cabal. Are you saying that once cabal installs an executable it will omit its deps in the future? I thought that ghc-pkg, and thus cabal, doesn't track installed executables and thus it's a bit confusing if cabal somehow knows that executables are installed! A more general point: do we want freeze to take currently installed packages (e.g. the sandbox package DB) when computing the install plan to freeze? On one hand that seems useful; you can test the setup before freezing it. On the other hand it might lead to issues like this, were freeze works differently depending on the state of the sandbox package DB (which is supposed to be an implementation detail). |
@benarmston: As I understand, #779 is the issue where listing executable-only packages in |
@tibbe: Consider a working application which does not constrain the version numbers of its dependencies in its I think a |
Same test as above, but with
|
With cabal versions prior to 1.7.1 the build-depends of any executable stanzas are included in the build depends which are registered with ghc-pkg. Cabal's resolver therefore has a complete set of build-depends when it selects the installed version of foo. `./test.sh` does not exhibit the bug described in haskell/cabal#1896.
With cabal version's greater than or equal to 1.7.1 the build-depends of any executable stanzas are not included in the build-depends registered with ghc-pkg. This causes `./test.sh` to exhibit the bug in haskell/cabal#1896.
If the library stanza is removed the package is not registered with ghc-pkg. This prevents the cabal's resolver from using the incomplete set of build-depends that ghc-pkg knows about. `./test.sh` no longer exhibits the bug described in haskell/cabal#1896.
With cabal versions prior to 1.7.1 the build-depends of any executable stanzas are included in the build depends which are registered with ghc-pkg. Cabal's resolver therefore has a complete set of build-depends when it selects the installed version of foo. `./test.sh` does not exhibit the bug described in haskell/cabal#1896.
With cabal version's greater than or equal to 1.7.1 the build-depends of any executable stanzas are not included in the build-depends registered with ghc-pkg. This causes `./test.sh` to exhibit the bug in haskell/cabal#1896.
If the library stanza is removed the package is not registered with ghc-pkg. This prevents the cabal's resolver from using the incomplete set of build-depends that ghc-pkg knows about. `./test.sh` no longer exhibits the bug described in haskell/cabal#1896.
@tibbe that's more or less what I'm telling you. When cabal installs a package, say foo, it registers the package's library (if any) with ghc-pkg. But the information which is registered doesn't contain any details about foo's executables. When cabal's resolver selects the installed version of foo, it queries ghc-pkg to find out what build-depends foo was compiled against. That list contains the build-depends for foo's library but not any build-depends for any of foo's executables. In the test program provided by @mietek the only dependency on My first reply on this ticket unregistered the snap package with ghc-pkg, thereby preventing cabal's resolver from selecting the installed version of snap. This caused cabal's resolver to consider the source package for snap and in doing so was able to determine the build-depends on all executables in the snap package. @mietek I think that this issue and #779 are somewhat related. However, when I referenced #779 I had not understood that the proposed solution was to prevent adding non-lib packages to build-depends. Given that proposal my reference was probably more noise than signal. Whilst trying to better understand what was happening I reduced @mietek's example to a much smaller case. It is on github at https://github.com/benarmston/cabal-issue-1896/. That repo contains a Tag Tag Tag The reason for The changes between the tags can be seen at benarmston/cabal-issue-1896@cabal-1.7.0...cabal-1.7.1 and benarmston/cabal-issue-1896@cabal-1.7.1...no-lib Whilst my understanding of the cause of this bug may be correct. I'm really not sure what the solution to it might be. DISCLAIMER: My understanding of the process I've described above has been gained by trial and error whilst trying to understand this ticket. It hasn't been gained through an understanding of the resolver code. There could well be subtleties that I'm missing. |
As an aside, to be clear on why I think this ticket and #779 are somewhat related. For #779: cabal installs the non-lib package and doesn't register that it has been installed (because there is not a library to register with ghc-pkg). As the package has not been registered, its build-depends are not registered. For this ticket: cabal installs the lib+exe package and registers the lib with ghc-pkg. The exe is not registered and in particular its build-depends are not registered. I had wrongly assumed that the solution to #779 would be to register the non-lib package somewhere. If that had been the case, we could have used that registry to include any executables within lib+exe packages including the build-depends. In which case #779 and this ticket would have had the same solution. But my assumption was wrong. |
@tibbe if freeze doesn't take installed packages into account could it not select different flags for some packages than were selected when installing them (particularly if the user provided certain flags when installing). If it can do that, could this not result in freezing an install plan which won't actually build in the current sandbox? Or would warn about dangerous reinstalls? If not taking the installed packages into account is the preferred method, I think we'd have to be careful not to present unhelpful (and perhaps scarry) messages to users. |
Here's the usage pattern I'm imagining:
What if a user now runs |
@tibbe: I agree. |
The other possible usage pattern is — once the user has his app's dependencies explicitly declared in a |
To bump your dependencies I'd expect the user to either
It's also possible to remove cabal.config (which should be tracked in source control) altogether, re-run freeze, and then use a diff tool to pick some changes and revert some. Note that the user needs to re-run |
Could the resolver always look at the source version of a package in order to determine dependencies, even if an installed version is selected? Paging @dcoutts. |
Just was pinged by this thread again, assuming because of a recent comment. I'm somewhat late to the party, but I just wanted to note the bit about:
note: transformers-compat ships 3 versions 0.3.3.2, 0.3.3.3, and 0.3.3.4, which all are basically the same package with different flags set up to work around the backtracker for cabal. Not sure if that is useful data, but it may explain why you get weird behavior around that package compared to others. |
it would be good to check if new-freeze has this issue, and if not, we can eventually obsolete this |
A
cabal freeze
done before installing dependencies gives a different result than acabal freeze
done after installing dependencies.The difference is that a globally installed package is included in the first result, and is not included in the second result.
To reproduce, start with either
ghc-7.6.3
orghc-7.8.2
, andcabal-install-1.20.0.1
orcabal-install-1.20.0.2
:The result with
ghc-7.6.3
:The result with
ghc-7.8.2
:The text was updated successfully, but these errors were encountered: