LoginSignup
4
5

More than 3 years have passed since last update.

Ruby 3.0.0 から 2.7.2 にダウングレードさせる。

Last updated at Posted at 2021-02-21

エラー

Unicorn が起動できない問題にぶつかった。

[User@ip-address app_name]$ bundle exec unicorn_rails -c /var/www/rails/app_name/config/unicorn.conf.rb -D -E production
master failed to start, check stderr log for details

ヒントになったサイト

解決した方法
Rubyのバージョンを2.7.2、unicornのバージョンを5.4.1にダウングレードしたら動きました。
どうやらRubyの3.0.0にunicornが対応していないらしいです。

[User@ip-address app_name]$ cd log
[User@ip-address log]$ tail unicorn.log
I, [2021-02-21T04:10:46.311290 #15000]  INFO -- : Refreshing Gem list
/home/User/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn.rb:80: [BUG] Segmentation fault at 0x0000000000000001
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

-- Control frame information -----------------------------------------------
I, [2021-02-21T04:14:21.956504 #15066]  INFO -- : Refreshing Gem list
/home/User/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn.rb:86: [BUG] Segmentation fault at 0x0000000000000000
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

-- Control frame information -----------------------------------------------

エラーログを見てみると、確かに 3.0.0 が邪魔をしている様子。

バージョン確認

[User@ip-address app_name]$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
[User@ip-address log]$ unicorn -version
unicorn v5.8.0

Gemファイル編集

[User@ip-address app_name]$ vim Gemfile #rubyを2.7.2に、unicornを5.4.1に書き換える。

bundle install

[User@ip-address app_name]$ bundle install
Your Ruby version is 3.0.0, but your Gemfile specified 2.7.2

おや、エラーだ。Gemfileを書き換えただけではダメみたい。

rbenvでインストールされているバージョン確認する

[User@ip-address app_name]$ rbenv versions
* 3.0.0 (set by /var/www/rails/app_name/.ruby-version) 

rbenv で ruby 2.7.2 をダウンロードする。

[User@ip-address rails]$ rbenv install 2.7.2
Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...
Installed ruby-2.7.2 to /home/User/.rbenv/versions/2.7.2

再度rbenvでバージョン確認する

[User@ip-address app_name]$ rbenv versions
  2.7.2
* 3.0.0 (set by /var/www/rails/app_name/.ruby-version)

##rbenvで2.7.2に置き換える。
[User@ip-address rails]$ rbenv global 2.7.2
[User@ip-address app_name]$ rbenv local 2.7.2
[User@ip-address app_name]$ rbenv versions
* 2.7.2 (set by /var/www/rails/app_name/.ruby-version)
  3.0.0

※ 修正(2020年2月22日)
この後、私は手探りしながら以下のコマンドを打ち込んでいましたが、不要のようであるため、コードから削除しました。
[User@ip-address app_name]$ rbenv rehash

参考サイト:rbenvでrehashがいらなくなった
@jnchito 様、ご指摘ありがとうございます。)

bundle install

[User@ip-address app_name]$ bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Fetching rake 13.0.3
Installing rake 13.0.3
Fetching concurrent-ruby 1.1.8
Installing concurrent-ruby 1.1.8
Fetching i18n 1.8.9
Installing i18n 1.8.9

通った。

4
5
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5