Techioz Blog

PATH 内の rbenv シムをチェックしています: 間違った位置で見つかりました

概要

rbenv-doctor コマンドを使用して rbenv の問題を確認しようとします。

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

これはわかります。

Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: found at wrong position 👈
  The directory `/Users/myname/.rbenv/shims' is present in PATH, but is listed too late.
  The Ruby version found in `/usr/local/opt/ruby/bin' will have precedence. Please reorder your PATH.

Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20210510)
Counting installed Ruby versions: 5 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK

これを強調したいと思います。

Checking for rbenv shims in PATH: found at wrong position

結果は、「PATH を並べ替えてください。」と表示されます。どうすればよいですか?

(更新) これは私の ./zshrc ファイル内の rbenv のものです

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/ruby/bin:$PATH"
export PATH="/usr/local/opt/krb5/bin:$PATH"
export PATH="/usr/local/opt/krb5/sbin:$PATH"

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH="/usr/local/sbin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH="/usr/local/opt/luajit-openresty/bin:$PATH"
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
export PATH="/usr/local/opt/ncurses/bin:$PATH"
export PATH="/usr/local/opt/ruby/bin:$PATH"

解決策

rbenv README より:

~/.rbenv/shims を PATH のどこに追加したか (おそらく ~/.bashrc や ~/.zshrc などのファイル内でしょうか?) を確認し、PATH の末尾ではなく先頭に追加していることを確認してください。

7.4/sbin:/usr/local/opt/php@7.4/bin:/usr/local/opt/libxml2/bin:/Users/itayayuuichirou/.phpenv/shims:/opt/homebrew/opt/tidy-html5/lib .cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/itayayuuicularu/.fzf/bin:/Users/itayayuuicularu/Documents/SDKs/flutter/bin 変数を使用できます。:/opt/homebrew/opt/icu4c/bin:/opt/homebrew/opt/openssl@1.1/bin:/opt/homebrew/opt/krb5/bin:/opt/homebrew/opt/libiconv/bin:/opt/ 走る:/Users/itayayuuicularu/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/bin:/Users/itayayuuicularu/.rbenv/versions/3.3.1/bin:/ の完全な内容を表示するにはhomebrew/opt/curl/bin:/opt/homebrew/opt/bzip2/bin:/opt/homebrew/opt/libxml2/bin:/opt/homebrew/opt/bison/bin:/Users/itayayuuicularu/.phpenv/bin usr/local/Cellar/rbenv/1.2.0/libexec:/Users/itayayuuicularu/Library/Caches/fnm_multishells/33854_1716205101510/bin:/Users/itayayuuicularu/Library/Application Support/fnm:/opt/homebrew/opt/openssl@ :/Users/itayayuuicularu/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple 3/bin:/Users/itayayuuicularu/Library/Caches/fnm_multishells/33805_1716205101477/bin:/Users/itayayuuicularu/.rbenv/shims:/Users/itayayuuicularu/.nodebrew/current/bin:/usr/local/opt/php@ .security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security

echo $PATH