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

cabal fails to use pkg-config for dependency resolution on linux #9790

Closed
pakanek opened this issue Mar 8, 2024 · 5 comments
Closed

cabal fails to use pkg-config for dependency resolution on linux #9790

pakanek opened this issue Mar 8, 2024 · 5 comments

Comments

@pakanek
Copy link

pakanek commented Mar 8, 2024

Describe the bug
Cabal is unable resolve dependencies because of not being able to use pkg-config.

To Reproduce

$ cabal init bug -n
$ cd bug

add gi-glib >=2.0 && <3.0 to build-depends in cabal file

$ cabal build
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] next goal: bug (user goal)
[__0] rejecting: bug-1.0.1, bug-1 (constraint from user target requires
==0.1.0.0)
[__0] trying: bug-0.1.0.0
[__1] next goal: gi-glib (dependency of bug)
[__1] rejecting: gi-glib-2.0.29, gi-glib-2.0.27, gi-glib-2.0.26,
gi-glib-2.0.25, gi-glib-2.0.24, gi-glib-2.0.23, gi-glib-2.0.22,
gi-glib-2.0.21, gi-glib-2.0.20, gi-glib-2.0.19, gi-glib-2.0.17,
gi-glib-2.0.16, gi-glib-2.0.15, gi-glib-2.0.14, gi-glib-2.0.13,
gi-glib-2.0.12, gi-glib-2.0.11, gi-glib-2.0.10, gi-glib-2.0.9, gi-glib-2.0.8,
gi-glib-2.0.7, gi-glib-2.0.6, gi-glib-2.0.5, gi-glib-2.0.4, gi-glib-2.0.3,
gi-glib-2.0.2, gi-glib-2.0.1 (conflict: pkg-config package glib-2.0-any, not
found in the pkg-config database)
[__1] rejecting: gi-glib-0.2.46.15 (conflict: bug => gi-glib>=2.0 && <=3.0)
[__1] skipping: gi-glib-0.2.46.14, gi-glib-0.2.46.13, gi-glib-0.2.46.12,
gi-glib-0.2.44.12, gi-glib-0.0.2.2, gi-glib-0.0.2.1, gi-glib-0.0.2,
gi-glib-0.2.46.10, gi-glib-0.2.44.11, gi-glib-0.2.44.10, gi-glib-0.2.44.9,
gi-glib-0.2.44.8 (has the same characteristics that caused the previous
version to fail: excluded by constraint '>=2.0 && <=3.0' from 'bug')
[__1] fail (backjumping, conflict set: bug, gi-glib)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: gi-glib, bug

Expected behavior
Use pkg-config provided by the OS.

System information

  • Linux, Fedora 39
  • cabal-install version 3.10.1.0
  • compiled using version 3.10.1.0 of the Cabal library
  • The Glorious Glasgow Haskell Compilation System, version 9.8.1

Additional context
By default Fedora has package glib-2.0, so I thought maybe creating symlink named glib-2.0-any would help, but it did not.

$ pkg-config --libs --cflags glib-2.0-any
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-6 -pthread -lglib-2.0
$ ls -l /usr/lib64/pkgconfig/glib-2.0-any.pc 
lrwxrwxrwx. 1 root root 11 Mar  8 22:50 /usr/lib64/pkgconfig/glib-2.0-any.pc -> glib-2.0.pc
$ pkg-config --list-all | grep glib-2.0
glib-2.0                       GLib - C Utility Library
glib-2.0-any                   GLib - C Utility Library
@geekosaur
Copy link
Collaborator

3.10.1.0 is a bit old. Additionally, there are buggy versions of pkg-config around that cabal was only recently taught to work around (see for example #9609 and #9391).

@pakanek
Copy link
Author

pakanek commented Mar 8, 2024

Latest version I can get from ghcup is 3.10.2.1 which has exact same problem.

$ cabal build
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] next goal: bug (user goal)
[__0] rejecting: bug-1.0.1, bug-1 (constraint from user target requires
==0.1.0.0)
[__0] trying: bug-0.1.0.0
[__1] next goal: gi-glib (dependency of bug)
[__1] rejecting: gi-glib-2.0.29, gi-glib-2.0.27, gi-glib-2.0.26,
gi-glib-2.0.25, gi-glib-2.0.24, gi-glib-2.0.23, gi-glib-2.0.22,
gi-glib-2.0.21, gi-glib-2.0.20, gi-glib-2.0.19, gi-glib-2.0.17,
gi-glib-2.0.16, gi-glib-2.0.15, gi-glib-2.0.14, gi-glib-2.0.13,
gi-glib-2.0.12, gi-glib-2.0.11, gi-glib-2.0.10, gi-glib-2.0.9, gi-glib-2.0.8,
gi-glib-2.0.7, gi-glib-2.0.6, gi-glib-2.0.5, gi-glib-2.0.4, gi-glib-2.0.3,
gi-glib-2.0.2, gi-glib-2.0.1 (conflict: pkg-config package glib-2.0-any, not
found in the pkg-config database)
[__1] rejecting: gi-glib-0.2.46.15 (conflict: bug => gi-glib>=2.0 && <3.0)
[__1] skipping: gi-glib-0.2.46.14, gi-glib-0.2.46.13, gi-glib-0.2.46.12,
gi-glib-0.2.44.12, gi-glib-0.0.2.2, gi-glib-0.0.2.1, gi-glib-0.0.2,
gi-glib-0.2.46.10, gi-glib-0.2.44.11, gi-glib-0.2.44.10, gi-glib-0.2.44.9,
gi-glib-0.2.44.8 (has the same characteristics that caused the previous
version to fail: excluded by constraint '>=2.0 && <3.0' from 'bug')
[__1] fail (backjumping, conflict set: bug, gi-glib)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: gi-glib, bug

$ cabal --version
cabal-install version 3.10.2.1
compiled using version 3.10.2.1 of the Cabal library 

@geekosaur
Copy link
Collaborator

You can get the current development version with

ghcup install cabal --force -u https://github.com/haskell/cabal/releases/download/cabal-head/cabal-head-Linux-x86_64.tar.gz head

None of the two PRs I pointed to (or a third I skipped) is in 3.10.2.1 either; they're all within the past 2 months. Unfortunately, so is distributions updating to pkg-config 1.9 which has the bugs.

@pakanek
Copy link
Author

pakanek commented Mar 8, 2024

Ok, it seems to be fixed on version 3.11.0.0 even if I remove symbolic link I created previously. Thank you for your help.

@pakanek pakanek closed this as completed Mar 8, 2024
@geekosaur
Copy link
Collaborator

These fixes will be in 3.10.3, for which we've begun the release cycle, so hopefully they'll be out soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants