Sibi
Sibi

Reputation: 48644

Find library dependency version of Haskell executable

Let's say I have a executable file produced by ghc. Now I want to know which version of a particular library it was built with (like which version of base/< insert other library here > it was built with ?) ?

Is it possible to find it ?

A more specific question - I want to know which version of Cabal library is used by my stack executable.

Upvotes: 2

Views: 218

Answers (1)

Sibi
Sibi

Reputation: 48644

Thanks to @ongy from #haskell irc for this answer.

I can use the GNU's strings utility to find the information. To find which version of Cabal my stack executable is using, I can do this:

strings ~/.local/bin/stack | grep -i Cabal-

That will spit out a big string and I can find this piece of information in it:

/tmp/stack-upgrade7565/stack/.stack-work/install/x86_64-linux/lts-6.14/7.10.3/lib/x86_64-linux-ghc-7.10.3/stack-1.2.1-IEWywJcSJuzIIEqkeEd87k:/home/sibi/.stack/snapshots/x86_64-linux/lts-6.17/7.10.3/lib/x86_64-linux-ghc-7.10.3/Cabal-1.22.8.0-Ku2CIqstfjg7Z2SNHUypWH:/home/sibi/.stack/snapshots/x86_64-linux/lts-6.14/7.10.3/lib/x86_64-linux-ghc-7.10.3/Glob-0.7.11-0WpLeizIORG0eUMRaKlYmO:/home/sibi/.stack/snapshots/x86_64-linux/lts-6.14/7.10.3/lib/x86_64-li....

And I can see Cabal-1.22.8.0 in it.

To find the base library version, you can do

executable +RTS --info which will spit out the ghc version from which we can find the base. Example:

$ stack +RTS --info
 [("GHC RTS", "YES")
 ,("GHC version", "7.10.3")
 ,("RTS way", "rts_thr")
 ,("Build platform", "x86_64-unknown-linux")
 ,("Build architecture", "x86_64")
 ,("Build OS", "linux")
 ,("Build vendor", "unknown")
 ,("Host platform", "x86_64-unknown-linux")
 ,("Host architecture", "x86_64")
 ,("Host OS", "linux")
 ,("Host vendor", "unknown")
 ,("Target platform", "x86_64-unknown-linux")
 ,("Target architecture", "x86_64")
 ,("Target OS", "linux")
 ,("Target vendor", "unknown")
 ,("Word size", "64")
 ,("Compiler unregisterised", "NO")
 ,("Tables next to code", "YES")
 ]

Thanks to @MarcelineVQ for the above tip.

Upvotes: 0

Related Questions