また例によって自分なりの解決法を記述します。
対象
- 主に古いソースを引き継いで、それを実行しようとしている人向け
- 古いRubyでもとりあえず問題ない人向け
手順
Rubyを複数バージョンインストール
筆者の場合は既にインストールされている2.5.1に加え、2.2.6をインストールしました。
console
[vagrant@localhost ~]$ rbenv install 2.2.6
Downloading ruby-2.2.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.6.tar.bz2
Installing ruby-2.2.6...
WARNING: ruby-2.2.6 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
Installed ruby-2.2.6 to /home/vagrant/.rbenv/versions/2.2.6
[vagrant@localhost ~]$ rbenv global 2.2.6
[vagrant@localhost ~]$ rbenv versions
* 2.2.6 (set by /home/vagrant/.rbenv/version)
2.5.1
.ruby_version修正
console
2.2.6
これで動くかと思いきや「The `rails' command exists in these Ruby versions:」などと言われるので諸々インストールします。
Ruby2.2.6用に諸々インストール
bundler
console
[vagrant@localhost ~]$ rbenv exec gem install bundler
Fetching: bundler-1.16.3.gem (100%)
Successfully installed bundler-1.16.3
Parsing documentation for bundler-1.16.3
Installing ri documentation for bundler-1.16.3
Done installing documentation for bundler after 4 seconds
1 gem installed
rails
console
[vagrant@localhost ~]$ gem install rails
(中略)
Done installing documentation for concurrent-ruby, thread_safe, (中略) rails after 60 seconds
38 gems installed
プロジェクトのパッケージも再インストール
console
[vagrant@localhost ~]$ bundle install
(中略)
================================================================================
Rails 2.x
---------
If you are using Seedbank with Rails 2.x you will need to place the following at
the end of your Rakefile so Rubygems can load the seedbank tasks;
require 'seedbank'
Seedbank.load_tasks if defined?(Seedbank)
Rails 3.x and 4.x
---------
Your work here is done!
================================================================================
マイグレーション
必要あれば
console
$ rake db:migrate
参考
https://qiita.com/toshiro3/items/6f2ee61f552fc4885317
https://qiita.com/ironsand/items/8617ba82767884528246
http://shiro-16.hatenablog.com/entry/2014/07/01/003435