【问题标题】:Snakemake change conda activation command to 'conda activate'Snakemake 将 conda 激活命令更改为“conda activate”
【发布时间】:2020-07-23 07:07:34
【问题描述】:

我想在我的托管环境中使用带有fish shell 和 conda 环境的snakemake(基本上我没有 root 权限,并且无法更改默认 shell)。

我在.bashrc 中使用这个hack 将fish 设置为“默认”外壳:

if [ "$REALBASH" != "1" ]; then
  case "$-" in
  *i*)
    export SHELL=/usr/bin/fish
    tty > /dev/null && echo "Your ~/.bashrc is switching interactive SHELL to $SHELL"
    [ -x $SHELL ] && exec $SHELL "$@"
    echo "Apparently $SHELL is not available here. Continuing with bash."
    export SHELL=/bin/bash
  ;;
  esac
fi

还有一个命令realbash 设置环境变量REALBASH=1 来绕过这个hack。

我设法让 conda 使用 this 与 fish 一起工作,但它的缺点是在 fish 中激活 conda 环境的命令与 bash 不同。在 bash 中,命令是 source activate ...,在 fish 中是 conda activate ...

使用source activate ... 的bash 和使用conda activate ... 的fish 都可以激活环境。

当我现在从fish执行snakemake时,我收到以下错误:

Activating conda environment ...
source: Error encountered while sourcing file “activate”:
source: No such file or directory

如果我从 bash 执行 snakemake,也会出现同样的错误。

如果我通过snakemake --overwrite-shellcmd realbash 从bash 执行snakemake,我会得到同样的错误并最终进入由snakemake 打开的bash shell。只有在输入 exit 之后,snakemake 才会完成(当然,但没有成功)。 如果我通过snakemake --overwrite-shellcmd realbash 从fish 执行snakemake,则会发生相同的行为。

我对 --overwrite-shellcmd 的行为感到困惑,有没有办法让我的 hack 工作? 否则,我可以将snakemake 配置为调用conda activate 而不是source activate? 或者有其他解决办法吗?

【问题讨论】:

    标签: bash conda snakemake fish


    【解决方案1】:

    显然这是snakemake 旧版本中的一个错误。问题中描述的效果是用snakemake 4.3.1产生的。

    在安装了snakemake 5.17.0conda 环境中运行snakemake 与问题中所述的设置完美配合。不需要--overwrite-shellcmd 或其他更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-13
      • 1970-01-01
      • 1970-01-01
      • 2020-12-06
      • 1970-01-01
      • 2017-07-17
      • 2022-09-27
      • 2019-08-30
      相关资源
      最近更新 更多