Haskell cabal:我刚刚安装了软件包,但是现在找不到软件包 [英] Haskell cabal: I just installed packages, but now the packages are not found
问题描述
在这里是我可以找到我自己的软件包的唯一原因GHC找不到使用 cabal
进行安装:
Over here is the only reason I can find that packages I'm installing using cabal
are not being found by GHC:
安装时会发生这种情况全局安装一个软件包,而以前的软件包则在本地安装。请注意,cabal-install默认在本地安装[...]
This happens when you install a package globally, and the previous packages were installed locally. Note that cabal-install install locally by default [...]
大概,本地安装意味着将软件包放入〜/ .cabal /
。第一个问题:全局安装在哪里?
Presumably, "local installation" means putting packages in ~/.cabal/
. First question: where are global installs?
我一直在使用 cabal
运行 sudo
,所以我想这是全局安装?我这样做的原因是,它在没有 sudo
的情况下运行时会抱怨权限,因此这与默认情况下本地安装cabal-install这一说法相矛盾。第二个问题:如何在本地安装以及如何在全球安装?
I've been running cabal
using sudo
, so I guess that's a global install? The reason I've been doing this is that it complains about permissions when run without sudo
, so this contradicts the statement "cabal-install install locally by default". Second question: how do I install locally and how do I install globally?
试图解决这一问题,我一直在随机使用 sudo ghc-pkg取消注册
,然后从〜/ .cabal /
中随机删除内容。因此,我的程序包树可能在本地和全局都被破坏了。第三个问题:如何重新启动?
Trying to fix this mess, I've been randomly using sudo ghc-pkg unregister
and randomly removing stuff from ~/.cabal/
. Consequently my package tree is broken, probably locally and globally. Third question: How do I start again?
编辑:我正在运行Ubuntu 10.10 。我安装了Haskell Platform 2011。
I'm running Ubuntu 10.10. I installed the Haskell Platform 2011.
推荐答案
您是否正在使用Windows,OS X或某些版本的Linux?您正在使用Haskell平台吗?您之前是否有 ghc
或 cabal
的版本?当然,对于Linux发行版,可能会涉及到软件包管理器的细微差别。 (特别是旧的 ghc
的踪迹,以及旧的〜/ .ghc /目录可能会带来麻烦。)
Are you using Windows, OS X or some version of Linux? Are you using the Haskell Platform? Have you had a version of ghc
or cabal
before? For a Linux distribution, subtleties about your package manager may come in, of course. (Traces of an old ghc
in particular, and an old ~/.ghc/ directory can be a source of trouble.)
以下是#haskell遇到的这类问题的一些基本思想。 (当然,我的理解并不完全足够):
Here are a few elementary thoughts of the type one goes through on #haskell with such problems. (My comprehension is not completely adequate, of course):
主要问题似乎是,为什么邀请您使用<$ c进行本地安装$ c> sudo ?如果ghc及其库位于 / usr / ...,则全局安装(
cabal安装小马--global
)当然需要特权。 code>或其他受保护的地方,但是 sudo
与非 sudo
的关系与安装。使用 cabal install pony --user
(理论上,默认为-user
)进行的操作不需要超级用户权限。 (我有时在OS X上发现需要调用 gcc
的特权,但这通常是出于对我的设置的好奇心。)但是无论如何 sudo
不影响 cabal
放置它们的位置:隐式-用户
和显式-global
以及更具体的开发思路可以做到这一点。
The chief question seems to be, Why you were being invited to do what should be local installs with sudo
? A global install (cabal install pony --global
) would of course require privileges if ghc and its libraries are in /usr/...
or some other protected place, but otherwise sudo
vs non-sudo
is independent of the place of installation. What you do with cabal install pony --user
(--user
is the default, in theory) should not require superuser authority. (I have sometimes found on OS X that privileges are requested where the gcc
needs to be called, but this has usually been due to curiosities about my setup.) But in any case sudo
doesn't affect where cabal
is putting them: the implicit --user
and explicit --global
, and more specific incantations for development, do that.
例如,如果您执行 ghc-pkg list
,它将把包裹分成不同的位置根据两个或多个 package.conf.d
目录注册的摘要。目前在我的笔记本电脑上是
If you do ghc-pkg list
, for example, it will divide the packages into the different places they are registered in according to two or more package.conf.d
directories it is summarizing. On my laptop at the moment these are
/Users/applicative/.ghc/x86_64-darwin-7.0.3/package.conf.d/...
用于〜/中的本地内容。 cabal / lib /...
和受保护的
/Library/Frameworks/GHC.framework/Versions/7.0.3-x86_64/usr/lib/ghc-7.0.3/package.conf.d
用于在Haskell Platform安装程序中全局安装的东西(此位置涉及某些OS X特性, ghc
, ghci
等在树林中的某个地方,但与 / usr / bin
链接。不同软件包的conf文件会告诉您确切的库安装位置。因此,例如关于神圣的 base
库,
for things that were installed globally with the Haskell Platform installer (this location involves some OS X peculiarities, ghc
, ghci
and so on are in the woods somewhere, but symlinked to /usr/bin
). The conf files for different packages tell you exactly where the libraries were installed. So, for example about the sacred base
library,
$ cat base-4.3.1.0-f5c465200a37a65ca26c5c6c600f6c76.conf
告诉我:
import-dirs:
/Library/Frameworks/GHC.framework/Versions/7.0.3-x86_64/usr/lib/ghc-7.0.3/base-4.3.1.0
library-dirs:
/Library/Frameworks/GHC.framework/Versions/7.0.3-x86_64/usr/lib/ghc-7.0.3/base-4.3.1.0
在任何情况下, ghc-pkg都在哪里 cabal安装
-ed软件包正在运行?在〜/ .cabal
文件夹中,查看文件 config
。如果尚未编辑,则我认为带注释的和未注释的行(如果它们声明了首选项)将说明使用-global
和<$ c $进行安装的默认设置。 c>-user 。在〜.ghc /
目录中,查看子目录 myghcversion / package.conf.d
,看是否有任何内容。 ,应该与 ghc-pkg
告诉您的内容相同。 (您通常可以研究 ghc-pkg
的选项,例如 ghc-pkg支票
和 ghc-pkg重新缓存
(如果尚未安装)。您可能已经以某种奇怪的方式安装了某些东西。)
In any case, where does ghc-pkg list
say your cabal install
-ed packages are going? In the ~/.cabal
folder, look at the file config
. If you haven't edited it, I think the commented and uncommented lines, if they state a preference, are stating the defaults for installation with --global
and --user
. In the ~.ghc/
directory check out the subdirectory myghcversion/package.conf.d
and see if anything is there, which should be the same as what ghc-pkg
tells you. (You might study the options for ghc-pkg
in general, eg. ghc-pkg check
and ghc-pkg recache
, if you haven't. You may have installed something in some odd way.)
如果已安装 ghc
和 cabal
和co。通过使用二进制安装程序或软件包管理器安装Haskell Platform,这似乎是一个好主意,我认为这也是一个好主意,以保持Platform库为神圣,并确保您绝不从Hackage全局安装任何内容;除其他外,这可能会使您覆盖平台库-尽管这似乎并不困难:如果存在的话,会更加明显。
If you installed ghc
and cabal
and co. by installing the Haskell Platform with a binary installer or your package manager, which seems like a good idea, it is also a good idea, I think, to keep the Platform libraries as something sacred, and make sure you never install anything globally from Hackage; among other things this is likely to have you overwriting Platform libraries -- though this doesn't seem the difficulty here: it would be more obvious if it were.
这篇关于Haskell cabal:我刚刚安装了软件包,但是现在找不到软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!