[Rubygems-developers] Bug in Gem.bin_path - gem bin scripts are broken if there are spaces in GEM_HOME env. variable (on Windows)

Gordon Thiesfeld gthiesfeld at gmail.com
Mon Jun 29 10:30:13 EDT 2009


First of all, I apologize for not submitting this on the rubyforge
tracker.  I can't log in to rubyforge from work because of a proxy,
and anonymous submissions are not allowed.  I can submit it this
evening, if need be.

Summary:
gem bin scripts are broken if there are spaces in GEM_HOME env.
variable (on Windows)

Description:

If you try to run a bin script created by rubygems, ruby is unable to
load the file inside the gem's bin dir.  This is because Gem.bin_path
wraps paths with spaces in quotes.  This was added for #25734.
Gem.bin_path was modified to work on the Windows command line, but is
broken when used with Kernel#load

C:\scripts\repo\rubygems>pik list
C:/Documents and Settings/gthiesfeld/.gem/ruby/1.8/bin/pik:19:in
`load': no such file to load -- "C:/documents and
settings/gthiesfeld/.gem/ruby/1.8/gems/pik-0.0.2/bin/pik" (LoadError)
        from C:/Documents and Settings/gthiesfeld/.gem/ruby/1.8/bin/pik:19

C:\scripts\repo\rubygems>cat "c:\Documents and
Settings\gthiesfeld\.gem\ruby\1.8\bin\pik" | grep -n load
19:load Gem.bin_path('pik', 'pik', version)

C:\scripts\repo\rubygems>svn blame lib\rubygems.rb | grep -n -A 2 -B 2 2183
384-  2064    drbrain     end
385-  2064    drbrain
386:  2183      raggi     File.join(spec.full_gem_path, spec.bindir,
exec_name).sub(/.*\s.*/m, '"\&"')
387-  2064    drbrain   end
388-  2064    drbrain

C:\scripts\repo\rubygems>svn log | grep -A 4 2183
r2183 | raggi | 2009-05-01 04:56:11 -0500 (Fri, 01 May 2009) | 2 lines

Gem.bin_path now escapes paths with spaces. Thanks to Luis Lavena in #25734.

------------------------------------------------------------------------


C:\scripts\repo\rubygems>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.4
  - RUBY VERSION: 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/documents and settings/gthiesfeld/.gem/ruby/1.8
  - RUBY EXECUTABLE: c:/ruby/186-p368-mingw32/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/documents and settings/gthiesfeld/.gem/ruby/1.8/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/documents and settings/gthiesfeld/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/



Thanks,

Gordon Thiesfeld


More information about the Rubygems-developers mailing list