更正我的 Linux $PATH 多个 rbenv 路径

Correcting my Linux $PATH of multiple rbenv paths

我刚接触 Linux Ubuntu,我在 Rails 安装时搞砸了 Ruby。 因此,我卸载了 Ruby 并尝试遵循 rbenv installation. 但是,我得到了这个堆栈跟踪:

martin@martyux:~$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: multiple
  You seem to have multiple rbenv installs in the following locations.
  Please pick just one installation and remove the others.

  /home/martin/.rbenv/bin/rbenv
  /usr/bin/rbenv
  /bin/rbenv

Checking for rbenv shims in PATH: not found
  The directory `/home/martin/.rbenv/shims' must be present in PATH for rbenv to work.
  Please run `rbenv init' and follow the instructions.

Checking `rbenv install' support: /home/martin/.rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20210119)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/home/martin/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK

我假设存在我之前尝试安装的 rbenv 实例,并且仍然以某种方式链接到 $PATH。我没有找到任何人遇到这个确切的问题,而且我还没有能力驾驭 Unix shell,所以我将不胜感激一些彻底的帮助。

我不知道你是怎么让 rbenv 在 /bin/rbenvusr/bin/rbenv 中结束的,但是我从他们的安装指南中看到你只需要 ~/.rbenv/bin/rbenv

假设你用的是bash,我想这些都是加到你的$PATH中的~/.bashrc。你应该找到类似这样的东西:

export PATH="$PATH:/bin/rbenv"

export PATH="$PATH:/usr/bin/rbenv"

您可以删除这些行。要正确清理,您还可以删除它们引用的 rbenv 安装。

最后,如错误消息所述,您希望 运行 rbenv init 在执行此操作后创建 shims 文件夹。

我的 ~/.bashrc

中没有 export PATH="$PATH:/bin/rbenv"export PATH="$PATH:/usr/bin/rbenv"

我只是运行

sudo apt-get purge ruby

sudo apt-get purge rbenv

然后

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash

只显示了一条路径。