大约一周前,我为我的第一个非平凡的Haskell项目发布了0.1.0.0软件包.我希望可执行文件易于安装和升级,即使对于非Haskeller也是如此.在README中,我建议使用安装cabal install.这是一个错误吗?
我听说过"Cabal hell",但没有意识到用户升级全局安装的软件包副本会有多么困难,即使我保守地没有改变.cabal文件中的任何版本依赖项.最后,我试图从0.1.0.0更新到0.2.0.0深入兔子洞.它警告我打破依赖关系,我尝试了各种各样的咒语来强制升级或重置我的本地状态,然后我就不得不重新安装ghc和使用cabal-installBrew软件包(这是在macOS上),以便让所有东西都恢复原状到我可以安装并再次运行的状态.
备择方案:
stack install:我已经在使用Stack来管理本地开发环境了,但是对于独立安装它似乎也很好,只要你先安装了Stack.(只需要$PATH适当地设置你.)所以,在我的README中,我现在提到了两者stack install和cabal install.但2016年的最佳做法是什么?
升级haskell平台包后,stack命令不起作用.
$ stack path
No compiler found, expected minor version match with ghc-8.0.1 (x86_64) (based on resolver setting in /home/eii/exercism/haskell/linked-list/stack.yaml).
To install the correct GHC into /home/eii/.stack/programs/x86_64-linux/, try running "stack setup" or use the "--install-ghc" flag.
$
Run Code Online (Sandbox Code Playgroud)
我尝试了堆栈设置,但它正在尝试下载旧的GHC(ghc-8.0.1).我刚刚安装了Haskell平台8.0.2(haskell-platform-8.0.2-unknown-posix-full-x86_64.tar.gz).我使用的是64位Linux.
$ stack setup
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
ghc-8.0.1: 15.69 MiB / 108.01 MiB ( 14.52%) downloaded...^Cuser interrupt
$
Run Code Online (Sandbox Code Playgroud)
我可以用ghc-8.0.2编译并且ghci工作正常..但我不能使用堆栈也不能安装新包.
$ stack update
Downloading package index from https://s3.amazonaws.com/hackage.fpcomplete.com/00-index.tar.gz
Updating package index …Run Code Online (Sandbox Code Playgroud) 我可以stack build从命令行创建一个项目,但是当我尝试C-c C-l使用emacs(带(custom-set-variables '(haskell-process-type 'stack-ghci)))时,我得到一个错误,即我导入的所有包模块都找不到.
/home/amcp011/bec/amcp011/accelerate/gpe/src/Numeric/GPE/Utils.hs:30:1: error:
Failed to load interface for ‘Data.Array.Accelerate’
Locations searched:
Data/Array/Accelerate.hs
Data/Array/Accelerate.lhs
Data/Array/Accelerate.hsig
Data/Array/Accelerate.lhsig
/home/amcp011/bec/amcp011/accelerate/gpe/src/Data/Array/Accelerate.hs
/home/amcp011/bec/amcp011/accelerate/gpe/src/Data/Array/Accelerate.lhs
/home/amcp011/bec/amcp011/accelerate/gpe/src/Data/Array/Accelerate.hsig
/home/amcp011/bec/amcp011/accelerate/gpe/src/Data/Array/Accelerate.lhsig
Run Code Online (Sandbox Code Playgroud)
gpe.cabal:
build-depends: base >= 4.7 && < 5
, bytestring
, bytestring-conversion
, mtl
, time
, filepath
, directory
, accelerate
, accelerate-io
Run Code Online (Sandbox Code Playgroud)
stack.yaml:
extra-deps: [accelerate-1.0.0.0
,accelerate-io-1.0.0.0
]
Run Code Online (Sandbox Code Playgroud) 我有一个小/中型Haskell代码库,我想生成一个覆盖率报告.默认情况下,HPC提供的覆盖率报告中填充了漏报(例如,我使用镜头访问我的大多数记录字段,而不是自动生成的记录字段,HPC随后报告为未覆盖).
典型的解决方案是生成一些覆盖,如下所示:https://wiki.haskell.org/Haskell_program_coverage#Hpc_toolkit
当我尝试用Stack执行此操作时遇到问题.
$ stack new --resolver=lts-9.5 hpcTest
Run Code Online (Sandbox Code Playgroud)
如果我们编辑src/Lib.hs为:
module Lib
( someFunc, otherFunc
) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"
otherFunc :: IO ()
otherFunc = putStrLn "otherFunc"
Run Code Online (Sandbox Code Playgroud)
并test/spec.hs成为:
import Lib
main :: IO ()
main = someFunc
Run Code Online (Sandbox Code Playgroud)
并运行 stack test --coverage
我们得到的覆盖率报告并非100%覆盖,因此如果我们按照维基页面的说明操作,我们会得到: stack exec hpc -- draft --hpcdir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/hpc/ --srcdir=. .stack-work/install/x86_64-linux/lts-9.5/8.0.2/hpc/hpcTest/hpcTest-test/hpcTest-test.tix > myDraft.txt
当我们运行时,结果如下myDraft.txt:
module "hpcTest-0.1.0.0-HnYRxRg1qoiyMKwsCMtby:Lib" {
tick function "otherFunc" on line 9;
}
Run Code Online (Sandbox Code Playgroud)
然后,当我们进行下一步并尝试生成叠加层时,stack exec …
stack setup 下载并安装GHC项目,
~/.stack/programs,
~/.stack/snapshots以及其他我还不知道的地方)
stack build下载依赖项并构建它们.
~/.stack/setup-exe-cache和其他地方.
我想清理项目范围的ghc并从它们下载依赖项/构建输出,以及我磁盘上所有其他项目相关的东西.
除了手动删除它们之外没有办法做到这一点?
当谷歌搜索此错误时没有看到任何相关结果,所以我想将其发布。
stack build
Building all executables for `gitchapter' once. After a successful build of all of them, only specified executables will be rebuilt.
gitchapter-0.1.0.0: build (exe)
Preprocessing executable 'app' for gitchapter-0.1.0.0..
Building executable 'app' for gitchapter-0.1.0.0..
Preprocessing executable 'test' for gitchapter-0.1.0.0..
Warning: Enabling workaround for Main module 'Main' listed in 'other-modules'
Building executable 'test' for gitchapter-0.1.0.0..
illegaly!
<no location info>: error:
output was redirected with -o, but no output will be generated
because there is no Main module.
-- While …Run Code Online (Sandbox Code Playgroud) 当我尝试通过堆栈安装ghc-mod时,我最终会遇到这些依赖性冲突
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for ghc-mod-5.8.0.0:
Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25 (latest matching version is 1.24.2.0)
base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && <4.10 (latest matching version is 4.9.1.0)
cabal-helper must match <0.8 && >=0.7.3.0, but the stack configuration has no specified version (latest matching version is 0.7.3.0)
extra-1.6.8 from stack configuration does not match <1.6 && >=1.4 (latest matching version is …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 ubuntu (18.04) 主机上运行一些 haskell 代码,该代码是在我的笔记本电脑上编译的。
host: 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
laptop: 4.14.74-1-MANJARO #1 SMP PREEMPT Fri Oct 5 14:16:52 UTC 2018 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found
Run Code Online (Sandbox Code Playgroud)
经过一些研究,我了解到这是因为我的笔记本电脑安装了 glibc 2.28 版本,但主机只有 libc6 2.27。
我做了一些谷歌搜索,认为也许 docker 可以解决这个问题。但是,我刚刚使用以下 Dockerfile 创建了一个 docker 映像,但它不起作用(相同的 GLIBC_2.28 错误)
FROM fpco/stack-build:lts-12.9 as builder
RUN mkdir /opt/build
COPY . /opt/build
RUN cd /opt/build && stack build
FROM ubuntu:18.04
RUN mkdir -p /opt/myapp
WORKDIR /opt/myapp
RUN apt-get …Run Code Online (Sandbox Code Playgroud) 我正在尝试为 Haskell 设置环境并安装堆栈。安装后我意识到 GHC 8.6.4 版本不是我需要的版本(8.0.2)。
compiler-exe: /home/manny/.stack/programs/x86_64-linux/ghc-tinfo6-
8.6.4/bin/ghc
compiler-bin: /home/manny/.stack/programs/x86_64-linux/ghc-tinfo6-
8.6.4/bin
compiler-tools-bin: /home/manny/.stack/compiler-tools/x86_64-linux-
tinfo6/ghc-8.6.4/bin
Run Code Online (Sandbox Code Playgroud)
所以我安装了GHC 8.0.2。我知道如果我更改全局配置文件,我可以解决问题,指示我想要的正确编译器,但是进行此类更改以避免编辑配置文件的正确命令是什么?
我试过:
stack config set --compiler ghc-8.0.2
Run Code Online (Sandbox Code Playgroud)
没有成功。我的编译器仍然是8.6.4。
~/.stack$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 8.6.4
Run Code Online (Sandbox Code Playgroud)
谢谢你!
当我stack ghci在一个全新的项目上运行时,它无法加载:
$ stack new repro simple
Downloading template "simple" to create project "repro" in repro\ ...
Run Code Online (Sandbox Code Playgroud)
(省略了额外的输出以使问题更具可读性。)
$ cd repro/
$ stack ghci
Using main module: 1. Package `repro' component repro:exe:repro with main-is file: C:\Users\mark\Desktop\repro\src\Main.hs
Building all executables for `repro' once. After a successful build of all of them, only specified executables will be rebuilt.
repro> configure (exe)
Configuring repro-0.1.0.0...
repro> initial-build-steps (exe)
Configuring GHCi with the following packages: repro
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help …Run Code Online (Sandbox Code Playgroud)