From 12a4cf380814305c6972274dbee823414d5d200d Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Wed, 9 Sep 2015 21:28:42 +0800 Subject: [PATCH] config: read ruby/python interpreter directly Closes Homebrew/homebrew#43750. Signed-off-by: Xu Cheng --- Library/Homebrew/cmd/config.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/cmd/config.rb b/Library/Homebrew/cmd/config.rb index 9db2c43c69..855cb515c8 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