[英]Using anyenv in Fish Shell
I tried to using anyenv in Fish Shell but the error occured. 我试图在Fish Shell中使用anyenv ,但发生了错误。
This is my ~./config/fish/config.fish
file. 这是我的
~./config/fish/config.fish
文件。
set -x PATH $HOME/.anyenv/bin $PATH
eval (anyenv init -)
What's wrong with this? 这怎么了
Errors which I got: 我得到的错误:
$# 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 '-'
Added: 添加:
I tried answer ( https://stackoverflow.com/a/42119354/7524270 ) but I get some new errors. 我尝试了答案( https://stackoverflow.com/a/42119354/7524270 ),但是出现了一些新的错误。
New Errors: 新错误:
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 '-'
In ~/.config/fish/config.fish , change: 在〜/ .config / fish / config.fish中 ,更改:
eval (anyenv init -)
to: 至:
eval (anyenv init - fish)
EDIT: or a slightly more bullet-proof approach: 编辑:或更防弹的方法:
eval (command anyenv init - fish)
( command
forces fish
to ignore functions) (
command
迫使fish
忽略功能)
anyenv init
uses the $SHELL
environment variable to determine your active shell and returns some commands, to be executed by the shell, in order to finish the initialization of anyenv
. anyenv init
使用$SHELL
环境变量来确定活动的shell并返回一些要由shell执行的命令,以完成anyenv
的初始化。
For some reason the $SHELL
variable in your environment points to bash
and not to fish
(you can verify this by running echo $SHELL
). 由于某种原因,您环境中的
$SHELL
变量指向bash
而不是指向fish
(您可以通过运行echo $SHELL
来验证这一点)。
The most probable reason is that fish
is simply not the default shell for your user. 最可能的原因是
fish
根本不是用户的默认外壳。 You may execute grep $USER /etc/passwd
to find out (look at what it says after the last :
). 您可以执行
grep $USER /etc/passwd
来查找(看看最后一个:
之后的内容)。 It's possible to change the default shell with chsh
, but if you decide to do it, do it with great care. 可以使用
chsh
更改默认的shell,但是如果您决定这样做,请务必谨慎。 There might be some important settings in your .bashrc
or some other programs may depend on a POSIX-compliant shell to work properly. .bashrc
可能有一些重要设置,或者某些其他程序可能依赖于POSIX兼容外壳程序才能正常工作。
Another option is that somewhere you have an override of the $SHELL
variable, such that it points to bash
and not fish
. 另一种选择是,在某个地方您可以重写
$SHELL
变量,以使其指向bash
而不是fish
。 I have this in my byobu
/ tmux
configuration because it helped me avoid some strange behavior. 我在
byobu
/ tmux
配置中拥有此功能,因为它帮助我避免了一些奇怪的行为。
Luckily, anyenv init
lets the user (you) specify the shell manually (ignore $SHELL
), and that should fix your issue with anyenv
. 幸运的是,
anyenv init
允许用户(您)手动指定外壳(忽略$SHELL
),这应该可以解决anyenv
的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.