summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--lib/bundler/definition.rb2
-rw-r--r--lib/bundler/dependency.rb9
-rw-r--r--lib/bundler/dsl.rb3
-rw-r--r--lib/bundler/gem_helpers.rb6
-rw-r--r--lib/bundler/settings.rb8
-rw-r--r--spec/bundler/dsl_spec.rb34
-rw-r--r--spec/commands/check_spec.rb2
-rw-r--r--spec/commands/update_spec.rb68
-rw-r--r--spec/install/gemfile/gemspec_spec.rb82
-rw-r--r--spec/lock/lockfile_spec.rb62
-rw-r--r--spec/runtime/setup_spec.rb2
-rw-r--r--spec/support/hax.rb9
-rw-r--r--spec/support/helpers.rb10
-rw-r--r--spec/support/platforms.rb4
-rw-r--r--spec/update/git_spec.rb2
16 files changed, 222 insertions, 83 deletions
diff --git a/.travis.yml b/.travis.yml
index bc94d34c58..c7d6deb873 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,7 +28,7 @@ rvm:
- 1.8.7
# Rubygems versions MUST be available as rake tasks
-# see Rakefile:66 for the list of possible RGV values
+# see Rakefile:125 for the list of possible RGV values
env:
# We need to know if changes to rubygems will break bundler on release
- RGV=master
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index ed755ba2ac..2729ca75b0 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -635,7 +635,7 @@ module Bundler
dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
next unless remote || dep.current_platform?
dep.gem_platforms(@platforms).each do |p|
- deps << DepProxy.new(dep, p) if remote || p == generic(Gem::Platform.local)
+ deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
end
end
deps
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 153f363de5..a62808d23c 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -54,6 +54,15 @@ module Bundler
:x64_mingw_23 => Gem::Platform::X64_MINGW
}.freeze
+ REVERSE_PLATFORM_MAP = {}.tap do |reverse_platform_map|
+ PLATFORM_MAP.each do |key, value|
+ reverse_platform_map[value] ||= []
+ reverse_platform_map[value] << key
+ end
+
+ reverse_platform_map.each {|_, platforms| platforms.freeze }
+ end.freeze
+
def initialize(name, version, options = {}, &blk)
type = options["type"] || :runtime
super(name, version, type)
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 355c39ee56..b09a838fbb 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -60,7 +60,8 @@ module Bundler
"#{file}. Make sure you can build the gem, then try again"
end
- gem spec.name, :path => path, :glob => glob
+ gem_platforms = Bundler::Dependency::REVERSE_PLATFORM_MAP[Bundler::GemHelpers.generic_local_platform]
+ gem spec.name, :path => path, :glob => glob, :platforms => gem_platforms
group(development_group) do
spec.development_dependencies.each do |dep|
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
index ac83e6fb92..146998957d 100644
--- a/lib/bundler/gem_helpers.rb
+++ b/lib/bundler/gem_helpers.rb
@@ -21,5 +21,11 @@ module Bundler
found || Gem::Platform::RUBY
end
end
+ module_function :generic
+
+ def generic_local_platform
+ generic(Gem::Platform.local)
+ end
+ module_function :generic_local_platform
end
end
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 1ca41e2e71..528d4f6aa2 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -224,17 +224,15 @@ module Bundler
end
def load_config(config_file)
- valid_file = config_file && config_file.exist? && !config_file.size.zero?
- if !ignore_config? && valid_file
+ SharedHelpers.filesystem_access(config_file, :read) do
+ valid_file = config_file && config_file.exist? && !config_file.size.zero?
+ return {} if ignore_config? || !valid_file
config_regex = /^(BUNDLE_.+): (['"]?)(.*(?:\n(?!BUNDLE).+)?)\2$/
- raise PermissionError.new(config_file, :read) unless config_file.readable?
config_pairs = config_file.read.scan(config_regex).map do |m|
key, _, value = m
[convert_to_backward_compatible_key(key), value.gsub(/\s+/, " ").tr('"', "'")]
end
Hash[config_pairs]
- else
- {}
end
end
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index 27f9feec95..2d323d64f4 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -145,6 +145,40 @@ describe Bundler::Dsl do
end
end
+ describe "#gemspec" do
+ let(:spec) do
+ Gem::Specification.new do |gem|
+ gem.name = "example"
+ gem.platform = platform
+ end
+ end
+
+ before do
+ allow(Dir).to receive(:[]).and_return(["spec_path"])
+ allow(Bundler).to receive(:load_gemspec).with("spec_path").and_return(spec)
+ allow(Bundler).to receive(:default_gemfile).and_return(Pathname.new("./Gemfile"))
+ end
+
+ context "with a ruby platform" do
+ let(:platform) { "ruby" }
+
+ it "keeps track of the ruby platforms in the dependency" do
+ subject.gemspec
+ expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::RUBY])
+ end
+ end
+
+ context "with a jruby platform" do
+ let(:platform) { "java" }
+
+ it "keeps track of the jruby platforms in the dependency" do
+ allow(Gem::Platform).to receive(:local).and_return(java)
+ subject.gemspec
+ expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::JAVA])
+ end
+ end
+ end
+
context "can bundle groups of gems with" do
# git "https://github.com/rails/rails.git" do
# gem "railties"
diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb
index eb74bd809a..02e81156ab 100644
--- a/spec/commands/check_spec.rb
+++ b/spec/commands/check_spec.rb
@@ -298,7 +298,7 @@ describe "bundle check" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index 6bdca75ffe..f80129030d 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -321,19 +321,23 @@ describe "bundle update" do
end
describe "bundle update --ruby" do
- context "when the Gemfile removes the ruby" do
- it "removes the Ruby from the Gemfile.lock" do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.1.3'
- ::RUBY_PATCHLEVEL = 100
- ruby '~> 2.1.0'
- G
+ before do
+ install_gemfile <<-G, :expect_err => true
+ ::RUBY_VERSION = '2.1.3'
+ ::RUBY_PATCHLEVEL = 100
+ ruby '~> 2.1.0'
+ G
+ bundle "update --ruby", :expect_err => true
+ end
- install_gemfile <<-G
+ context "when the Gemfile removes the ruby" do
+ before do
+ install_gemfile <<-G, :expect_err => true
::RUBY_VERSION = '2.1.4'
::RUBY_PATCHLEVEL = 222
G
-
+ end
+ it "removes the Ruby from the Gemfile.lock" do
bundle "update --ruby"
lockfile_should_be <<-L
@@ -351,21 +355,16 @@ describe "bundle update --ruby" do
end
end
- context "when the Gemfile specified an updated Ruby verison" do
- it "updates the Gemfile.lock with the latest version" do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.1.3'
- ::RUBY_PATCHLEVEL = 100
- ruby '~> 2.1.0'
- G
-
- install_gemfile <<-G
+ context "when the Gemfile specified an updated Ruby version" do
+ before do
+ install_gemfile <<-G, :expect_err => true
::RUBY_VERSION = '2.1.4'
::RUBY_PATCHLEVEL = 222
ruby '~> 2.1.0'
G
-
- bundle "update --ruby"
+ end
+ it "updates the Gemfile.lock with the latest version" do
+ bundle "update --ruby", :expect_err => true
lockfile_should_be <<-L
GEM
@@ -386,39 +385,30 @@ describe "bundle update --ruby" do
end
context "when a different Ruby is being used than has been versioned" do
- it "shows a helpful error message" do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.1.3'
- ::RUBY_PATCHLEVEL = 100
- ruby '~> 2.1.0'
- G
-
- install_gemfile <<-G
+ before do
+ install_gemfile <<-G, :expect_err => true
::RUBY_VERSION = '2.2.2'
::RUBY_PATCHLEVEL = 505
ruby '~> 2.1.0'
G
+ end
+ it "shows a helpful error message" do
+ bundle "update --ruby", :expect_err => true
- bundle "update --ruby"
expect(out).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0")
end
end
context "when updating Ruby version and Gemfile `ruby`" do
- it "updates the Gemfile.lock with the latest version" do
- install_gemfile <<-G
- ::RUBY_VERSION = '2.1.3'
- ::RUBY_PATCHLEVEL = 100
- ruby '~> 2.1.0'
- G
-
- install_gemfile <<-G
+ before do
+ install_gemfile <<-G, :expect_err => true
::RUBY_VERSION = '1.8.3'
::RUBY_PATCHLEVEL = 55
ruby '~> 1.8.0'
G
-
- bundle "update --ruby"
+ end
+ it "updates the Gemfile.lock with the latest version" do
+ bundle "update --ruby", :expect_err => true
lockfile_should_be <<-L
GEM
diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb
index c98d30cde2..7b38dfb961 100644
--- a/spec/install/gemfile/gemspec_spec.rb
+++ b/spec/install/gemfile/gemspec_spec.rb
@@ -165,4 +165,86 @@ describe "bundle install from an existing gemspec" do
should_be_installed "rack 1.0"
end
end
+
+ context "with a lockfile and some missing dependencies" do
+ let(:source_uri) { "http://localgemserver.test" }
+
+ context "previously bundled for Ruby" do
+ let(:platform) { "ruby" }
+ let(:explicit_platform) { false }
+
+ before do
+ build_lib("foo", :path => tmp.join("foo")) do |s|
+ s.add_dependency "rack", "=1.0.0"
+ s.platform = platform if explicit_platform
+ end
+
+ gemfile <<-G
+ source "#{source_uri}"
+ gemspec :path => "../foo"
+ G
+
+ lockfile <<-L
+ PATH
+ remote: ../foo
+ specs:
+ foo (1.0)
+ rack (= 1.0.0)
+
+ GEM
+ remote: #{source_uri}
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ #{generic_local_platform}
+
+ DEPENDENCIES
+ foo!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+
+ context "using JRuby with explicit platform" do
+ let(:platform) { "java" }
+ let(:explicit_platform) { true }
+
+ it "should install" do
+ simulate_ruby_engine "jruby" do
+ simulate_platform "java" do
+ results = bundle "install", :artifice => "endpoint"
+ expect(results).to include("Installing rack 1.0.0")
+ should_be_installed "rack 1.0.0"
+ end
+ end
+ end
+ end
+
+ context "using JRuby" do
+ let(:platform) { "java" }
+
+ it "should install" do
+ simulate_ruby_engine "jruby" do
+ simulate_platform "java" do
+ results = bundle "install", :artifice => "endpoint"
+ expect(results).to include("Installing rack 1.0.0")
+ should_be_installed "rack 1.0.0"
+ end
+ end
+ end
+ end
+
+ context "using Windows" do
+ it "should install" do
+ simulate_windows do
+ results = bundle "install", :artifice => "endpoint"
+ expect(results).to include("Installing rack 1.0.0")
+ should_be_installed "rack 1.0.0"
+ end
+ end
+ end
+ end
+ end
end
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index 780298ebc7..a81eb8a606 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -17,7 +17,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -40,7 +40,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
omg!
@@ -63,7 +63,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -81,7 +81,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -103,7 +103,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -121,7 +121,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -140,7 +140,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack (> 0)
@@ -158,7 +158,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -186,7 +186,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -204,7 +204,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -269,7 +269,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -296,7 +296,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
@@ -322,7 +322,7 @@ describe "the lockfile format" do
rack
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack-obama
@@ -348,7 +348,7 @@ describe "the lockfile format" do
rack
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack-obama (>= 1.0)
@@ -378,7 +378,7 @@ describe "the lockfile format" do
rack
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack-obama (>= 1.0)
@@ -433,7 +433,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo!
@@ -502,7 +502,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo!
@@ -532,7 +532,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo!
@@ -562,7 +562,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo!
@@ -589,7 +589,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo!
@@ -629,7 +629,7 @@ describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
bar!
@@ -664,7 +664,7 @@ describe "the lockfile format" do
rack
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
actionpack
@@ -705,7 +705,7 @@ describe "the lockfile format" do
rake (10.0.2)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rails
@@ -731,7 +731,7 @@ describe "the lockfile format" do
net-ssh (1.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
double_deps
@@ -757,7 +757,7 @@ describe "the lockfile format" do
rack
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack-obama (>= 1.0)
@@ -783,7 +783,7 @@ describe "the lockfile format" do
rack
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack-obama (>= 1.0)
@@ -811,7 +811,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo
@@ -839,7 +839,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo
@@ -867,7 +867,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo
@@ -894,7 +894,7 @@ describe "the lockfile format" do
specs:
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
foo!
@@ -927,7 +927,7 @@ describe "the lockfile format" do
gem "rack"
G
- platforms = ["java", generic(Gem::Platform.local).to_s].sort
+ platforms = ["java", generic_local_platform.to_s].sort
lockfile_should_be <<-G
GEM
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 7e205ca59a..92e588660b 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -908,7 +908,7 @@ describe "Bundler.setup" do
rack (1.0.0)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rack
diff --git a/spec/support/hax.rb b/spec/support/hax.rb
index 4c456f6fbb..f5d78b0614 100644
--- a/spec/support/hax.rb
+++ b/spec/support/hax.rb
@@ -10,6 +10,15 @@ if ENV["BUNDLER_SPEC_VERSION"]
end
end
+if ENV["BUNDLER_SPEC_WINDOWS"] == "true"
+ require "bundler/constants"
+
+ module Bundler
+ remove_const :WINDOWS if defined?(WINDOWS)
+ WINDOWS = true
+ end
+end
+
class Object
if ENV["BUNDLER_SPEC_RUBY_ENGINE"]
remove_const :RUBY_ENGINE if defined?(RUBY_ENGINE)
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 70e58e574f..bec6bb8758 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -353,6 +353,16 @@ module Spec
ENV["BUNDLER_SPEC_VERSION"] = old if block_given?
end
+ def simulate_windows
+ old = ENV["BUNDLER_SPEC_WINDOWS"]
+ ENV["BUNDLER_SPEC_WINDOWS"] = "true"
+ simulate_platform mswin do
+ yield
+ end
+ ensure
+ ENV["BUNDLER_SPEC_WINDOWS"] = old
+ end
+
def revision_for(path)
Dir.chdir(path) { `git rev-parse HEAD`.strip }
end
diff --git a/spec/support/platforms.rb b/spec/support/platforms.rb
index fa12523a04..26753af936 100644
--- a/spec/support/platforms.rb
+++ b/spec/support/platforms.rb
@@ -35,11 +35,11 @@ module Spec
end
def local
- generic(Gem::Platform.local)
+ generic_local_platform
end
def not_local
- all_platforms.find {|p| p != generic(Gem::Platform.local) }
+ all_platforms.find {|p| p != generic_local_platform }
end
def local_tag
diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb
index 465f451a58..9133f9473c 100644
--- a/spec/update/git_spec.rb
+++ b/spec/update/git_spec.rb
@@ -222,7 +222,7 @@ describe "bundle update" do
rails (2.3.2)
PLATFORMS
- #{generic(Gem::Platform.local)}
+ #{generic_local_platform}
DEPENDENCIES
rails!