解决ghc-pkg注意的问题检查 [英] Fixing issues noted by ghc-pkg check

查看:180
本文介绍了解决ghc-pkg注意的问题检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个相当不错的是, ghc-pkg check 将列出破坏的包,以及为什么它们被破坏。但据我所知,没有自动的方式来照顾这些破损的包裹。破坏包装的建议方法是什么? (最好不要重新安装GHC)

It's rather nice that ghc-pkg check will list broken packages, and why they are broken. But as far as I know, there is no automated way to take care of those broken packages. What is the recommended way to deal with broken packages? (Preferably not reinstall GHC)

推荐答案

希望你已经明智了,不能破坏你的全局包数据库中的任何一个。破损可能很容易意味着重新安装GHC是必要的。所以,让我们假设破坏仅限于用户包db(除了用户包中的全局包中可能包含一个或两个以外)。如果只有几个软件包被破坏,您可以通过取消注册违规软件包来修复您的设置。

Hopefully, you have been wise enough to not break any in your global package database. Breakage there can easily mean a reinstallation of GHC is necessary. So, let us assume that the breakage is restricted to the user package db (except possibly a package or two in the global shadowed by user packages). If only few packages are broken, you can fix your setup by unregistering the offending packages,

$ ghc-pkg unregister --user borken

通常会抱怨注销borken会破坏其他软件包。无论您尝试以 - 强制立即取消注册第一个或取消注册borken,然后处理新破坏的内容,主要是一个选择。确保您只从用户数据库中注销软件包。如果事情不太严重,注销少量软件包后, ghc-pkg检查将报告没有更多的破损包。

如果另一方面,大部分软件包损坏,则可能会更容易地完全擦除用户数据库, $ rm -rf〜/ .ghc / ghc-version / package.conf.d 或其他操作系统上的等效文件。

that will often complain that unregistering borken will break other packages. Whether you try to unregister those first or unregister borken immediately with --force and deal with the newly broken afterwards is mostly a matter of choice. Make sure that you only unregister packages from the user db. If things aren't too grim, after unregistering a handful of packages, ghc-pkg check will report no more broken packages.
If, on the other hand, a large proportion of packages is broken, it will probably be easier to completely wipe the user db, $ rm -rf ~/.ghc/ghc-version/package.conf.d or the equivalent on other OSs.

无论哪种方式丢失了您仍然想要使用的软件包,所以您将尝试重新安装它们,而不会重新打破任何东西。运行

Either way, you will have lost packages you still want to use, so you will try to reinstall them without breaking anything anew. Run

$ cabal install world --dry-run

,将尝试为使用 cabal-install 安装的所有软件包生成一致的安装计划。如果没有这样做,它将打印出原因,然后您可以通过向世界文件中列出的包添加约束来解决问题(〜/ .cabal / world cabal install world --dry-run 告诉我可以不配置 vector-algorithms-0.5.2 ,这取决于 vector> = 0.6&& < 0.8 (我有 vector-0.7.1 安装)。原因是 hmatrix-0.12.0.1 需要 vector> = 0.8 。将世界文件中的< 0.12替换为hmatrix上的 - 约束产生了一个干净的安装计划。

在世界文件中有一些限制条件,您将从cabal获取安装计划。检查是否重新安装已经有的软件包(安装较新的版本可能还好,重新安装相同的版本意味着麻烦)。如果您对于cabal的安装计划感到满意,那么在GHC忙碌的时候,您可以在$ code> cabal install world
中冲泡一杯。再次运行 ghc-pkg检查,以验证所有是否按顺序。

that will try to produce a consistent install plan for all the packages you installed with cabal-install. If it fails to do so, it will print out the reasons, you may then be able to fix the issues by adding constraints to the packages listed in the world file (~/.cabal/world) - for example, although I have no broken packages (according to ghc/ghc-pkg), cabal install world --dry-run told me it could not configure vector-algorithms-0.5.2, which depends on vector >= 0.6 && < 0.8 (I have vector-0.7.1 installed). The reason is that hmatrix-0.12.0.1 requires vector >= 0.8. Replacing the -any "constraint" on hmatrix by a "< 0.12" in the world file produced a clean install-plan.
So, after a bit of fiddling with constraints in the world file, you will get an install plan from cabal. Check whether that would reinstall any packages you already have (installing a newer version is probably okay, reinstalling the same version means trouble). If you're happy with cabal's install-plan, cabal install world and brew a nice pot of tea while GHC is busy. Run ghc-pkg check once more, to verify all is in order.

一个普遍好的建议:如果你不知道安装一个软件包是什么,那么首先总是使用--dry-run。

A piece of generally good advice: If you don't know what installing a package entails, always use --dry-run first.

如果你打破了你的全局包数据库通过全面的安装来解决犯罪嫌疑人的策略可能会起作用,但也可能不可逆转地破坏你的ghc,这取决于什么是破坏的方式。如果您通过从操作系统发行版安装软件包来破坏全局数据库,请安装新的GHC,诅咒发行版包装程序,并尝试帮助他们防止进一步的此类事件。

If you broke your global package database by doing global installs with cabal, the strategy of unregistering offenders may work, but it may also irrevocably break your ghc, that depends on what is broken in which way. If you broke your global db by installing packages from your OS distro, install a fresh GHC, curse the distro-packagers, and try to help them prevent further such events.

一个 cabal修复命令将是非常好的,但是暂时修复破损的设置是不幸的是更多的工作。

A cabal repair command would be very nice, but for the time being, repairing a broken setup is unfortunately much more work.

这篇关于解决ghc-pkg注意的问题检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