Package versioning clashes in Cabal

你离开我真会死。 提交于 2019-12-23 17:14:05

问题


Forgive me if this is a FAQ but I'm a bit puzzled about how to get around this problem properly.

I recently downloaded the package TagSoup which installed fine with the latest version 0.12.2

Then I installed the package download-curl which installed fine with the latest version. What I failed to realise was, download-curl depends on TagSoup with a version =< 0.11, so as part of the installation process Cabal downloaded an older version of TagSoup too.

This is a problem because I want to use both libraries (the latest version of TagSoup AND download-curl) - and when you do for some reason GHCI gets in a bit of a mess.

My question is, is there a way of specifying versions in your import statements, i.e.

import Text.Html.TagSoup-0.12.2

or is this a no go? I'm thinking not.

The only way I got around this was to download the download-curl source, modify the .cabal file to use TagSoup-0.12.2 and reinstalled the package with my little "hack" in place which works as I would expect it to - but I don't think this is the solution

Any help would be appreciated


回答1:


Normally one specifies the required version in the .cabal file. There is an extension syntax for specific package imports (-XPackageImports) but it's usually better to let Cabal deal.

That said, yes, if you need to use both then you enter the dark realm of diamond dependencies. Yours is pretty much the only solution available currently. -XPackageImports is not a good idea here, as trying to use two versions of the same library in the same program probably won't link and almost certainly will dump core at runtime if it does manage to link without duplicate symbols.



来源:https://stackoverflow.com/questions/6526353/package-versioning-clashes-in-cabal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!