我正在尝试将我的第一个包上传到 Hackage(耶!),我收到了这个错误:
The dependency 'build-depends: base' does not specify an upper bound on the version number. Each major release of the 'base' package changes the API in various ways and most packages will need some changes to compile with it. The recommended practise is to specify an upper bound on the version of the 'base' package. This ensures your package will continue to build when a new major version of the 'base' package is released. If you are not sure what upper bound to use then use the next major version. For example if you have tested your package with 'base' version 2 and 3 then use 'build-depends: base >= 2 && < 4'.
这似乎是一个完全可以接受的拒绝我的包裹的理由。
是否有一个很好的工具可以针对各种版本的
base
测试我的包所以我可以看到界限是什么(而不仅仅是猜测)?我能想到的最好的方法是使用一些 shell 脚本来执行以下操作:% for v in $BASE_VERSIONS
do
cabal install base-$v &&\
cabal configure --enable-tests &&\
cabal build &&\
cabal test && echo "$v ok" || echo "$v fail"
done
但我觉得应该有更好的东西。
最佳答案
这是一个非常糟糕的主意!您不得升级 base 或 any other packages that come with GHC (标签列中带有 -
的那些),否则一切都会糟糕透顶。
使用较旧版本的 base 进行测试的唯一方法是安装较旧的 GHC 并使用它进行测试。我建议在 7.0.4 和 7.2.2 上尝试一下;这些天支持旧版本可能是浪费时间。
否则,只需指定 base >= VERSION && < 5
, 其中 VERSION
是您的 GHC 的版本。或 base == 4.*
并希望最好的:)
严肃地说,base 的 API 并没有真正改变太多,所以你不太可能遇到很多问题。
使用各种版本的软件包测试您的程序,而不会干扰您的主要 ~/.cabal
存储库,我强烈推荐 cabal-dev ;就像是
$ cabal-dev install 'pkg==VERSION'
$ cabal-dev install
$ cabal-dev test
应该这样做。
对了,你可以做
cabal check
在将您的包上传到 Hackage 之前收到有关此类问题的警告。
关于Haskell:针对 Hackage 的多个版本的 base 测试包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8645946/