通过堆栈安装`--flag`来堆栈运行?

时间:2019-01-26 16:16:30

标签: haskell-stack

如何像使用<input name="ids[]" value="1" type="radio" class="multiradio"> <input name="ids[]" value="2" type="radio" class="multiradio"> <input name="ids[]" value="3" type="radio" class="multiradio"> p params[:ids] @advert = Advert.new(advert_params) if (params[:ids] == "1") @advert.update(category: "1") elsif (params[:ids] == "2") @advert.update(category: "2") elsif (params[:ids] == 3) @advert.update(category: "3") else @advert.update(category: "9") end 一样将标志传递给stack run

1 个答案:

答案 0 :(得分:0)

我找不到执行此操作的方法,所以这是我建议的解决方法:

使用stack run ...来构建应用程序并直接运行程序,而不是使用stack build

所以,不要使用

# The Problem: This doesn't work because run doesn't recognize --flag

> stack run --flag asd:qwe

使用以下两步方法:

  1. stack build --flag asd:qwe
  2. ./path/to/your/executable/<your executable>

如果您使用的是stack install而不是stack build,则堆栈会将编译后的二进制文件放在local-bin目录中。¹The documentation suggests that you add this directory to your $PATH variable,这意味着您可以调用{{ 1}}。

此响应的其余部分假定您正在使用<your-executable>

在我的系统上(Arch linux,19年5月,堆栈1.9.3.1),堆栈将编译后的二进制文件放入stack build内的bin文件夹中。 (使用local-install-root显示它。)

可执行文件的完整路径应为stack path --local-install-root

¹根据The User guide,对<local-install-root>/bin/<executable-name>的含义经常感到困惑。它是stack install的别名,它只是在构建后将二进制文件复制到stack build --copy-bins,如果$ PATH包含local-bin-path

,它通常就可以使用。
相关问题