【问题标题】:`shell: bash -l {0}` in GitHub ActionsGitHub Actions 中的`shell: bash -l {0}`
【发布时间】:2021-11-03 07:40:53
【问题描述】:

当我使用setup-miniconda 时,它在GitHub Actions 中使用shell: bash -l {0}

jobs:
  foo:
    name: Foo
    runs-on: "ubuntu-latest"
    defaults:
      run:
        shell: bash -l {0}

当我使用CML 时。它只使用shell: bash 而没有-l {0}

我在GitHub Actions doc找到了一些解释:

您可以使用command […options] {0} [..more_options]shell 值设置为模板字符串。 GitHub 将字符串的第一个以空格分隔的单词解释为命令,并在 {0} 处插入临时脚本的文件名。

但是我还是不清楚-l{0}的作用是什么?对于-l,是不是bash的参数?

感谢您的一些解释!

【问题讨论】:

  • -l 当然意味着 run as login shell (参见 bash 手册页),但我不知道 {0} 应该做什么。至少在 bash 上下文中没有意义。

标签: bash shell github-actions


【解决方案1】:

这可能与issue 128 相关联,其中指出:

我被卡住了一段时间,因为我的运行命令没有使用登录 bash shell。
所以 conda 环境没有激活。

对此提出警告并在 yaml 中推荐如下内容会有所帮助:

defaults:
  run:
    shell: bash -l {0}

与:

  • -l 确保 login bash 环境设置正确;
  • {0},一个模板占位符,在管道执行时替换为要执行的实际脚本命令。

【讨论】:

  • 感谢@VonC,想得到-l {0}部分的一些解释,因为我发现网上有些代码正在使用它,有些没有。
  • @HongboMiao -l 是重要的部分,以确保正确设置环境的登录 bash。
  • 知道了!我尝试在本地终端中运行bash -l,它启动了一个 bash 会话。 {0}呢?
  • and inserts the file name for the temporary script at {0}:这是一个模板占位符,在管道执行时替换为实际的脚本源文件。
猜你喜欢
  • 2020-10-23
  • 2021-05-22
  • 2021-09-23
  • 2020-01-14
  • 2022-10-05
  • 2020-03-31
  • 1970-01-01
  • 1970-01-01
  • 2021-10-11
相关资源
最近更新 更多