Rubyの新しいバージョンをインストールできない

実現したいこと

・Rubyのバージョン3.2.2をインストールしたい
・バージョンを上げた際に、再起動してもバージョンが戻らないようにしたい

前提

Rubyで作成したアプリのデプロイ作業を行なっています。現在、EC2上のrubyをインストールしています。

今のバージョンは ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

バージョンアップさせたい経緯としては、
bundle exec rails assets:precompile RAILS_ENV=productionコマンド時にロードエラーになってしまいます。その原因がrubyが古いためなのではないかと考えたため新しいバージョンにしてエラー試したい。

発生している問題

関連する全てのコマンドとログ [ec2-user@ip-172-31-4-50 dog_worker]$ sudo yum -y install gcc-c++ openssl-devel readline-devel Loaded plugins: extras_suggestions, langpacks, priorities, update-motd amzn2-core | 3.7 kB 00:00:00 Package gcc-c++-7.3.1-15.amzn2.x86_64 already installed and latest version Package 1:openssl-devel-1.0.2k-24.amzn2.0.6.x86_64 already installed and latest version Package readline-devel-6.2-10.amzn2.0.2.x86_64 already installed and latest version Nothing to do [ec2-user@ip-172-31-4-50 dog_worker]$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv fatal: destination path '/home/ec2-user/.rbenv' already exists and is not an empty directory. [ec2-user@ip-172-31-4-50 dog_worker]$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build fatal: destination path '/home/ec2-user/.rbenv/plugins/ruby-build' already exists and is not an empty directory. [ec2-user@ip-172-31-4-50 dog_worker]$ sudo ~/.rbenv/plugins/ruby-build/install.sh [ec2-user@ip-172-31-4-50 dog_worker]$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile [ec2-user@ip-172-31-4-50 dog_worker]$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile [ec2-user@ip-172-31-4-50 dog_worker]$ source ~/.bash_profile [ec2-user@ip-172-31-4-50 dog_worker]$ rbenv install 3.2.2 rbenv: /home/ec2-user/.rbenv/versions/3.2.2 already exists continue with installation? (y/N) yse To follow progress, use 'tail -f /tmp/ruby-build.20230415055549.27884.log' or pass --verbose Downloading ruby-3.2.2.tar.gz... -> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz Installing ruby-3.2.2... Installed ruby-3.2.2 to /home/ec2-user/.rbenv/versions/3.2.2 [ec2-user@ip-172-31-4-50 dog_worker]$ rbenv global 3.2.2 [ec2-user@ip-172-31-4-50 dog_worker]$ rbenv rehash [ec2-user@ip-172-31-4-50 dog_worker]$ rbenv exec gem install bundler Successfully installed bundler-2.4.12 Parsing documentation for bundler-2.4.12 Done installing documentation for bundler after 0 seconds 1 gem installed [ec2-user@ip-172-31-4-50 dog_worker]$ ruby -v ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] ←なぜかupdateされない

該当のソースコード

ソースコード

試したこと

いくつか参考になりそうに記事を見るけて試しましたが、解決に至りませんでした。

Rubyの公式サイトも試しましがうまくいきませんでした。
https://ruby.studio-kingdom.com/rbenv/ruby_build/

補足情報(FW/ツールのバージョンなど)

<EC2>
Bundler version 2.4.12
Rails 5.2.7
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

Bundler version 2.4.12 Rails 6.1.7.3 ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]

コメントを投稿

0 コメント