pkg-config uses a more general version scheme #163

bos opened this Issue May 24, 2012 · 12 comments


None yet

bos commented May 24, 2012

(Imported from Trac #170, reported by @dcoutts on 2007-11-05)

From HsOpenSSL.cabal

  --PkgConfig-Depends: openssl >= 0.9.7l
  -- We really should use this instead of the configure
  -- script but Cabal can't handle the weird version
  -- scheme of OpenSSL.
For example:
$ pkg-config --modversion openssl
Currently Cabal tries to map pkg-config versions to the standard Version type which only allows for a sequence of numbers.

pkg-config uses just strings to represent package versions. It uses code lifted from rpm to compare version strings. See the compare_versions function in pkg-gconfig-0.22/pkg.c from


bos commented May 24, 2012

(Imported comment by @dcoutts on 2007-11-05)

A possibly-better reference for the rpm version string comparison code:


bos commented May 24, 2012

(Imported comment by guest on 2008-01-26)

I got

$ cabal install
Resolving dependencies...
Configuring alsa-core-
cabal: parsing output of pkg-config --modversion failed
cabal: Error: some packages failed to install:
alsa-core- failed during the configure step. The exception was:
ExitFailure 1
$ pkg-config --modversion alsa
I remember that Cabal had functions for parsing version numbers with tags, would this help here?

Newer ALSA versions do not seem to have the version tag anymore.


bos commented May 24, 2012

(Imported comment by guest on 2011-03-05)

How about using pkg-config's --atleast-version option? Then Cabal does not need to parse the version number at all.


bos commented May 24, 2012

(Imported comment by @dcoutts on 2011-03-05)

We do need to parse the version because people can use arbitrarily complicated version constraints, not just ">= x.y". I think we just need to do it properly and have pkg-config versions use a different type internally than Version, and use different version comparison code.


tibbe commented May 5, 2014

Closing as there's been no activity in years.

We're cleaning up the bug tracker to make it useful again and are thus closing bugs that haven't seen any activity in a long time. Please re-open (or file a new bug) if the problem reappears.

@tibbe tibbe closed this May 5, 2014


mietek commented Jul 30, 2014

This is still an issue.

With pkgconfig-depends: openssl, Cabal fails as follows:

$ cabal build
Resolving dependencies...
Configuring foo-0.0.1...
cabal: parsing output of pkg-config --modversion failed

This is due to the openssl version number format:

$ pkg-config --modversion openssl

@dcoutts dcoutts reopened this Jul 30, 2014

@ttuegel ttuegel added this to the _|_ milestone Apr 23, 2015


BardurArantsson commented Jun 25, 2015

@mietek Do you have the ability and/or inclination to help with fixing this issue? If you're keen the Cabal developers are going to be very grateful for any manpower you can offer. Given how long this has gone unaddressed, I fear it'll go on being unresolved otherwise.

I propose this be closed -- if @mietek wants he can reopen. (But please only do so if you want to help address it or know somebody who can.)


hvr commented Aug 17, 2015

For the record, pkg-config seems to use the same version comparison that rpm uses (or used at some point), see


nomeata commented Nov 3, 2015

I have been observing that when building bindings-sane on Debian. @mtolly, are you still planning to fix this?


mtolly commented Nov 10, 2015

My apologies, this has fallen off my radar for a while now. In #2730 you can see that it got a bit more complicated, and as far as I could tell, clear decisions weren't really reached regarding where the extra tags should be allowed, and whether they should be ignored or actually used for comparison (and, what comparison function should be used). In addition my own reason for needing the fix mostly went away. So, anyone else is certainly free to pick this back up.

kenta2 commented Feb 10, 2017

Yet one more package that this bug affects is hlibBladeRF- which depends on libbladeRF. Ubuntu 14.04 provides
$ pkg-config --modversion libbladeRF

This one almost parses correctly as a tag; the only issue is that simpleParse in Cabal/Distribution/Text.hs assumes tags are Char.isAlphaNum, but the period is not alphanumeric.

@ezyang ezyang modified the milestones: Triaged, Mar 7, 2017


ezyang commented Mar 7, 2017

Perhaps, as a stopgap, we should just truncate the version string at the point where it stops looking like a normal version? This should be easy to implement, should be a very small change, and will get more packages compiling than before.

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