Cabal: Cannot install library dependencies

Created on 18 Sep 2019  路  5Comments  路  Source: haskell/cabal

Describe the bug
I can't seem to globally install the dependencies of a local package.

To Reproduce
Navigate to the root directory of a cabalized package and run cabal install --only-dependencies. Witness the following error:

cabal: Cannot build the executables in the package units because it does not
contain any executables. Check the .cabal file for the package and make sure
that it properly declares the components that you expect.

I know there are no executables. I want the libraries installed into my global package database, just like happened with previous versions of cabal.

Expected behavior
I want the dependencies of my package to be installed in my global package database, so that when I run ghci, from any directory on my system, I can access them.

System informataion

  • cabal version 3.0.0.0

Additional context
Perhaps I am misusing cabal, but trying to educate myself hit #6245. Some background may be in #5650, which also describes why I care about the global database.

Most helpful comment

Please fix this as soon as possible, as it is a major usability issue. The Cabal 3.0.0.0 (and later) documentation clearly states that "cabal install [PACKAGE]" is the way to install a package, for example here: https://www.haskell.org/cabal/users-guide/installing-packages.html#building-and-installing-packages

It does not mention the existence of any --lib option at all. And most packages that I have ever installed are libraries, so why would the default be to expect executables in a package that doesn't contain them?

It looks to me like the documentation that claims to be for Cabal 3.0.0.0 is in fact for Cabal 2, as it contains many other instructions that don't work with Cabal 3.0.0.0 (e.g., "cabal sandbox init", which gives an "unrecognised command" error, or "cabal install package-0.0.0.0.tar.gz", which gives an "Invalid package ID" error.

Incidentally, where is the actual documentation for Cabal 3.0.0.0 located? Thanks!

All 5 comments

Aha. I needed to pass --lib. Perhaps the error message should suggest this? In any case, I've gotten past this barrier.

Duplicate of #6237 (pinging @typedrat again)

I鈥檒l look at it on the other issue.

Please fix this as soon as possible, as it is a major usability issue. The Cabal 3.0.0.0 (and later) documentation clearly states that "cabal install [PACKAGE]" is the way to install a package, for example here: https://www.haskell.org/cabal/users-guide/installing-packages.html#building-and-installing-packages

It does not mention the existence of any --lib option at all. And most packages that I have ever installed are libraries, so why would the default be to expect executables in a package that doesn't contain them?

It looks to me like the documentation that claims to be for Cabal 3.0.0.0 is in fact for Cabal 2, as it contains many other instructions that don't work with Cabal 3.0.0.0 (e.g., "cabal sandbox init", which gives an "unrecognised command" error, or "cabal install package-0.0.0.0.tar.gz", which gives an "Invalid package ID" error.

Incidentally, where is the actual documentation for Cabal 3.0.0.0 located? Thanks!

I had to find this thread to understand why I could not install packages. Running cabal install I get:

Resolving dependencies...
cabal: Cannot build the executables in the package HDBC because none of the
components are available to build: the executable 'runtests' is marked as
'buildable: False'

Adding "--lib" does fix the issue. Please update wikis and docs

Was this page helpful?
0 / 5 - 0 ratings