Techioz Blog

MacO は、brew 経由でインストールされた Ruby のバージョンを変更します [終了]

概要

brew 経由でインストールされた Ruby があり、brew 経由でバージョンを更新しましたが、使用されているデフォルトのバージョンを変更できません。

手伝って頂けますか?

編集:

次に rbenv をインストールしましたが、Ruby のバージョン マネージャーはありませんでした。

rbenv 経由でバージョン 3.2.2 をインストールしました。手順は次のとおりです。

brew install rbenv 
rbenv install 3.2.2
rbenv use 3.2.2

私が持っているバージョンを確認すると、次のようになります。

端末上の場合は echo /Users/itayayuuicularu/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/bin:/Users/itayayuuicularu/.rbenv/versions/3.3.1/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@3/ bin:/Users/itayayuuicularu/Library/Caches/fnm_multishells/33805_1716205101477/bin:/Users/itayayuuicularu/.rbenv/shims:/Users/itayayuuicularu/.nodebrew/current/bin:/usr/local/opt/php@7.4/ sbin:/usr/local/opt/php@7.4/bin:/usr/local/opt/libxml2/bin:/Users/itayayuuicularu/.phpenv/shims:/opt/homebrew/opt/tidy-html5/lib:/ opt/homebrew/opt/icu4c/bin:/opt/homebrew/opt/openssl@1.1/bin:/opt/homebrew/opt/krb5/bin:/opt/homebrew/opt/libiconv/bin:/opt/homebrew/ opt/curl/bin:/opt/homebrew/opt/bzip2/bin:/opt/homebrew/opt/libxml2/bin:/opt/homebrew/opt/bison/bin:/Users/itayayuuicularu/.phpenv/bin:/ Users/itayayuuofficial/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security .cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd /codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/itayayuuicularu/.fzf/bin:/Users/itayayuuicularu/Documents/SDKs/flutter/bin 私はこれを取得します:

/Users/userName/.bun/bin:
/Users/userName/.nvm/versions/node/v18.17.1/bin:
/usr/local/bin:
/System/Cryptexes/App/usr/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/Library/TeX/texbin:
/Library/Apple/usr/bin:
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:
/Users/userName/.maestro/bin

解決策

更新された質問にあるように、rbenv がインストールされていますが、おそらく完全ではなく、rbenv 以外の Ruby バージョンが使用されています。

シェル構成ファイル (この場合は ~/.zshrc のようになります) を開き、次の行を最後に追加します

eval "$(rbenv init -)"

このスクリプトを現在のターミナル タブで直接実行することもできます。

参照: https://github.com/rbenv/rbenv#installation