RubyGems – Stickler
Stickler – Manage gem repositories
http://copiousfreetime.rubyforge.org/stickler
Stickler – Manage gem repositories
http://copiousfreetime.rubyforge.org/stickler
Using ruby 1.8.6 and rubygems 1.0.1
If you get the error “can’t activate xxx, already activated yyy”, it can be hard to find the problem.
This version of custom_require.rb has some debug information that prints to the console to make this job easier.
This file updates the file of the same name in the directory
$RUBY_LIB_INSTALL_DIR/site_ruby/1.8/rubygems/custom_require.rb
where $RUBY_LIB_INSTALL_DIR is the base directory where internal Ruby libraries are stored for your particular installation. This is almost always either /usr/lib/ruby or /usr/local/lib/ruby.
In addition, in the following in the file:
$RUBY_LIB_INSTALL_DIR/site_ruby/1.8/rubygems.rb
Add an additional line so the code starting near line 12 looks like this fragment
module Gem
class LoadError < ::LoadError
attr_accessor :name, :version_requirement
end
DEBUG_ME = true unless defined?(Gem::DEBUG_ME)
end
Then, insert a statement similar to this at the start of the method ‘activate’ (near line 300).
puts "rubylib.rubygems activate gem #{gem.inspect} autorequire #{autorequire.inspect} version_requirements #{version_requirements.inspect}" if Gem::DEBUG_ME
Rubygems overrides the standard Ruby ‘require’ statement. If you need to see what RubyGems is actually doing, in the file
.../lib/ruby/site_ruby/1.8/rubygems/custom_require.rb
add code similar to the following:
def require(path) # :doc: (original code)
if ENV['RUBYGEM_DEBUG'] and ENV['RUBYGEM_DEBUG'] == 'true'
puts "\ngem rubygems 1.3.4 require called from"
1.upto(3) do |idx|
puts caller[idx,1]
end
puts "gem rubygems 1.3.4 require about to require \"#{path}\""
end
gem_original_require path # (original code)
Then create aliases similar to the following to turn ‘require’ debugging on and off.
alias rubygem_debug_on='export RUBYGEM_DEBUG=true' alias rubygem_debug_off='export RUBYGEM_DEBUG=false'
That’s it!
If you want to install a second suite of Ruby, Rubygems and gems, and allow the second suite to be used on demand you can follow something similar to the following manual procedure.
sudo mkdir /opt/ruby186
Install the basics, forcing them into the new structure
(this assumes you have the appropriate distributions unpacked in some build directory)
cd readline-5.2
make clean
./configure --prefix=/opt/ruby186
make
sudo make install
cd ../ruby-1.8.6-p111
make clean
./configure --prefix=/opt/ruby186 --disable-pthread --with-readline-dir=/opt/ruby186 --enable-shared
make
sudo make install
cd ../rubygems-1.3.4
export PATH=/opt/ruby186/bin:${PATH} # VITAL
sudo ruby setup.rb
alias rubyother='export PATH=/opt/ruby186/bin:${PATH}'
Put the alias into one of your shell startup files – e.g. ~/.bashrc
When you need to switch to this version of Ruby, open up a new terminal window, type ‘rubyother’ and you’re using the second version of Ruby. When you close the window, these settings disappear – which is what you want.