【问题标题】:How to get rid of annoying startup message from stack ghci?如何摆脱来自堆栈 ghci 的烦人的启动消息?
【发布时间】:2020-01-19 11:16:10
【问题描述】:

我正在使用 stack ghci 来启动我的 REPL,这基于我为 question on how to import a module installed with stack 得到的答案。这工作正常,但我最初收到一条警告消息 注意:没有指定本地目标,因此将启动一个没有包隐藏或包选项的普通 ghci。,然后是一堆关于包隐藏的建议和选项。我的猜测是,这是因为我还没有使用stack init 来设置项目,因为我还处于“玩耍和学习”状态并且还不想要项目。我还没有找到关于“没有本地目标”含义的解释,但是启动一个普通的 ghci 的效果正是我当时想要的。有没有办法抑制这个消息?看了stack --help,没找到合适的。

【问题讨论】:

    标签: haskell haskell-stack


    【解决方案1】:

    正如Note(非警告)所暗示的,启动了一个普通的ghci,这在使用stack 时是相当罕见的情况。

    ~$ stack ghci
    
    Note: No local targets specified, so a plain ghci will be started with no package hiding or package options.
    
          You are using snapshot: lts-14.12
    
          If you want to use package hiding and options, then you can try one of the following:
    
          * If you want to start a different project configuration than /home/username/.stack/global-project/stack.yaml, then you can use stack init to create a new stack.yaml for the packages in the
            current directory. 
    
          * If you want to use the project configuration at /home/username/.stack/global-project/stack.yaml, then you can add to its 'packages' field.
    
    Configuring GHCi with the following packages: 
    GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
    Loaded GHCi configuration from /tmp/haskell-stack-ghci/2a3bbd58/ghci-script
    Prelude> 
    

    这意味着尽管在没有 Note 的情况下获得相同行为所需要做的只是在全局堆栈环境的上下文中手动启动 ghci:

    ~$ stack exec -- ghci
    GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
    Prelude> 
    

    如果您想确保在 ghci 会话中安装了一些用于“玩耍和学习”的软件包,您可以将它们作为 --package 参数提供

    ~$ stack exec --package massiv -- ghci
    atomic-primops> using precompiled package
    cabal-doctest > using precompiled package
    scheduler     > using precompiled package
    massiv        > using precompiled package
    Completed 4 action(s).
    GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
    Prelude> import Data.Massiv.Array
    Prelude Data.Massiv.Array> 
    

    【讨论】:

      【解决方案2】:

      stack exec --ghci 在 lehins 的回答中对我不起作用,但 stack exec ghci 对我有用。

      【讨论】:

      • 不是exec --ghci,是exec -- ghci
      猜你喜欢
      • 2011-04-19
      • 2015-03-12
      • 1970-01-01
      • 2016-06-10
      • 2011-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-16
      相关资源
      最近更新 更多