如何更改 cabal 存储文档的目录

发布于 2024-11-04 13:55:17 字数 684 浏览 0 评论 0原文

我安装了一个带有前缀 $HOME/usr 的自定义 Haskell 工具链,因此编译器位于 $HOME/usr/bin/ghc 中,文档位于 $HOME 中/usr/share/doc/ghc/...。该工具链由 ghc 安装、cabal 安装以及您需要的所有库组成。我以某种方式设置了 $PATH,所有这些程序都在其中。我的系统上没有安装这些工具。

现在我尝试安装一些其他库。但当 cabal 尝试安装文档时,我总是遇到同样的错误:

~$ cabal install --global binary
Resolving dependencies...
Configuring binary-0.5.0.2...
Preprocessing library binary-0.5.0.2...
Building binary-0.5.0.2...
 ... snip ...
Registering binary-0.5.0.2...
cabal: /usr/local/share/doc: permission denied

我怎样才能告诉 cabal 文档应该放在哪里?我不想在 shell 中一次又一次地提供这些信息,所以最好是一个配置文件。我希望将所有与 haskell 相关的东西都放在我的主树中,以避免错误的命令破坏我的系统。

I installed a custom Haskell toolchain with the prefix $HOME/usr, so the compiler lives in $HOME/usr/bin/ghc and the documentation in $HOME/usr/share/doc/ghc/.... The toolchain consists of a ghc installation, a cabal installation and all the libs you need. I set up $PATH in a way, that all these programs are in it. There is no other installation of these tools on my system.

Now I tried to install some other libraries. But I always got the same error when cabal tried to install the documentation:

~$ cabal install --global binary
Resolving dependencies...
Configuring binary-0.5.0.2...
Preprocessing library binary-0.5.0.2...
Building binary-0.5.0.2...
 ... snip ...
Registering binary-0.5.0.2...
cabal: /usr/local/share/doc: permission denied

How can I tell cabal where the documentation should live? I don't want to give this information again and again in the shell, so the best would be a config file. I want to have all the haskell related stuff in my home tree, to avoid destroying my system with a wrong command.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撞了怀 2024-11-11 13:55:17

为什么要使用“--global”安装?默认情况下,这会将所有内容放入 /usr/local/ 中。如果您执行标准的每用户安装,文档将安装到您的主目录中,并且应该可以正常工作。

话虽如此,这可以通过文件进行配置。 cabal 配置文件通常位于 ~/.cabal/config/。这是我的相关部分:

install-dirs global
  -- prefix: /usr/local
  -- bindir: $prefix/bin
  -- libdir: $prefix/lib
  -- libsubdir: $pkgid/$compiler
  -- libexecdir: $prefix/libexec
  -- datadir: $prefix/share
  -- datasubdir: $pkgid
  -- docdir: $datadir/doc/$pkgid
  -- htmldir: $docdir/html
  -- haddockdir: $htmldir

您可以进行任何您喜欢的更改,只需确保取消注释这些行即可。还有一个“install-dirs user”部分,用于每用户安装。

Why are you installing with "--global"? By default this would put everything in /usr/local/. If you do a standard per-user install the docs will be installed into your home directory and it should work fine.

That being said, this is configurable via a file. The cabal config file is typically located at ~/.cabal/config/. Here's the relevant section of mine:

install-dirs global
  -- prefix: /usr/local
  -- bindir: $prefix/bin
  -- libdir: $prefix/lib
  -- libsubdir: $pkgid/$compiler
  -- libexecdir: $prefix/libexec
  -- datadir: $prefix/share
  -- datasubdir: $pkgid
  -- docdir: $datadir/doc/$pkgid
  -- htmldir: $docdir/html
  -- haddockdir: $htmldir

You can make whatever changes you like, just be sure to uncomment the lines. There is also an "install-dirs user" section, which is used in per-user installs.

深巷少女 2024-11-11 13:55:17

我同意海报的观点。为什么没有明确的文档说明如何操作
cabal安装包--全局
需要权限时提示输入 sudo 吗?
正在做
sudo cabal 安装包
是一个坏主意,因为这样你就以 root 身份构建包。并且您必须允许互联网连接写入 root 拥有的文件(您必须填充 /root/.cabal 或类似的内容)。

这是人们想要这样做的一个很好的理由:
如果我通过我的 Linux 包管理器安装 ghc 和 haskell 平台(这样做有充分的理由;),那么如果我执行 cabal 安装包
它不会识别全局识别的包。

I agree with the poster. Why is there no clear documentation for how to do
cabal install package --global
that prompts for sudo when permission is needed?
Doing
sudo cabal install package
is a bad idea because then you're building packages as root. And you have to allow an internet connection to write to a file owned by root (you will have to populate /root/.cabal or something like that).

Here is a good reason why one would want to do this:
If I install ghc and the haskell platform through my linux package manager (there are good reasons for this ;), then if I do cabal install package
it will not recognize the packages that globally recognized.

橘和柠 2024-11-11 13:55:17

好吧,实际上有人发布了(几乎令人烦恼的)详细描述,说明如何进行全局安装(使用 --global 或 install-dirs global)而不会遇到权限错误。诀窍是在 cabal 配置文件中使用 root-cmd sudo 。
看,
http://jdgallag.wordpress.com/2011/05/14/cabal-install-to-global-using-sudo-but-do-not-build-as-root/

Well, someone actually posted a(n almost annoyingly) detailed description of how to do global installations (with either --global or install-dirs global) without running into permission errors. The trick is to use root-cmd sudo in the cabal config file.
See,
http://jdgallag.wordpress.com/2011/05/14/cabal-install-to-global-using-sudo-but-do-not-build-as-root/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文