[英]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.