Ruby upgrading causes gem breakage

I have been playing with this for a bit now. It appears that recent
upgrades to RUby and Gem have broken things.

I was having all kinds of issues with native code compiling (Ubuntu
14.10), and nothing the Mac guys were trying worked, so I started over
by installing ruby-2.1.5 from source. Okay, so far so good; had to
re-install gems so this time I went conservative and installed rails -v
4.0.12. Great, everything worked and all the native compile failures
disappeared, except for one: ruby-postgres. Major improvement, so I felt
good.

Encouraged, I tried gem update --system, then gem update. Whoops, I
said, as I saw that gem update was happily updating Rails. Sure enough
all the failures are now back again.

These are not rails-specific gem failures, which is why I am posting
here. Nokogiri, for example, now fails. I’ve been joyfully using Ruby
since about 2004, so I’m not exactly a newbie although my work has had
me using that horrid language that begins with A ‘J’ for the last two
years.

A further examination shows that there is a backwards compatibility
snafu regarding files in /usr/local/include/ruby-2.2.0/ruby/backward/.

There are two files in question, and although I mkdir ruby and mv st.h
ruby/st.h and mv rubyio.h ruby/io.h as seemed to be suggested, the
native code compilation is getting into a recursive stack crash.

Staying on rails -v 4.0.12 seems to have cured most of these errors,
but I can’t seem to get a working postgres adapter, nor does the default
sqlite3 gem install.