Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rubygems'
module Gem
class << self
def hacked_set_paths(gpaths)
@gem_path = gpaths
@gem_path << Gem.dir
end
end
end
Gem.hacked_set_paths(["file:/a"])
p Gem.path
jruby-1.5.5 > require 'rubygems'
=> false
jruby-1.5.5 > Gem.path
=> ["/Users/ericanderson/.rvm/gems/jruby-1.5.5@warbler", "/Users/ericanderson/.rvm/gems/jruby-1.5.5@global"]
jruby-1.5.5 > ENV['GEM_PATH'] = 'a'
=> "a"
jruby-1.5.5 > Gem.clear_paths
=> nil
jruby-1.5.5 > Gem.path
=> ["/Users/ericanderson/.rvm/gems/jruby-1.5.5@warbler"]
jruby-1.5.5 > ENV['GEM_PATH']
=> "a"
~ (1.8.7) $ irb
ruby-1.8.7-p302 > require 'rubygems'
=> false
ruby-1.8.7-p302 > Gem.path
=> ["/Users/ericanderson/.rvm/gems/ruby-1.8.7-p302", "/Users/ericanderson/.rvm/gems/ruby-1.8.7-p302@global"]
ruby-1.8.7-p302 > ENV['GEM_PATH'] = "a"
=> "a"
ruby-1.8.7-p302 > Gem.clear_paths
=> nil
ruby-1.8.7-p302 > Gem.path
=> ["a", "/Users/ericanderson/.rvm/gems/ruby-1.8.7-p302"]
ruby-1.8.7-p302 > ENV['GEM_PATH']
=> "a"
module Gem
ConfigFile::PLATFORM_DEFAULTS['install'] = '--env-shebang'
ConfigFile::PLATFORM_DEFAULTS['update'] = '--env-shebang'
@jar_paths = []
class << self
alias_method :original_set_paths, :set_paths
def set_paths(gpaths)
original_set_paths(gpaths)
@gem_path.reject! {|p| !readable_path? p }
@jar_paths.each {|p| @gem_path << p unless @gem_path.include?(p) } if @jar_paths
end
def readable_path?(p)
p =~ /^file:/ || File.exists?(p)
end
end
@ericanderson

This comment has been minimized.

Copy link
Owner Author

@ericanderson ericanderson commented Feb 2, 2011

So, jruby_partial.rb has the code that jruby ships. There are 2 big duhs for my problems.

  1. In my IRB tests, the file obviously doesn't exist
  2. The place I was using this in code was trying to set file:/some.jar!afile.txt, but since gems will split on ':' it never matter!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment