diff options
author | Bundlerbot <bot@bundler.io> | 2019-04-24 10:52:26 +0000 |
---|---|---|
committer | Bundlerbot <bot@bundler.io> | 2019-04-24 10:52:26 +0000 |
commit | dea7c6dcc3658d4f7ffcebdd7147076b017dc8db (patch) | |
tree | 4134f93550cd34909e31db94d1f59439fceda53c | |
parent | 6f11812e8f7db34d0b94adbbe6803ed38bf8b151 (diff) | |
parent | d0fe3a054234f407ebd6b1ff9a35bf30ae67f020 (diff) | |
download | bundler-dea7c6dcc3658d4f7ffcebdd7147076b017dc8db.tar.gz |
Merge #7129
7129: Bundle env improvements r=deivid-rodriguez a=deivid-rodriguez
This came from debugging #7096.
### What was the end-user problem that led to this PR?
The problem was that `bundle env` is great, but could be more useful and accurate.
### What is your fix for the problem, implemented in this PR?
My fix is to start improving it, by dumping more paths, and more accurate information, and getting the paths tested.
### Why did you choose this fix out of the possible options?
I have a few more improvements in mind, but I want to keep my PRs small.
Co-authored-by: David RodrÃguez <deivid.rodriguez@riseup.net>
-rw-r--r-- | lib/bundler/env.rb | 5 | ||||
-rw-r--r-- | spec/bundler/env_spec.rb | 49 |
2 files changed, 52 insertions, 2 deletions
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb index 8be4746e59..a08db08aa0 100644 --- a/lib/bundler/env.rb +++ b/lib/bundler/env.rb @@ -100,8 +100,9 @@ module Bundler out << [" Full Path", Gem.ruby] out << [" Config Dir", Pathname.new(Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE).dirname] 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 << [" Gem Home", Gem.dir] + out << [" Gem Path", Gem.path.join(File::PATH_SEPARATOR)] + out << [" User Home", Gem.user_home] out << [" User Path", Gem.user_dir] out << [" Bin Dir", Gem.bindir] if defined?(OpenSSL) diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb index 20bd38b021..8323a9a7b3 100644 --- a/spec/bundler/env_spec.rb +++ b/spec/bundler/env_spec.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require "openssl" require "bundler/settings" RSpec.describe Bundler::Env do @@ -17,6 +18,54 @@ RSpec.describe Bundler::Env do expect(out).to include(OpenSSL::OPENSSL_VERSION) end + describe "rubygems paths" do + it "prints gem home" do + with_clear_paths("GEM_HOME", "/a/b/c") do + out = described_class.report + expect(out).to include("Gem Home /a/b/c") + end + end + + it "prints gem path" do + with_clear_paths("GEM_PATH", "/a/b/c:/d/e/f") do + out = described_class.report + expect(out).to include("Gem Path /a/b/c:/d/e/f") + end + end + + it "prints user home" do + with_clear_paths("HOME", "/a/b/c") do + out = described_class.report + expect(out).to include("User Home /a/b/c") + end + end + + it "prints user path" do + with_clear_paths("HOME", "/a/b/c") do + out = described_class.report + expect(out).to include("User Path /a/b/c/.gem") + end + end + + it "prints bin dir" do + with_clear_paths("GEM_HOME", "/a/b/c") do + out = described_class.report + expect(out).to include("Bin Dir /a/b/c/bin") + end + end + + private + + def with_clear_paths(env_var, env_value) + old_env_var = ENV[env_var] + ENV[env_var] = env_value + Gem.clear_paths + yield + ensure + ENV[env_var] = old_env_var + end + end + context "when there is a Gemfile and a lockfile and print_gemfile is true" do before do gemfile "gem 'rack', '1.0.0'" |