diff options
author | The Bundler Bot <bot@bundler.io> | 2017-09-13 22:50:51 +0000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-09-18 13:41:56 -0500 |
commit | acbe31104bade2729d2616dfac9254ddd63c7c88 (patch) | |
tree | 6d7ac04af7d976a6ef652bda2c689ad9126f4e31 | |
parent | 050d711ff96706d04a6080fca274c597bc08d211 (diff) | |
download | bundler-acbe31104bade2729d2616dfac9254ddd63c7c88.tar.gz |
Auto merge of #6011 - bundler:indirect/expand-env, r=indirect
Expand `env` output
We've been printing the version of OpenSSL that Ruby was compiled against, but not the version that was dynamically linked at runtime, which is a huge potential issue. While I was there, I added a few more things that seemed helpful.
(cherry picked from commit 0d38f6604c425228cb6ca87c7121e67b23966b6f)
-rw-r--r-- | lib/bundler/env.rb | 41 | ||||
-rw-r--r-- | spec/bundler/env_spec.rb | 2 |
2 files changed, 33 insertions, 10 deletions
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb index e3b11d9030..437dafc65f 100644 --- a/lib/bundler/env.rb +++ b/lib/bundler/env.rb @@ -86,21 +86,44 @@ module Bundler "not installed" end + def self.version_of(script) + return "not installed" unless Bundler.which(script) + `#{script} --version` + end + + def self.chruby_version + return "not installed" unless Bundler.which("chruby-exec") + `chruby-exec -- chruby --version`. + sub(/.*^chruby: (#{Gem::Version::VERSION_PATTERN}).*/m, '\1') + end + def self.environment out = [] out << ["Bundler", Bundler::VERSION] - out << ["RubyGems", Gem::VERSION] + out << [" Platforms", Gem.platforms.join(", ")] out << ["Ruby", ruby_version] - out << ["GEM_HOME", ENV["GEM_HOME"]] unless ENV["GEM_HOME"].nil? || ENV["GEM_HOME"].empty? - out << ["GEM_PATH", ENV["GEM_PATH"]] unless ENV["GEM_PATH"].nil? || ENV["GEM_PATH"].empty? - out << ["RVM", ENV["rvm_version"]] if ENV["rvm_version"] - out << ["Git", git_version] - out << ["Platform", Gem::Platform.local] - out << ["OpenSSL", OpenSSL::OPENSSL_VERSION] if defined?(OpenSSL::OPENSSL_VERSION) + out << [" Full Path", Gem.ruby] + out << [" Config Dir", Gem::ConfigFile::SYSTEM_CONFIG_PATH] + out << ["RubyGems", Gem::VERSION] + out << [" Gem Home", ENV.fetch("GEM_HOME") { Gem.dir }] + out << [" Gem Path", ENV.fetch("GEM_PATH") { Gem.path.join(File::PATH_SEPARATOR) }] + out << [" User Path", Gem.user_dir] + out << [" Bin Dir", Gem.bindir] + out << ["OpenSSL"] if defined?(OpenSSL) + out << [" Compiled", OpenSSL::OPENSSL_VERSION] if defined?(OpenSSL::OPENSSL_VERSION) + out << [" Loaded", OpenSSL::OPENSSL_LIBRARY_VERSION] if defined?(OpenSSL::OPENSSL_LIBRARY_VERSION) + out << [" Cert File", OpenSSL::X509::DEFAULT_CERT_FILE] if defined?(OpenSSL::X509::DEFAULT_CERT_FILE) + out << [" Cert Dir", OpenSSL::X509::DEFAULT_CERT_DIR] if defined?(OpenSSL::X509::DEFAULT_CERT_DIR) + out << ["Tools"] + out << [" Git", git_version] + out << [" RVM", ENV.fetch("rvm_version") { version_of("rvm") }] + out << [" rbenv", version_of("rbenv")] + out << [" chruby", chruby_version] + %w[rubygems-bundler open_gem].each do |name| specs = Bundler.rubygems.find_name(name) - out << [name, "(#{specs.map(&:version).join(",")})"] unless specs.empty? + out << [" #{name}", "(#{specs.map(&:version).join(",")})"] unless specs.empty? end if (exe = caller.last.split(":").first) && exe =~ %r{(exe|bin)/bundler?\z} shebang = File.read(exe).lines.first @@ -125,6 +148,6 @@ module Bundler out << "```\n" end - private_class_method :read_file, :ruby_version, :git_version, :append_formatted_table + private_class_method :read_file, :ruby_version, :git_version, :append_formatted_table, :version_of, :chruby_version end end diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb index fbb7ec3c22..83c03e67d5 100644 --- a/spec/bundler/env_spec.rb +++ b/spec/bundler/env_spec.rb @@ -136,7 +136,7 @@ RSpec.describe Bundler::Env do and_return("git version 1.2.3 (Apple Git-BS)") expect(Bundler::Source::Git::GitProxy).to receive(:new).and_return(git_proxy_stub) - expect(described_class.report).to include("Git 1.2.3 (Apple Git-BS)") + expect(described_class.report).to include("Git 1.2.3 (Apple Git-BS)") end end end |