我尝试在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 '-'
答案 0 :(得分:2)
在〜/ .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
根本不是您用户的默认shell。您可以执行grep $USER /etc/passwd
查找(查看上一次:
之后的内容)。可以使用chsh
更改默认shell,但如果您决定这样做,请务必小心谨慎。您的.bashrc
或其他一些程序中可能有一些重要设置可能依赖于符合POSIX标准的shell来正常工作。
另一个选择是,您可以覆盖$SHELL
变量,使其指向bash
而不是fish
。我在我的byobu
/ tmux
配置中有这个,因为它帮助我避免了一些奇怪的行为。
幸运的是,anyenv init
允许用户(您)手动指定shell(忽略$SHELL
),这应该可以解决anyenv
的问题。