我正在按照http://seanhess.github.io/2015/08/04/practical-haskell-getting-started.html开始使用堆栈工具。
$> stack --version
Version 0.1.3.1, Git revision 908b04205e6f436d4a5f420b1c6c646ed2b804d7
Run Code Online (Sandbox Code Playgroud)
在“安装 GHC”步骤中我得到Permission denied:
$> stack setup
Run from outside a project, using implicit global config
Using resolver: lts-3.2 from global config file: /Users/karl/.stack/global/stack.yaml
Preparing to download ghc-7.10.2 .../Users/karl/.stack/programs/x86_64-osx/ghc-7.10.2.tar.bz2.tmp:
openBinaryFile: permission denied (Permission denied)
Run Code Online (Sandbox Code Playgroud)
这是预期的(指南中的错误)还是中的错误stack?
运行相同的命令sudo似乎可以解决问题。这是预期的方法吗?
$> sudo stack setup
Password:
Downloaded ghc-7.10.2.
Installed GHC.
stack will use a locally installed GHC
For more information on paths, see 'stack path' and 'stack exec env' …Run Code Online (Sandbox Code Playgroud) 这是我的stack.yaml文件声明hspec为额外的依赖项:
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-3.8
# Local packages, usually specified by relative directory name
packages:
- '.'
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps:
- hspec-2.2.0
Run Code Online (Sandbox Code Playgroud)
当我运行时stack solver,它说没有要做任何更改:
root@5d7daa2aec0a:/src/test_stack/a-test/src# stack solver
This command is not guaranteed to give you a perfect build plan
It's possible that even with the changes generated below, you …Run Code Online (Sandbox Code Playgroud) 只是尝试在我已从 cabal 转换为 stack 的项目上运行基准测试。运行stack bench只是打印出来project-name-version: benchmarks,没有进一步的输出。我是否必须向堆栈传递额外的标志才能查看标准输出?
参考基准部分:
benchmark mainbench
type: exitcode-stdio-1.0
hs-source-dirs: src, bench
main-is: MainBench.hs
build-depends: base,
vector,
linear,
hmatrix,
hmatrix-gsl,
criterion,
random,
MonadRandom
ghc-options: -Wall
-O2
default-language: Haskell2010
Run Code Online (Sandbox Code Playgroud)
编辑:此功能已开启stack-0.1.6.0
(这与如何使用堆栈工作台没有重复:))
我设置了一个简单的堆栈项目和一个用于基准测试的 .cabal 条目:
benchmark leaves-of-a-tree-bench
type: exitcode-stdio-1.0
hs-source-dirs: src, bench
main-is: MainBenchmarkSuite.hs
build-depends: base
, criterion
, random
, leaves-of-a-tree
ghc-options: -Wall
-O2
default-language: Haskell2010
Run Code Online (Sandbox Code Playgroud)
但是运行后stack bench我收到以下错误:
setup-Simple-Cabal-1.22.5.0-ghc-7.10.3: Error: Could not find benchmark program
".stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/leaves-of-a-tree-bench/leaves-of-a-tree-bench".
Did you build the package first?
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
编辑:我将项目上传到github 存储库
我的工作流程system-ghc: true专门使用。我希望堆栈在任何时候都无法通过它失败,否则它将访问网络以下载任何内容。是否可以配置(全局或每个项目都可以)?
我做了一个非常简单的项目,但测试套件失败了https://github.com/k-bx/noruntests-play
\n\n现在,当我运行时,stack --test --no-run-tests build我希望它构建项目,但不运行测试。相反,它运行测试:
\xe2\x9e\x9c noruntests-play git:(master) stack --test --no-run-tests build\nnoruntests-play-0.1.0.0: test (suite: test)\n\ntest: error\nCallStack (from HasCallStack):\n error, called at tests/Tests.hs:4:8 in main:Main\n\nTest suite failure for package noruntests-play-0.1.0.0\n test: exited with: ExitFailure 1\nLogs printed to console\nRun Code Online (Sandbox Code Playgroud)\n\n我在这里做错了什么?谢谢你!
\n当堆栈正在构建项目的大型组件时,有什么方法可以在终端上显示进度条?目前,该Progress n/m显示仅在封装级别起作用。如果可能的话,我正在寻找包+模块级别的东西。
使用 Haskell Stack 初始化 GHCJS 项目需要做什么?
按照堆栈文档,我尝试初始化一个 GHCJS 项目,以便可以将 Haskell 代码编译为 JavaScript。
完成后stack templates我看到有一个 GHCJS 模板
ghcjs - Haskell to JavaScript compiler, based on GHC
Run Code Online (Sandbox Code Playgroud)
当我尝试使用此模板的新命令时,如下所示:
stack new ghcjsSetup ghcjs
我收到此错误消息:
Downloading template "ghcjs" to create project "ghcjsSetup" in ghcjsSetup/ ...
The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /home/u/.stack/config.yaml, like this:
templates:
params:
author-email: value
author-name: value
category: value
copyright: value
github-username: …Run Code Online (Sandbox Code Playgroud) 我认为唯一有趣的是我的导入和我的 cabal 文件。以下是导入以及我将如何使用有问题的导入 ( Database.CQL.IO.Log) 的演示。
module FDS.Database.Cassandra where
import Prelude hiding(init)
import Database.CQL.IO as Client hiding(Logger)
import Database.CQL.IO.Log as CQLLog
import qualified Database.CQL.Protocol as CQL
import Numeric.Natural
import System.Logger (Logger)
cqlLogger :: Logger -> CQLLog.Logger
cqlLogger logger = undefined
Run Code Online (Sandbox Code Playgroud)
但是,我收到错误:
src/FDS/Database/Cassandra.hs:7:1: error:
Could not load module `Database.CQL.IO.Log'
It is a member of the hidden package `cql-io-1.1.0'.
Perhaps you need to add `cql-io' to the build-depends in your .cabal file.
Use -v to see a list of the files …Run Code Online (Sandbox Code Playgroud) 在应该正确构建的项目中运行stack build(它可以在其他开发人员的机器上运行,并且过去在我的机器上运行)regex-posix-0.95.2每次都会挂在同一个库()上。
我运行的是 macOS 10.14.4。
我已经尝试过stack clean --full从头开始重新安装堆栈。尝试stack upgrade挂起于Download complete, testing executable。
这是输出stack build --verbose:
stack build --verbose
1.9.3 x86_64
Compiled with:
- Cabal-2.4.0.1
- Glob-0.9.3
- HUnit-1.6.0.0
- QuickCheck-2.11.3
- StateVar-1.1.1.1
- aeson-1.3.1.1
- aeson-compat-0.3.9
- annotated-wl-pprint-0.7.0
- ansi-terminal-0.8.2
- ansi-wl-pprint-0.6.8.2
- array-0.5.2.0
- asn1-encoding-0.9.5
- asn1-parse-0.9.4
- asn1-types-0.3.2
- async-2.2.1
- attoparsec-0.13.2.2
- attoparsec-iso8601-1.0.1.0
- auto-update-0.1.4
- base-4.11.1.0
- base-compat-0.10.5
- base-orphans-0.7
- base-prelude-1.3
- base16-bytestring-0.1.1.6 …Run Code Online (Sandbox Code Playgroud) haskell ×10
haskell-stack ×10
build ×1
build-tools ×1
cabal ×1
dependencies ×1
ghcjs ×1
macos ×1