cabal icon indicating copy to clipboard operation
cabal copied to clipboard

v1-install fails with internal libraries

Open andreasabel opened this issue 2 years ago • 1 comments

Lifted from:

  • https://github.com/haskell/hackage-server/issues/1173

cabal v1-install chokes on the hackage-cli executable in the linking phase. @gbaz suspects it is because hackage-cli defines an internal library (cabal-revisions):

$ cabal get hackage-cli-0.1.0.0
$ cd hackage-cli-0.1.0.0
$ cabal v1-install -w ghc-9.4.4
...
Building library 'cabal-revisions' for hackage-cli-0.1.0.0..
...
Building executable 'hackage-cli' for hackage-cli-0.1.0.0..
...
[5 of 5] Linking dist/build/hackage-cli/hackage-cli
Installing internal library cabal-revisions in /Users/abel/.cabal/lib/x86_64-osx-ghc-9.4.4/hackage-cli-0.1.0.0-Dk3ZdfpjcyF4Z0aP4NlJOe
Installing executable hackage-cli in /Users/abel/.cabal/bin
Failed to install hackage-cli-0.1.0.0
Error: cabal: Some packages failed to install:
hackage-cli-0.1.0.0-Dk3ZdfpjcyF4Z0aP4NlJOe failed during the final install
step. The exception was:
dieVerbatim: user error (Error: cabal: '/usr/local/bin/ghc-pkg-9.4.4' exited
with an error:
z-hackage-cli-z-cabal-revisions-0.1.0.0: Warning: haddock-interfaces:
/Users/abel/.cabal/share/doc/x86_64-osx-ghc-9.4.4/hackage-cli-0.1.0.0/html/hackage-cli.haddock
doesn't exist or isn't a file
z-hackage-cli-z-cabal-revisions-0.1.0.0: Warning: haddock-html:
/Users/abel/.cabal/share/doc/x86_64-osx-ghc-9.4.4/hackage-cli-0.1.0.0/html
doesn't exist or isn't a directory
z-hackage-cli-z-cabal-revisions-0.1.0.0: installed package info from too old
version of Cabal (key field does not match id field)
)

The last line of the error "installed package info from too old version of <PKG> (key field does not match id field)" is also present in this issue:

  • #4668

andreasabel avatar Feb 04 '23 11:02 andreasabel

This issue is maybe more relevant as cabal v1-install happy fails now (since happy-2.0).

  • https://github.com/haskell/happy/issues/315

The error message is quite hermetic:

$ cabal v1-install happy
...
Completed    happy-lib-2.0.2
...
Building executable 'happy' for happy-2.0.2...
[1 of 2] Compiling Paths_happy      ( dist/build/happy/autogen/Paths_happy.hs, dist/build/happy/happy-tmp/Paths_happy.o )
[2 of 2] Compiling Main             ( app/Main.lhs, dist/build/happy/happy-tmp/Main.o )
/Users/abel/.cabal/lib/x86_64-osx-ghc-9.10.1-2e29/happy-lib-2.0.2-15p6rBDzTdm9pd5BXGUD6u/Happy/Backend/LALR.hi
Declaration for lalrBackendDataDir
Unfolding of lalrBackendDataDir:
  getDataDir1 ErrorWithoutFlag
                Something is amiss; requested module  happy-lib-2.0.2-15p6rBDzTdm9pd5BXGUD6u-backend-lalr:Paths_happy_lib differs from name found in the interface file happy-lib-2.0.2-15p6rBDzTdm9pd5BXGUD6u-backend-glr:Paths_happy_lib (if these names look the same, try again with -dppr-debug)
<no location info>: error:
    Cannot continue after interface file error

The least that should happen for this issue is a proper error like "v1-install not supported for package with internal libraries".

andreasabel avatar Sep 25 '24 17:09 andreasabel

This issue presumably came up again in https://github.com/haskell/happy/issues/328, which wants to use Setup.hs for packaging happy in Arch. It appears that this issue is a blocker for anyone wanting to package binaries of haskell libraries with private sub-libraries.

sgraf812 avatar Dec 04 '24 16:12 sgraf812

During packaging of happy-lib, it seems that Cabals Setup copy command doesn't copy correctly when specifying --libsubdir in the Setup configure step and writes the Paths_happy_lib file to the wrong location. This happens for both, so the second one overwrites the first.

To reproduce the issue, setting --libsubdir to any value produces the invalid artifact. Not specifying it doesn't exhibit this issue. After running the copy command with --verbose (and including other debug info like the directory structure), I got the below attached log.

Log

with --libsubdir=\$compiler/site-local/\$pkgid

without --libsubdir

Vekhir avatar Dec 27 '24 01:12 Vekhir

It is likely that this issue is a consequence of #10687. I found a workaround to #10687 and released happy 2.1.4 with it, now cabal v1-install happy works again.

sgraf812 avatar Jan 18 '25 16:01 sgraf812

now cabal v1-install happy works again.

It does so with cabal-3.12.1.0. But it fails with cabal-3.14.1.1, so this might be a new regression:

$ cabal v1-install happy 
Resolving dependencies...
Error: [Cabal-7654]
No cabal file found.
Please create a package description file <pkgname>.cabal

Failed to install happy-lib-2.1.4
Error: [Cabal-7140]
Some packages failed to install:
happy-2.1.4-FEt88s8bYtb4jlboxNtUeZ depends on happy-2.1.4 which failed to install.
happy-lib-2.1.4-1UOKRLhw4Nh6fWsmrPkI7e failed during the configure step. The exception was:
  ExitFailure 1

andreasabel avatar Jan 19 '25 09:01 andreasabel