Installed Ubuntu 11.10, removed Ruby1.8.7 completely, and then installed Ruby1.9.2-p290 from source, followed by rubygems1.8.10. Here’s the script I ran for installation …
#!/bin/bash
#===============================================================================
#
# FILE: install_ruby_1.9.sh
#
# USAGE: ./install_ruby_1.9.sh
#
# AUTHOR: Ryan Schulze (rs), ryan@dopefish.de
# CREATED: 07/07/2011 11:59:37 AM CDT
#===============================================================================
Version="1.9.2-p290"
GZFile="ruby-${Version}.tar.gz"
Download="http://ftp.ruby-lang.org/pub/ruby/1.9/${GZFile}"
if [[ "$(id -u)" != "0" ]]
then
echo "You need root permission to execute this script"
exit
fi
apt-get -q update
apt-get -qy upgrade
apt-get install -qy build-essential wget zlib1g-dev libssl-dev libffi-dev autoconf
cd /usr/local/src/
test -e ${GZFile} || wget ${Download}
tar -xzf ${GZFile}
cd ruby-${Version}
autoconf
./configure --with-ruby-version=${Version} --prefix=/usr --program-suffix=${Version}
make
make install
mkdir -p /usr/lib/ruby/gems/${Version}/bin
update-alternatives \
--install /usr/bin/ruby ruby /usr/bin/ruby${Version} $(echo ${Version//./}|cut -d- -f1) \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby${Version}.1 \
--slave /usr/lib/ruby/gems/bin gem-bin /usr/lib/ruby/gems/${Version}/bin \
--slave /usr/bin/irb irb /usr/bin/irb${Version} \
--slave /usr/bin/gem gem /usr/bin/gem${Version} \
update-alternatives --config ruby
update-alternatives --display gem >/dev/null 2>&1 && update-alternatives --remove-all gem
…
The script ran perfectly, and ruby works fine …. except for rubygems (which was also installed from source):
$: irb
irb(main):001:0> require 'rubygems'
=> false
But, it points to the correct version:
$: which gem
/usr/bin/gem
$: file /usr/bin/gem
/usr/bin/gem: symbolic link to `/etc/alternatives/gem'
$: file /etc/alternatives/gem
/etc/alternatives/gem: symbolic link to `/usr/bin/gem1.9.2-p290'
Also, here’s the gem environment:
$: gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.2-p290/bin/
- RUBY EXECUTABLE: /usr/bin/ruby1.9.2-p290
- EXECUTABLE DIRECTORY: /usr/lib/ruby/gems/1.9.2-p290/bin/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.9.2-p290/bin/
- /home/rbanerjee/.gem/ruby/1.9.2-p290
- /usr/lib/ruby/gems/1.9.2-p290
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I am at a loss as to what happened. Similar upgrades worked when, in another machine, I had gone from 1.8.7 to 1.9.1. I have tried providing all the details, making this a long question. Any help at all will be greatly appreciated.
In Ruby 1.9,
require 'rubygems'always returns false. The Rubygems package is included in 1.9 so you don’t need to require it separately.Are you seeing a problem beyond the false return value? (i.e. are your gems not actually working?)