大约一周前,我为我的第一个非平凡的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年的最佳做法是什么?
假设我有一个包含一些.hs文件的文件夹,我想将它包装在一个项目中
如果我有cabal install,stack那没什么大不了的:
cabal init(互动选择东西)stack init但是,当我只是轻松 - 只是安装stack路线,我没有cabal install- 只有stack
现在stack init没有.cabal(或.package)文件就无法工作,因为stack new我知道没有没有设置其他文件/文件夹的模板.
可能我错过了一些明显的东西,并且有一个stack参数/命令吗?
如果不是:处理这个问题的正确方法是什么?安装cabal-install?
升级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) 已经建立的项目无法找到GHC.堆栈构建导致:
No compiler found, expected minor version match with ghc-8.0.2 (x86_64-ncurses6-nopie)
(based on resolver setting in /home/iam/Work/has/grove/stack.yaml).
To install the correct GHC into /home/iam/.stack/programs/x86_64-linux/, try running "stack
setup" or use the "--install-ghc" flag. To use your system GHC installation,
run "stack config set system-ghc --global true", or use the "--system-ghc" flag.
Run Code Online (Sandbox Code Playgroud)
堆栈设置导致:
Unable to find installation URLs for OS key: linux64-ncurses6-nopie
However, in .stack-work, in the install file there is a folder called x86_64-linux-ncurses6,
not linux64-ncurses6-nopie
Run Code Online (Sandbox Code Playgroud)
Stack由pacman安装.版本1.4.0 x86_64,该项目使用解析器:lts-8.21
我可以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) 我们的团队正在使用Docker构建我们的Haskell应用程序,为了优化构建时间,我们努力将~/.stack操作系统中的目录与docker容器内的目录共享.最初的实现只是重用OS中的那个,但事实证明这不能很好地工作,它失败并出现如下错误:
The GHC located at /root/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was: Running /root/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc /tmp/stack-sanity-check48/Main.hs -no-user-package-db in directory /tmp/stack-sanity-check48/ exited with ExitFailure 127
/root/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc: line 9: /home/ubuntu/.stack/programs/x86_64-linux/ghc-8.0.1/lib/ghc-8.0.1/bin/ghc: No such file or directory
make: *** [adserver_executables] Error 1
Run Code Online (Sandbox Code Playgroud)
似乎某个地方~/.stack有一个缓存~/.stack,它指明了GHC的绝对路径,当我们在docker中挂载时,它会被挂载/root/.stack而不是/home/<user>/.stack,因此该路径找不到编译器.
我们目前的决定是创建一个单独的目录~/.docker-stack,我们将用于所有基于docker的构建,而不会干扰操作系统级别的目录.这并不理想,因为它将占用更多空间,并且即使在非docker OS级环境中编译它们也需要重新编译包.
是否有更好的方法有人可以建议~/.stack与内部Docker堆栈共享?谢谢.
我一直在尝试使用堆栈构建我最近几天的Haskell项目,并且我遇到了访问冲突错误.根据我的理解,我有最新的堆栈版本和GHC.
这一切都是最初工作,直到我将库添加到我的cabal文件.我现在已将其删除,但错误仍然存在.我还回到了我的代码肯定正在工作的时候,所以我确定这是由堆栈引起的.
我已经尝试卸载堆栈,删除.stack-work并重新安装.然后进行堆栈设置.我尝试了很多命令,但没有结果.
我现在也尝试使用Stack创建一个新项目并构建它,我也遇到了同样的问题.
stack build
Building all executables for `haskell-project' once. After a successful build of all of them, only specified executables will be rebuilt.
haskell-project-0.1.0.0: configure (exe)
Access violation in generated code when reading 000000000e58391a
-- While building custom Setup.hs for package haskell-project-0.1.0.0 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.0.1.0_ghc-8.2.2.exe --builddir=.stack-work\dist\5c8418a7 configure --with-ghc=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\ghc-8.2.2\bin\ghc.EXE --with-ghc-pkg=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\ghc-8.2.2\bin\ghc-pkg.EXE --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\13cecb13\pkgdb --package-db=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\pkgdb --libdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\lib --bindir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\bin --datadir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\share --libexecdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\libexec --sysconfdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\etc --docdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\doc\haskell-project-0.1.0.0 --htmldir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\doc\haskell-project-0.1.0.0 --haddockdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\doc\haskell-project-0.1.0.0 --dependency=base=base-4.10.1.0 --dependency=containers=containers-0.5.10.2 --dependency=mtl=mtl-2.2.1-DscMMmDQUE6GBfOSl4qMUH --dependency=parsec=parsec-3.1.11-3BgBURmbRiVF8fgoxhAiBa --dependency=pretty-simple=pretty-simple-2.0.1.0-J3QTM6x6LHL5fhqavYvVhJ --dependency=text=text-1.2.2.2-9VTsh6V7U7hpagw2HDvpZ --extra-include-dirs=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include --extra-lib-dirs=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\bin --extra-lib-dirs=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib --enable-tests --enable-benchmarks
Process exited with code: ExitFailure …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Stack建立一个Haskell项目.我创建了一个项目:stack new project1并添加了建议的依赖项(acme-missile),以了解它是如何工作的.
extra-deps:
- acme-missiles-0.3
Run Code Online (Sandbox Code Playgroud)
但是当我尝试launchMissile在Main中调用时它将无法工作.我明白了
Error:(3, 1) Could not find module ‘Acme.Missiles’
Use -v to see a list of the files searched for.
|
3 | import Acme.Missiles
| ^^^^^^^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
问题是什么?我错过了什么?
编辑
我跑的时候stack solver得到这个:
Using configuration file: stack.yaml
Using cabal packages:
- ./
The following changes will be made to stack.yaml:
* Dependencies to be deleted
extra-deps:
- acme-missiles-0.3
To automatically update stack.yaml, rerun with '--update-config'
Run Code Online (Sandbox Code Playgroud)
这不奇怪吗?就像它认为不需要我的依赖?
stack setup 下载并安装GHC项目,
~/.stack/programs,
~/.stack/snapshots以及其他我还不知道的地方)
stack build下载依赖项并构建它们.
~/.stack/setup-exe-cache和其他地方.
我想清理项目范围的ghc并从它们下载依赖项/构建输出,以及我磁盘上所有其他项目相关的东西.
除了手动删除它们之外没有办法做到这一点?
当我尝试通过堆栈安装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)