'can't install rails 4.2.10 with source "http://rubygems.org" getting forbidden error

While installing

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)


Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Olliedee