Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

allow recognizing symlinked ruby in ruby_command #194

Merged
merged 2 commits into from

2 participants

@mpapis

fix to avoid rvm/rvm#609

for rubies not being named ruby it will check if ruby exists and is a link to the original name

so in case of jruby and rbx it will still use ruby

@eventualbuddha

s/then/than/

@eventualbuddha eventualbuddha merged commit 21a9822 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 19, 2011
  1. @mpapis
Commits on Nov 20, 2011
  1. @mpapis

    s/then/than/

    mpapis authored
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 1 deletion.
  1. +20 −1 lib/thor/util.rb
View
21 lib/thor/util.rb
@@ -216,9 +216,28 @@ def self.globs_for(path)
#
def self.ruby_command
@ruby_command ||= begin
- ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
+ ruby_name = RbConfig::CONFIG['ruby_install_name']
+ ruby = File.join(RbConfig::CONFIG['bindir'], ruby_name)
ruby << RbConfig::CONFIG['EXEEXT']
+ # avoid using different name than ruby (on platforms supporting links)
+ if ruby_name != 'ruby' && File.respond_to?(:readlink)
+ begin
+ alternate_ruby = File.join(RbConfig::CONFIG['bindir'], 'ruby')
+ alternate_ruby << RbConfig::CONFIG['EXEEXT']
+
+ # ruby is a symlink
+ if File.symlink? alternate_ruby
+ linked_ruby = File.readlink alternate_ruby
+
+ # symlink points to 'ruby_install_name'
+ ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
+ end
+ rescue NotImplementedError
+ # just ignore on windows
+ end
+ end
+
# escape string in case path to ruby executable contain spaces.
ruby.sub!(/.*\s.*/m, '"\&"')
ruby
Something went wrong with that request. Please try again.