我的工作流程system-ghc: true专门使用。我希望堆栈在任何时候都无法通过它失败,否则它将访问网络以下载任何内容。是否可以配置(全局或每个项目都可以)?
如何将+RTS选项传递给使用 运行的程序stack exec?
我已经添加-rtsopts到ghc-options我的 cabal 文件中,并使用stack build. 如果我手动运行程序,普通和+RTS命令行参数都可以工作:
>.stack-work\dist\ca59d0ab\build\iterate-strict-exe\iterate-strict-exe.exe 25 +RTS -s
OK
3,758,156,184 bytes allocated in the heap
297,976 bytes copied during GC
...
Run Code Online (Sandbox Code Playgroud)
但是如果我stack exec只用普通选项运行它到达程序
>stack exec iterate-strict-exe -- 25 +RTS -s
OK
Run Code Online (Sandbox Code Playgroud)
如果我按照@epsilonhalbe 的建议调整参数的顺序,我会得到相同的结果。
>stack exec -- iterate-strict-exe 25 +RTS -s
OK
Run Code Online (Sandbox Code Playgroud)
似乎没有建议的--rts-options选项传递给stack exec.
>stack exec --rts-options "-s" -- iterate-strict-exe 25
Invalid option `--rts-options'
Usage: stack exec CMD …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我为 haskell 堆栈安装的 ghc 版本从 8.0.2 版更新到 8.2.1 版,但似乎我遗漏了一些东西。
[user@localhost ~]$ stack --resolver ghc-8.2.1 setup
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
[user@localhost ~]$ stack ghci
Configuring GHCi with the following packages:
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /tmp/ghci7878/ghci-script
Prelude> :q …Run Code Online (Sandbox Code Playgroud) 我试图使用M-.去定义一个函数,但它似乎intero-goto-definition只适用于我目前正在开发的库,而不适用于我正在导入的库。
这是我的 stack.yaml:
flags: {}
extra-package-dbs: []
packages:
- location: libs/not-gloss/not-gloss # the library I am trying to C-. into
- .
extra-deps:
- spatial-math-0.4.0.0
resolver: lts-9.0
Run Code Online (Sandbox Code Playgroud) 使用 引用特定版本的git存储库的正确方法是Stack什么?
堆栈抱怨在第一场出现的语法错误extra-deps的部分stack.yaml。下面的代码片段基于官方 Stack 文档中的一个示例,我不太确定为什么它不起作用。
# Dependency packages to be pulled from upstream that are not in the resolver
# (e.g., acme-missiles-0.3)
extra-deps:
- git: https://github.com/jwaldmann/moo
commit: b429a7d371c0b268a4bb8dbea8044054aaf04cd5
- git: https://github.com/jwaldmann/monad-mersenne-random
commit: d1f949fe60dc0c0cfbd310b339fe7fd5ecf4c5f5
- gray-code-0.3.1
#extra-deps: [gray-code-0.3.1]
Run Code Online (Sandbox Code Playgroud) 说,我需要System.Eval.Haskell。或者别的什么。我怎么知道我应该在我的文件中指定哪个包package.yaml?当我转到https://hackage.haskell.org/package/plugins-1.5.7/docs/System-Eval-Haskell.html 时,我看不到包名称。
PS“插件”对我不起作用。因此,我认为这是不同的东西。但愿如此 :)
看起来配置中的额外依赖项和“常规”依赖项之间存在一些不太清楚的区别。提到plugins-1.5.7extra-dep 确实有效。我是否在这里做一些依赖管理不善,或者这是绿色的方式?
是否可以stack ghci像ghci通过~/.ghci文件配置的方式进行配置?
当前stack ghci不选取~/.ghci文件中的设置。
我正在考虑将提示设置为 lambda 而不是加载的模块:
:set prompt "\ESC[33m\STX?> \ESC[m\STX"
Run Code Online (Sandbox Code Playgroud)
更新
[neo@nixos:~/HaskellLearning/IdeTest]$ stack ghci 以下 GHC 选项与 GHCi 不兼容,尚未传递给它: -threaded 使用以下包配置 GHCi: IdeTest 使用主模块: 1. 包 `IdeTest'组件 exe:IdeTest-exe 与 main-is 文件:/home/neo/HaskellLearning/IdeTest/app/Main.hs GHCi,版本 8.2.2:http : //www.haskell.org/ghc/ :? 寻求帮助 从 /home/neo/HaskellLearning/IdeTest/.ghci 加载 GHCi 配置 从 /home/neo/.ghci 加载 GHCi 配置 [1 of 9] 编译 Ch13
( /home/neo/HaskellLearning/IdeTest/src/Ch13.hs, 解释 ) [2 of 9] 编译 Ch15 ( /home/neo/HaskellLearning/IdeTest/src/Ch15.hs, 解释 ) [3 of 9] …
我只是注意到通过运行的 Haskell 程序stack不会从调用环境接收环境变量。这是一个示例程序:
-- testenv.hs
import System.Environment
main :: IO ()
main = print =<< getEnv "FOOBAR"
Run Code Online (Sandbox Code Playgroud)
如果我在没有堆栈的情况下运行它,就像这样,它可以工作:
% FOOBAR=123 runhaskell testenv.hs
"123"
Run Code Online (Sandbox Code Playgroud)
但是使用堆栈:
% FOOBAR=123 stack runhaskell testenv.hs
testenv.hs: FOOBAR: getEnv: does not exist (no environment variable)
Run Code Online (Sandbox Code Playgroud)
编译时也是如此:工作时FOOBAR=123 stack exec testenv失败FOOBAR=123 .stack-work/install/BLAHBLAH/testenv。
有没有办法强制堆栈传递某些环境变量?
我遇到的真正问题是yesod devel,我想用环境变量覆盖一些设置,但yesod devel使用堆栈来运行程序,因此它们不会通过。
这是 NixOS 18.03.132262.0a73111bc29 上的堆栈 1.6.5。
我正在尝试在项目中使用以下命令构建本地 hoogle 服务器,该项目lts-11.1用作解析器stack.yaml
stack hoogle -- server --local --port=8080
Run Code Online (Sandbox Code Playgroud)
它曾经可以工作,但现在由于此错误而失败:
? stack hoogle -- server --local --port=8080
Hoogle isn't installed. Automatically installing (use --no-setup to disable) ...
Minimum version is hoogle-5.0. Found acceptable hoogle-5.0.17.6 in your index, installing it.
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for hoogle-5.0.17.6:
haskell-src-exts-1.20.3 from stack configuration does not match >=1.21 && <1.22 (latest matching version is 1.21.0)
needed since hoogle is a build target. …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用stack设置happstack-lite应用程序。
我用这些命令初始化了项目:
stack new my-happstack
cd my-happstack
stack setup
Run Code Online (Sandbox Code Playgroud)
我更改了package.yaml,因此它包含:
dependencies:
- base >= 4.7 && < 5
- happstack-lite >= 7.3
Run Code Online (Sandbox Code Playgroud)
然后我多次运行stack build并根据建议更改了项目目录中stack.yaml中的extra-deps(添加了依赖项,例如happstack-server)。
显然,我被要求将已经列出的包添加到extra-deps中,它们具有不同的版本边界和相同的版本(template-haskell-2.11.1.0):
stack.yaml内容:
extra-deps:
- happstack-lite-7.3.6
- happstack-server-7.4.6.4
- Win32-2.2.2.0@sha256:10ed55dd31315f386910c121c1d1d442df83bd2ee92090a753cd65300735a8ca
- network-2.6.3.6@sha256:1ca79d81af02d7acd6032d5e6c9bde4618a8fdcfbe19bd42b49d420183975df0
- template-haskell-2.11.1.0@sha256:f90d6ab73ad35c749e8547ca132e7ab5d32d2f8e7bb2e2ff6d597be26b58e061
- transformers-compat-0.5.1.4@sha256:1b4bfa8589afb1ca0e719129ab261bd90ef0cc3e6c0b9963f94970c082b61250
Run Code Online (Sandbox Code Playgroud)
堆栈构建的输出:
F:\Projects\Haskell\my-happstack>stack build
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for Cabal-2.4.1.0: …Run Code Online (Sandbox Code Playgroud)