aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-09-09 21:28:42 +0800
committerXu Cheng2015-09-10 13:37:14 +0800
commit12a4cf380814305c6972274dbee823414d5d200d (patch)
tree85cd337ada638371be3cacea1592122dbd145dc7 /Library
parent9dc461cb9f05a7f09c822ef9a45f5cace919e4c4 (diff)
downloadbrew-12a4cf380814305c6972274dbee823414d5d200d.tar.bz2
config: read ruby/python interpreter directly
Closes Homebrew/homebrew#43750. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/config.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/Library/Homebrew/cmd/config.rb b/Library/Homebrew/cmd/config.rb
index 9db2c43c6..855cb515c 100644
--- a/Library/Homebrew/cmd/config.rb
+++ b/Library/Homebrew/cmd/config.rb
@@ -74,19 +74,26 @@ module Homebrew
def describe_python
python = which "python"
- if %r{/shims/python$} =~ python && which("pyenv")
- "#{python} => #{Pathname.new(`pyenv which python`.strip).realpath}" rescue describe_path(python)
+ return "N/A" if python.nil?
+ python_binary = Utils.popen_read python, "-c", "import sys; sys.stdout.write(sys.executable)"
+ python_binary = Pathname.new(python_binary).realpath
+ if python == python_binary
+ python
else
- describe_path(python)
+ "#{python} => #{python_binary}"
end
end
def describe_ruby
ruby = which "ruby"
- if %r{/shims/ruby$} =~ ruby && which("rbenv")
- "#{ruby} => #{Pathname.new(`rbenv which ruby`.strip).realpath}" rescue describe_path(ruby)
+ return "N/A" if ruby.nil?
+ ruby_binary = Utils.popen_read ruby, "-e", \
+ 'include RbConfig;print"#{CONFIG["bindir"]}/#{CONFIG["ruby_install_name"]}#{CONFIG["EXEEXT"]}"'
+ ruby_binary = Pathname.new(ruby_binary).realpath
+ if ruby == ruby_binary
+ ruby
else
- describe_path(ruby)
+ "#{ruby} => #{ruby_binary}"
end
end