Cabal fetch dependencies for current package - haskell

I wrote a package that I am trying to build. For reasons, I do not want to install it on my laptop. I want to download all of its dependencies and install it on another computer. How can I do that? If I run
$ cd my-package
$ cabal fetch .
cabal says no packages requested. If I do
$ cabal fetch my-package.cabal
it does read the cabal file, but then it actually tries to download packages that don't exist on hackage, but are in my sandbox.

You could try this:
cabal fetch `cabal install --dependencies-only --dry-run | sed 1,2d`
You might want to do it in a fresh sandbox so it doesn't skip dependencies that are already installed.
Aren't *nix tools great?

Related

Let Cabal-Install show the install plan

If I install a package using cabal install pkg then cabal will install all packages that pkg depends on. If there is a conflict with already installed packages then cabal shows which packages have to be installed freshly, which ones are updated and which installed ones will be broken.
Is there a way to get this list unconditionally instead of running the install procedure?
cabal install <pkg> --dry-run will print the packages that will be installed without actually performing any of the installation. It will not show this information though if the package is installed or similar.

How to manually install package to a project that uses cabal

I was hoping to use a library that is on Hackage. But it turns out that the maintainer of the package has abandoned the library for some time and now it's not compiling due to minor problems. Now that I fixed the problems, what is the best way to link it with my cabal project until my PR is merged into the upstream
To install it like "cabal install ..." would install it, try this:
Use "cabal get pkgname-X.Y.Z" to get the source from Hackage; it places the source in the directory pkgname-X.Y.Z
cd into the source directory and apply your patches
Run cabal install
There are other options if you are using stack or cabal sandboxes.

Cabal install reports package as installed, but Setup configure reports it as missing

I am using ghc-7.6.3 with cabal-install version 1.18.0.5 using version 1.18.1.3 of the Cabal library. My operating system is Debian Wheezy 7.5.
I have a fresh cabal install, and that I have removed the .ghc from my home directory.
After that I have changed the cabal config file and set:
remote-repo: stackage-nightly-2014-12-15:http://www.stackage.org/snapshot/nightly-2014-12-15
After that I did (following this documentation)
$ cabal update
$ cabal install alex happy yesod-bin
and the build complained that it cannot build package system-filepath-0.4.12.
So, I am trying to build package system-filepath-0.4.12 manually. After unpacking the archive, I cd-ed to the unpacked folder and entered:
$ ghc -o Setup Setup.hs
$ ./Setup configure
which gives:
Configuring system-filepath-0.4.12...
Setup: At least the following dependencies are missing:
text >=0.7.1
But
$ cabal install text
gives:
Resolving dependencies...
All the requested packages are already installed:
text-1.1.1.3
Use --reinstall if you want to reinstall anyway.
How is it possible that a package is reported as installed and missing at the same time?
Should I look for a more stable remote-repo configuration, is there something I can check that might fix the missing text package? Note that I am not using a sandbox.
EDIT
Thanks for pointing out that there are two package databases.
I have now tried both
$ cabal configure
$ cabal build
and
$ Setup configure --user
$ Setup build
Both give no error during configuration, but give the following error during the build phase:
Building system-filepath-0.4.12...
Preprocessing library system-filepath-0.4.12...
/usr/bin/ld: cannot find -lHStext-1.1.1.3-ghc7.8.3
collect2: error: ld returned 1 exit status
Try this instead
cd system-filepath--0.4.12
cabal configure
I am not sure why, but this works for me, whereas Setup.hs gave me the same error (truth be told, I always do it the cabal configure way, and am not sure if your way should also work).
There are (at least) two package databases: a global one available to all users, and a user-specific one. By default, Setup.hs looks in (and installs to) the global one, and cabal-install looks in (and installs to) the user-specific one. You can manually choose one or the other with --user and --global; so, you could fix this either by using
./Setup configure --user
or by
cabal install text --global
You can see the current state of the package databases with ghc-pkg, which will report information about both by default.

How do I install my own package-candidate with cabal?

I've just created a new cabal package (http://hackage.haskell.org/package/json-python-0.1.0.0/candidate). I'd like to test it on a separate computer before publishing. Running cabal install json-python fails to find the candidate, which makes sense. Is there a way to tell cabal to target candidates, or a specific url of the tarball? Otherwise, is the best way to install the package to wget the tarball url from my other computer, run tar xf, and then cabal install from the local package? It would be great if someone could add some of this information to the otherwise nice introduction at http://hackage.haskell.org/upload.
These days you can use cabal.project and specify a remote tarball, e.g.
packages:
.
http://hackage.haskell.org/package/json-python-0.1.0.0/candidate/json-python-0.1.0.0.tar.gz

How do you install packages/libraries without Cabal or Cabal-Install?

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.

Resources