[英]Using anyenv in Fish Shell
我试图在Fish Shell中使用anyenv ,但发生了错误。
这是我的~./config/fish/config.fish
文件。
set -x PATH $HOME/.anyenv/bin $PATH
eval (anyenv init -)
这怎么了
我得到的错误:
$# is not supported. In fish, please use 'count $argv'.
- (line 1): begin; source "/Users/kasumi/.anyenv/libexec/../completions/anyenv.bash" anyenv() { typeset command command="$1" if [ "$#" -gt 0 ]; then shift fi command anyenv "$command" "$@" } export NDENV_ROOT="/Users/kasumi/.anyenv/envs/ndenv" export PATH="/Users/kasumi/.anyenv/envs/ndenv/bin:$PATH" export PATH="/Users/kasumi/.anyenv/envs/ndenv/shims:${PATH}" source "/Users/kasumi/.anyenv/envs/ndenv/libexec/../completions/ndenv.bash" ndenv rehash 2>/dev/null ndenv() { typeset command command="$1" if [ "$#" -gt 0 ]; then shift fi case "$command" in rehash|shell) eval "`ndenv "sh-$command" "$@"`";; *) command ndenv "$command" "$@";; esac }
^
from sourcing file -
called on line 60 of file /usr/local/Cellar/fish/2.4.0/share/fish/functions/eval.fish
in function 'eval'
called on line 6 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called on standard input
source: Error while reading file '-'
添加:
我尝试了答案( https://stackoverflow.com/a/42119354/7524270 ),但是出现了一些新的错误。
新错误:
Variables cannot be bracketed. In fish, please use "$PATH".
- (line 1): begin; source "/Users/kasumi/.anyenv/libexec/../completions/anyenv.fish" function anyenv set command $argv[1] set -e argv[1] command anyenv "$command" $argv end set -x NDENV_ROOT "/Users/kasumi/.anyenv/envs/ndenv" set -x PATH $PATH "/Users/kasumi/.anyenv/envs/ndenv/bin" export PATH="/Users/kasumi/.anyenv/envs/ndenv/shims:${PATH}" ndenv rehash 2>/dev/null ndenv() { typeset command command="$1" if [ "$#" -gt 0 ]; then shift fi case "$command" in rehash|shell) eval "`ndenv "sh-$command" "$@"`";; *) command ndenv "$command" "$@";; esac }
^
from sourcing file -
called on line 60 of file /usr/local/Cellar/fish/2.5.0/share/fish/functions/eval.fish
in function 'eval'
called on line 4 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called during startup
source: Error while reading file '-'
在〜/ .config / fish / config.fish中 ,更改:
eval (anyenv init -)
至:
eval (anyenv init - fish)
编辑:或更防弹的方法:
eval (command anyenv init - fish)
( command
迫使fish
忽略功能)
anyenv init
使用$SHELL
环境变量来确定活动的shell并返回一些要由shell执行的命令,以完成anyenv
的初始化。
由于某种原因,您环境中的$SHELL
变量指向bash
而不是指向fish
(您可以通过运行echo $SHELL
来验证这一点)。
最可能的原因是fish
根本不是用户的默认外壳。 您可以执行grep $USER /etc/passwd
来查找(看看最后一个:
之后的内容)。 可以使用chsh
更改默认的shell,但是如果您决定这样做,请务必谨慎。 .bashrc
可能有一些重要设置,或者某些其他程序可能依赖于POSIX兼容外壳程序才能正常工作。
另一种选择是,在某个地方您可以重写$SHELL
变量,以使其指向bash
而不是fish
。 我在byobu
/ tmux
配置中拥有此功能,因为它帮助我避免了一些奇怪的行为。
幸运的是, anyenv init
允许用户(您)手动指定外壳(忽略$SHELL
),这应该可以解决anyenv
的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.