Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project that builds successfully in version 3.6.2.0 fails in version 3.8.1.0: "libcrypto-any, not found in the pkg-config database" #8446

Closed
clintonmead opened this issue Sep 2, 2022 · 14 comments
Labels
resolution: invalid Not an issue (error on the side of the reporter)

Comments

@clintonmead
Copy link

clintonmead commented Sep 2, 2022

Describe the bug
Upon updating cabal from 3.6.2.0 to 3.8.1.0, I get this bizarre error:

[_10] rejecting: HsOpenSSL:-use-pkg-config (constraint from project config
/Users/clinton.mead/source/neph/brt/cabal.project requires opposite flag
selection)
[_10] rejecting: HsOpenSSL:+use-pkg-config (conflict: pkg-config package
libcrypto-any, not found in the pkg-config database)

I am intentionally using the +use-pkg-config flag, with the following in my cabal.project file:

constraints: HsOpenSSL +use-pkg-config

cabal version 3.6.2.0 happily builds though.

To Reproduce
Steps to reproduce the behavior:

$ cabal build all

I'm not sure what difference using v2-build makes, but cabal v2-build all produces the same error.

Expected behavior
The build working like it does for cabal 3.6.2.0

System information

  • MacOS
  • cabal 3.8.1.0
  • GHC 9.2.2

Additional context
As this is propriety software it may be a bit tricky to give you a full reproducible example

@ulysses4ever
Copy link
Collaborator

Thanks for the report! I assume, it's due to #7621 /cc @gbaz.

@clintonmead
Copy link
Author

@ulysses4ever I'm a bit confused, because it looks like #7621 is merged. Did it not make it into 3.8.1.0? Or was 3.6.2.0 doing some hack to get around this? Like was I actually falling back to a non-pkg-config flag and it was just working anyway?

@gbaz
Copy link
Collaborator

gbaz commented Sep 2, 2022

"Before, if there was no pkg-config that could be found, the solver would optimistically succeed"

So it would be due to that if this failure occurs because pkg-config is not present or perhaps finding the package in pkg-config fails due to the name not being exactly correct.

@clintonmead
Copy link
Author

@gbaz I don't know much about pkg-config or even why we're using it in this project (I'm relatively new on this project) but is what you're saying that this our project is broken in some way, and 3.6.2.0 somehow worked around it, whereas 3.8.1.0 is more strict?

@clintonmead
Copy link
Author

Sorry I'm quite dumb. It seems when making this report I accidentally hadn't entered a nix develop shell. I presume this sets up pkg-config appropriately for the build.

I guess 3.6.2.0 worked around this when doing dependency solving but 3.8.1.0 is probably CORRECTLY rejecting the build.

I'm happy to consider this closed.

@ulysses4ever ulysses4ever added resolution: invalid Not an issue (error on the side of the reporter) and removed regression in 3.8 labels Sep 2, 2022
@arrowd
Copy link
Collaborator

arrowd commented Sep 22, 2022

I bumped into similar problem on FreeBSD, except the rejection is incorrect. The error I get is

Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] next goal: gi-atk (user goal)
[__0] rejecting: gi-atk-2.0.24 (conflict: pkg-config package atk>=2.0 && <3,
not found in the pkg-config database)
[__0] fail (backjumping, conflict set: gi-atk)

However, pkg-config --modversion atk gives me 2.38.0. Running the same command with cabal-install 3.6 works too.

Running with -v3 reveals:

/usr/local/bin/pkg-config returned ExitFailure 1 with error message:
Package libevent-2.1.5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent-2.1.5.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libevent-2.1.5', required by 'avahi-libevent', not found
Failed to query pkg-config, Cabal will continue without solving for pkg-config
constraints: dieVerbatim: user error (CallStack (from HasCallStack):
withMetadata, called at src/Distribution/Simple/Utils.hs:370:14 in
Cabal-3.8.1.0-6vwXxyy24tK3US19KEu6L5:Distribution.Simple.Utils
Error: cabal: '/usr/local/bin/pkg-config' exited with an error:
Package libevent-2.1.5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libevent-2.1.5.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libevent-2.1.5', required by 'avahi-libevent', not found
)
Resolving dependencies...
...
[_82] fail (backjumping, conflict set: gi-atk)
CallStack (from HasCallStack):
  withMetadata, called at src/Distribution/Simple/Utils.hs:370:14 in Cabal-3.8.1.0-6vwXxyy24tK3US19KEu6L5:Distribution.Simple.Utils
