gem install rails -v 4.2.10 --source https://rubygems.org
on mac monterey getting error:
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Forbidden 403 (http://api.rubygems.org/quick/Marshal.4.8/nokogiri-1.13.1-x64-unknown.gemspec.rz)
I had the same issue. M1 Mac, while setting up to run Ruby 2.5.1 and an older Rails app.
I followed these steps from a Github comment:
gem update --system xcode-select --install (didn't need to do this, though it was a listed step) gem install nokogiri bundle install