I'm fairly new to Haskell, and upon seeing this flag, e.g. in this dockerfile, I can't ever seem to find an explanation for what it does. "Install only the dependencies necessary to build the given packages," in the cabal help install doesn't say much to me.
If I'm not building inside a docker container, I use sandboxes. Is this flag applicable to either of these situations?
For cabal, what does only-dependencies flag mean?
It can be spelled as both --dependencies-only and --only-dependencies and it simply means that it will install all, and only, the dependencies the specific package requires (without installing or building the packages themselves). Note that by default tests and benchmark dependencies will not be installed; for them you need to add --enable-tests and --enable-benchmarks respectively.
Is this flag applicable to either of these situations?
Yes, this can be used just fine with cabal sandboxes as well as without.
What's then the difference between it and simply running cabal install, which has worked for me so far?
cabal install will install both those dependencies and the packages themselves. Same for cabal build. cabal install --only-dependencies will only install the dependencies those packages require.
Related
The commands install, v1-install, v2-install and new-install are simply described to "Install packages" when running man cabal. Are they different from one another? Which is the preferred option?
For modern versions of cabal-install, install, new-install and v2-install are the same. v1-install and the other v1- commands are obsolete and should not be used anymore.
Notice that, when developing a cabal package, the install command is largely unnecessary. Running cabal build and cabal repl will automatically install the required dependencies (listed in the build-depends: section of the cabal file).
cabal install is still useful in cases like the following:
Installing an executable from a package. Like the warp executable from the package wai-app-static. In those cases, the options --overwrite-policy, --install-method and --installdir are useful.
Creating a local package environment in some folder, so that "bare" invocations of ghc and ghci see some desired set of libraries. Like this. In those cases, the options --lib and --package-env are useful.
I have an application in a sandbox. Cabal dependencies have no constraints so cabal install --only-dependencies gives me the latest packages.
After a certain period of time I want to bump my dependencies to the latest versions but before this I want to see which dependencies are actually changed to a newer version.
I can check all of them manually of course. But I'd rather see a nice list of the things that will be upgraded.
I assume that cabal install --upgrade-dependencies --only-dependencies --dry-run is the way to do it. I would expect it to give me the list of all the packages that are at newer version that the one in my sandbox. But it never works! I mean, it just says that all dependencies are up to date when they are clearly not. Am I doing something wrong or missing/misunderstanding something?
If I destroy my sandbox completely, rerun cabal install --only-dependencies and diff the freeze files then I can see which packages got bumped. But this is silly. So how can I get cabal install --upgrade-dependencies --only-dependencies --dry-run to work correctly and print all the packages that are going to be upgraded without blowing the sandbox? Ad if those options do not work in cabal why aren't they just removed to avoid confusion?
Thank you.
You can use cabal list --installed and compare "Default available version" with "Installed versions".
Unfortunately cabal's --simple-output switch does not include that information, so to automate it you will need a smallish script.
I'm in situation where I cannot install new package without reinstalling others (my distribution comes without sandbox).
Is it possible to determine which version of each package I should use so that there will be no conflicts with new one included?
How can I encode this set to create new cabal sandbox?
cabal install --dry-run --avoid-reinstalls should give you some output that indicates the installation plan for a particular package, or fail if it cannot avoid reinstalls due to dependencies.
However, sandboxes are really quite helpful. Independent of how you bootstrap your cabal installation (tarballs, distribution packages, etc.), you should probably add ~/.cabal/bin early in your path and then cabal install cabal-install. This should only fail if the latest version of cabal doesn't work on your version of ghc / base.
I am having an issue with building a shared library with ghc and I think I need to rebuild my haskell packages with --enable-shared, is there an easy way to rebuild all of my packages with cabal with the flag --enable-shared?
If you have a ~/.cabal/world, cabal install --reinstall --enable-shared world could work, but test with the --dry-run flag first. That will, however only take care of cabal-installed packages. If you have packages installed with your distro's package manager, the distro might also provide shared versions for those (otherwise, you'd have to do it manually). Also, it would probably be helpful to set shared: True in ~/.cabal/config.
I'm trying to set up Haskell from scratch, on Ubuntu 11.04, without using the outdated Debian repository or Haskell-Platform.
I've installed GHC-7.0.4 from source with no problem, and now need to install Cabal (which appears to already be included in GHC in /usr/local/lib/ghc-7.0.4/Cabal-1.10.2.0) and Cabal Install.
The latter specifies several dependencies (parsec and network), each of which has several dependencies of their own (mtl, text, etc).
What's the command to install these packages, that I downloaded from hackage in tar.gz form?
Unpack, then runhaskell doesn't work.
I see Setup.lhs, but it's not clear what that's for or how to use it.
Most of the Haskell documentation I've found assumes you've installed from a repo or Haskell-Package and doesn't really explain this well.
cabal-install has a shell script that does this. If you download it from hackage and install it, you can start bootstrap.sh to install cabal-install. You can then use it to install other packages.
There are two different packages: Cabal and cabal-install. Cabal is a library, and cabal-install is an executable named cabal.
To install a package, cabal-install is an optional convenience wrapper around Cabal, but Cabal is required.
According to http://hackage.haskell.org/trac/ghc/wiki/Commentary/Libraries , Cabal is a 'zero-boot' package, so when you build GHC, Cabal and its dependencies are built for you automatically.
You can use ghc-pkg executable to check which packages are already installed:
# ghc-pkg list
Check if Cabal is in the list after you build GHC. If yes, you can install more packages without cabal-install using this documentation:
http://haskell.org/haskellwiki/Cabal/How_to_install_a_Cabal_package
I suggest you to install cabal-install first, and then install everything else using cabal-install executable. A usual commandine for global installation is this:
# runhaskell Setup configure
# runhaskell Setup build
# sudo runhaskell Setup install
Unpack a package tarball and run the commands in the folder with Setup.hs or Setup.lhs files. Note that a per-user non-root installation is also supported - Use runhaskell Setup configure --user
When you install cabal executable and its dependencies this way, use cabal install {package-name} to install more packages.
Note that Haskell Platform exists mostly because of the pain of installing cabal-install by yourself.