Error: cabal: Could not resolve dependencies:
[__0] next goal: gi-atk (user goal)
[__0] rejecting: gi-atk-2.0.24 (conflict: pkg-config package atk>=2.0 && <3,
not found in the pkg-config database)

Removing the avahi-app system package makes Cabal happy. So, the outline is:

  • Cabal queries all pkg-config packages currently present in the system.
  • The avahi-app package contains broken .pc file, which is a packaging problem, not Cabal one.
  • This makes Cabal fail even if avahi-libevent.pc isn't required by the Haskell package being built.
  • Cabal will fail on any package containing pkg-config-depends if system has broken .pc files. I'd say this is a bug.

@gbaz
Copy link
Collaborator

gbaz commented Sep 22, 2022

It looks like cabal is trying to find libevent, and the broken avahi-app package prevents it from finding it?

I.e. the broken pc file breaks pkg-config-depends in general?

@arrowd
Copy link
Collaborator

arrowd commented Sep 22, 2022

avahi-libevent.pc has Requires: libevent-2.1.5 line, which hardcodes library version. It works when changed to Requires: libevent.

However, the library I'm building doesn't depend on libevent, nor on avahi. Cabal's error message is about atk and pkg-config return correct results for this package.

The problem is that Cabal somehow queries all pkg-config packages and if one of them is broken it thinks that nothing was found at all.

@arrowd
Copy link
Collaborator

arrowd commented Sep 22, 2022

Another problem with different Haskell package:

/usr/local/bin/pkg-config returned ExitFailure 1 with error message:
Package gtest was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtest.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtest', required by 'libhwy-test', not found
Failed to query pkg-config, Cabal will continue without solving for pkg-config
constraints: dieVerbatim: user error (CallStack (from HasCallStack):
withMetadata, called at src/Distribution/Simple/Utils.hs:370:14 in
Cabal-3.8.1.0-6vwXxyy24tK3US19KEu6L5:Distribution.Simple.Utils
Error: cabal: '/usr/local/bin/pkg-config' exited with an error:
Package gtest was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtest.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtest', required by 'libhwy-test', not found
)

The package doesn't use any of gtest and libhwy-test. It seems there are a lot of malformed .pc files around and Cabal chokes on all of them.

@gbaz
Copy link
Collaborator

gbaz commented Sep 22, 2022

Wait why does the first package succeed when there's still a broken pc for gtest apparently, and only the second package fail?

@arrowd
Copy link
Collaborator

arrowd commented Sep 22, 2022

These are different machines. The first one was building in a clean and isolated environment with only required dependencies installed.

The last one is on my laptop, which also has unrelated stuff installed.

@arrowd
Copy link
Collaborator

arrowd commented Sep 23, 2022

Should this issue be reopened, or it is better to open a new one?

@gbaz
Copy link
Collaborator

gbaz commented Sep 23, 2022

better a new one imho.

@andreasabel
Copy link
Member

In the CI for Agda, we are also seeing regressions when upgrading cabal-install from 3.6.2.0 to 3.8.1.0:
https://github.com/agda/agda/actions/runs/3198492342/jobs/5223079990

Error: cabal: Could not resolve dependencies:
[__0] trying: Agda-2.6.3 (user goal)
[__1] rejecting: Agda:-enable-cluster-counting (constraint from config file,
command line flag, or user target requires opposite flag selection)
[__1] trying: Agda:+enable-cluster-counting
[__2] next goal: text-icu (dependency of Agda +enable-cluster-counting)
[__2] rejecting: text-icu-0.8.0.2, text-icu-0.8.0.1 (conflict: pkg-config
package icu-i18n>=62.1, not found in the pkg-config database)
[__2] rejecting: text-icu-0.8.0 (conflict: pkg-config package icu-i18n-any,
not found in the pkg-config database)

Note that we do set PKG_CONFIG_PATH to point to the icu library (hopefully) before attempting to build text-icu-0.8.*.

I suppose this is a regression introduced by:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution: invalid Not an issue (error on the side of the reporter)
Projects
None yet
Development

No branches or pull requests

5 participants