建议使用Stack作为全局包管理器的方法 [英] Recommended approach to use Stack as global package manager

查看:108
本文介绍了建议使用Stack作为全局包管理器的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在全球范围内安装一些Haskell库,例如,我的编辑器的Haskell集成使用的hindent.推荐的方法是什么?

我认为stack install hindent是执行此操作的正确方法.但是,后来我想更新我的程序包,发现没有无法做到这一点.根据我发现的GitHub问题报告

stack与管理项目的本地构建沙箱有关.并不是要成为全球包装经理.

似乎有一些变通办法,例如维护一个虚拟项目,该虚拟项目对我要安装的软件包具有人为的依赖性.这听起来像是一个骇人听闻的骇客,我一直无法找到有关应采取哪种实际方法的任何官方文档.

由于我的系统软件包管理器(Homebrew)未打包,因此无法安装.

我本应针对Stack打开问题报告,但是贡献准则要求我改为在标签.

解决方案

好,任何项目中的stack install都将安装到~/.local/bin,因此使您安装的所有可执行文件都可以全局访问.

在没有项目的情况下运行堆栈时使用全局项目,该项目位于~/.stack/global-project/stack.yaml中.

如果您希望所有可全局访问的工具都具有相同的依赖项(也许是为了确保ghc版本匹配或类似),则可以制作一个旨在构建所有这些工具的项目.是否是全局项目"由您决定-它没有什么特别之处,如果您运行堆栈并且不在项目中,这只是默认设置.

为了记录我想在全局安装哪些haskell可执行文件",您可以考虑创建一个shell文件,例如

#!/bin/sh
stack install hindent

然后在您更改已安装工具的版本时运行它.

此外,对于像intero这样需要与ghc版本匹配的工具,您可以执行stack install --copy-compiler-tool intero,当该ghc版本与堆栈一起使用时,它将在PATH上可用.

I would like to install some Haskell libraries globally, for example hindent which is used by my editor's Haskell integration. What is the recommended way to do this?

I thought that stack install hindent was the correct way to do this. However, then I wanted to update my packages and found that there was no way to do this. According to the GitHub issue report I found,

stack is concerned with managing a local build sandbox for a project. It isn't intended to be a global package manager.

There appear to be workarounds such as maintaining a dummy project with artificial dependencies on the packages I would like installed. This sounds like a terrible hack, and I have been unable to find any official documentation on what approach should actually be taken.

Installing Haskell packages using my system package manager (Homebrew) is not an option since they are not packaged.

I would have opened an issue report against Stack, however the contribution guidelines requested that I instead ask a question here under the tag.

解决方案

Well, stack install in any project will install to ~/.local/bin therefore making whatever executable you install be globally accessible.

The global project is used when running stack without a project, it is located in ~/.stack/global-project/stack.yaml.

If you want all of your globally accessible tools to have the same dependencies (perhaps to ensure that the ghc version matches or something), then you could make a project intended to build all of these tools. It's up to you whether or not it is the "global project" - there's not much special about it, it's just a default if you run stack and aren't in a project.

In order to record "what haskell executables do I want installed globally", you might consider creating a shell file like

#!/bin/sh
stack install hindent

And then running this whenever you change the versions of the installed tools.

Also, for tools like intero that need to match the ghc version, you can do stack install --copy-compiler-tool intero, and it will be available on the PATH when stack is used with that ghc version.

这篇关于建议使用Stack作为全局包管理器的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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