Skip to content

Instantly share code, notes, and snippets.

@koseki
Created January 15, 2010 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koseki/278021 to your computer and use it in GitHub Desktop.
Save koseki/278021 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
# -----------------------------------------------
# $ gem --version
# 1.3.5
# $ mkdir gemtest
# $ cd gemtest
# $ gem install -i . bluecloth
# $ gem_path_test.rb . bluecloth
# ERROR
# ERROR
# ERROR
# OK
# -----------------------------------------------
require 'rubygems'
Gem.path.unshift(ARGV[0])
def try_require
begin
require ARGV[1]
puts "OK"
rescue LoadError
puts "ERROR"
end
end
try_require # -> ERROR
Gem.refresh
try_require # -> ERROR
# Why need this line?
Gem.source_index.spec_dirs = Gem::SourceIndex.installed_spec_directories
try_require # -> ERROR
Gem.refresh
try_require # -> OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment