How to keep cabal and ghci package versions in sync?

Hi all,
I have a project with a .cabal file listing package dependencies using
the usual version constraints ==X.Y.*

On Sun, Apr 24, 2011 at 11:13 AM, Gracjan Polak
I have a project with a .cabal file listing package dependencies using the usual version constraints ==X.Y.*
=K.J syntax. Standard route cabal configure; cabal build works correctly as it is able to select working set of package versions. I have also a .ghci file. When I run GHCi it uses all latest installed packages in the system. This prevents the project from loading.
I tried to use 'cabal-dev ghci', but this still selects latest global packages.
This should only arise for the base ghc packages, which are tied closely enough to ghc that you should probably switch ghc versions if you want to work with different versions of those core packages. If you're installing additional packages globally, my only advice is: Beware, there be dragons! I strongly recommend that you ghc-pkg unregister all the non-essential packages from your global package db because: (1) cabal-dev will not bring you any benefit. (2) you will eventually run into ugly unsatisfiable dependency issues between your local and global package databases. (3) you may inadvertently cause a base package to be upgraded, which is somewhat easier to fix if it's installed to a local package db. cabal-dev ghci should be able to do what you want, but it has no control over the global db. I'd be happy to send you a list of the packages that ghc comes with, if you choose to unregister packages from the global db (assuming you're using one of the OS/arch/ghc combinations I have available :) --Rogan
So, how to I load up ghci with the same package versions as selected by cabal?
Thanks!
-- Gracjan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 24 April 2011 22:27, Rogan Creswick
I have a project with a .cabal file listing package dependencies using the usual version constraints ==X.Y.*
=K.J syntax. Standard route cabal configure; cabal build works correctly as it is able to select working set of package versions. I have also a .ghci file. When I run GHCi it uses all latest installed
in the system. This prevents the project from loading.
I tried to use 'cabal-dev ghci', but this still selects latest global
On Sun, Apr 24, 2011 at 11:13 AM, Gracjan Polak
wrote: packages packages. This should only arise for the base ghc packages, which are tied closely enough to ghc that you should probably switch ghc versions if you want to work with different versions of those core packages.
If you're installing additional packages globally, my only advice is: Beware, there be dragons! I strongly recommend that you ghc-pkg unregister all the non-essential packages from your global package db because:
I'll second this; I had the same problem and just uninstalled the global package and went ahead and uninstalled them all, no problems since. All my projects are under cabal-dev so it's not a problem.

Gracjan Polak schrieb:
Hi all,
I have a project with a .cabal file listing package dependencies using the usual version constraints ==X.Y.*
=K.J syntax. Standard route cabal configure; cabal build works correctly as it is able to select working set of package versions.
You can manually select packages for GHCi with '-package' option. However I do not know a way to automatically syncronise this with the dependencies from the Cabal file.

Henning Thielemann
You can manually select packages for GHCi with '-package' option. However I do not know a way to automatically syncronise this with the dependencies from the Cabal file.
I kind of expected 'cabal-dev ghci' to do this for me. Thanks for help, I'm cleaning my packages for now. -- Gracjan

On Tue, Apr 26, 2011 at 2:10 AM, Gracjan Polak
I kind of expected 'cabal-dev ghci' to do this for me.
At the moment, cabal-dev ghci just uses the -package-conf and -no-user-package-conf flags to restrict ghci to the sandboxed and global package dbs. It's difficult to do more without parsing the content of the project's cabal file, and that parser isn't exposed through a library api (it's in cabal-install), which makes it a little difficult to use. --Rogan

On 27/04/2011, at 3:04 AM, Rogan Creswick wrote:
At the moment, cabal-dev ghci just uses the -package-conf and -no-user-package-conf flags to restrict ghci to the sandboxed and global package dbs.
It's difficult to do more without parsing the content of the project's cabal file, and that parser isn't exposed through a library api (it's in cabal-install), which makes it a little difficult to use.
Can't you use cabal as a library to do this? I had a crack at figuring out a ghci command line in TBC (testing by convention): https://github.com/peteg/TBC while waiting for this cabal feature to be implemented: http://hackage.haskell.org/trac/hackage/ticket/382 Apparently there's a GSoC project that will nail this. You can fire up TBC with the verbose flag and it will give you a very long ghc invocation line that is strongly similar to what cabal uses to compile your project. It doubtlessly is incomplete, and probably bit rotten. I will try to make it work with the latest Haskell Platform release in the coming weeks. I welcome patches, but you're better off fixing cabal itself. cheers peter -- http://peteg.org/

Rogan Creswick schrieb:
On Tue, Apr 26, 2011 at 2:10 AM, Gracjan Polak
wrote: I kind of expected 'cabal-dev ghci' to do this for me.
At the moment, cabal-dev ghci just uses the -package-conf and -no-user-package-conf flags to restrict ghci to the sandboxed and global package dbs.
It's difficult to do more without parsing the content of the project's cabal file, and that parser isn't exposed through a library api (it's in cabal-install), which makes it a little difficult to use.
Cabal exposes functions for reading and writing package description files: http://hackage.haskell.org/packages/archive/Cabal/1.10.1.0/doc/html/Distribu... Or what do you mean?
participants (5)
-
Christopher Done
-
Gracjan Polak
-
Henning Thielemann
-
Peter Gammie
-
Rogan Creswick