summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--CHANGELOG.md9
-rw-r--r--Rakefile39
-rwxr-xr-xbin/bundle_ruby2
-rwxr-xr-xbin/bundler2
-rw-r--r--lib/bundler.rb9
-rw-r--r--lib/bundler/cli.rb14
-rw-r--r--lib/bundler/cli/gem.rb7
-rw-r--r--lib/bundler/cli/install.rb8
-rw-r--r--lib/bundler/cli/lock.rb36
-rw-r--r--lib/bundler/dsl.rb122
-rw-r--r--lib/bundler/fetcher.rb326
-rw-r--r--lib/bundler/fetcher/base.rb27
-rw-r--r--lib/bundler/fetcher/dependency.rb88
-rw-r--r--lib/bundler/fetcher/downloader.rb61
-rw-r--r--lib/bundler/fetcher/index.rb31
-rw-r--r--lib/bundler/friendly_errors.rb3
-rw-r--r--lib/bundler/inline.rb50
-rw-r--r--lib/bundler/source/rubygems.rb22
-rw-r--r--lib/bundler/templates/newgem/.travis.yml.tt1
-rw-r--r--lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt2
-rw-r--r--lib/bundler/templates/newgem/Rakefile.tt2
-rw-r--r--lib/bundler/templates/newgem/test/newgem_test.rb.tt (renamed from lib/bundler/templates/newgem/test/test_newgem.rb.tt)4
-rw-r--r--lib/bundler/templates/newgem/test/test_helper.rb.tt (renamed from lib/bundler/templates/newgem/test/minitest_helper.rb.tt)0
-rw-r--r--lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo.rb5
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo.rb5
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb (renamed from lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/dependency_graph.rb)0
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/errors.rb (renamed from lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/errors.rb)0
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb (renamed from lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/gem_metadata.rb)0
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb (renamed from lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/specification_provider.rb)0
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb (renamed from lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/ui.rb)0
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb (renamed from lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolution.rb)27
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb (renamed from lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolver.rb)4
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/state.rb (renamed from lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/state.rb)0
-rw-r--r--lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/actions.rb)14
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/create_file.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_file.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/create_link.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_link.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/directory.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/actions/directory.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/actions/empty_directory.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/actions/file_manipulation.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/actions/inject_into_file.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/base.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/base.rb)24
-rw-r--r--lib/bundler/vendor/thor/lib/thor/command.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/command.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/hash_with_indifferent_access.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/io_binary_read.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/ordered_hash.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/error.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/error.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/group.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/group.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/invocation.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/invocation.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb)4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/basic.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/readline.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/argument.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/parser/argument.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/arguments.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/parser/arguments.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/option.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/parser/option.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/options.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/parser/options.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/rake_compat.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/rake_compat.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/runner.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/runner.rb)8
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/shell.rb)6
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/basic.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/shell/basic.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/color.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/shell/color.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/html.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/shell/html.rb)2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/util.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/util.rb)0
-rw-r--r--lib/bundler/vendor/thor/lib/thor/version.rb (renamed from lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb)0
-rw-r--r--lib/bundler/vendored_molinillo.rb7
-rw-r--r--lib/bundler/vendored_thor.rb8
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--man/bundle-config.ronn4
-rw-r--r--man/bundle.ronn6
-rw-r--r--man/gemfile.5.ronn8
-rw-r--r--spec/bundler/dsl_spec.rb9
-rw-r--r--spec/bundler/fetcher_spec.rb11
-rw-r--r--spec/commands/lock_spec.rb94
-rw-r--r--spec/commands/newgem_spec.rb39
-rw-r--r--spec/install/gems/post_install_spec.rb195
-rw-r--r--spec/install/gems/simple_case_spec.rb2
-rw-r--r--spec/other/bundle_ruby_spec.rb36
-rw-r--r--spec/quality_spec.rb2
-rw-r--r--spec/realworld/parallel_spec.rb4
-rw-r--r--spec/runtime/inline_spec.rb88
-rw-r--r--spec/runtime/setup_spec.rb15
-rw-r--r--spec/update/gems_spec.rb10
85 files changed, 1039 insertions, 490 deletions
diff --git a/.travis.yml b/.travis.yml
index 8ac48c749d..ea99cf8999 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,7 @@ before_script: travis_retry rake spec:travis:deps
branches:
only:
- master
+ - 1-9-stable
- 1-8-stable
- 1-7-stable
- 1-6-stable
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2c9a0ac206..5941e2ecdb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,18 @@
+## 1.9.1 (2015-03-21)
+
+Bugfixes:
+
+ - avoid exception in 'bundler/gem_tasks' (#3492, @segiddins)
+
+## 1.9.0 (2015-03-20)
+
## 1.9.0.rc (2015-03-13)
Bugfixes:
- make Bundler.which stop finding directories (@nohoho)
- handle Bundler prereleases correctly (#3470, @segiddins)
+ - add before_install to .travis.yml template for new gems (@kodnin)
## 1.9.0.pre.1 (2015-03-11)
diff --git a/Rakefile b/Rakefile
index 79bcce1a7d..ec21f6a269 100644
--- a/Rakefile
+++ b/Rakefile
@@ -27,23 +27,32 @@ module Rake
end
end
+def clean_files(files, regex, replacement = '')
+ files.each do |file|
+ contents = File.read(file)
+ contents.gsub!(regex, replacement)
+ File.open(file, 'w') { |f| f << contents }
+ end
+end
+
namespace :molinillo do
task :namespace do
- files = Dir.glob('lib/bundler/vendor/Molinillo*/**/*.rb')
- sh "sed -i.bak 's/Molinillo/Bundler::Molinillo/g' #{files.join(' ')}"
- sh "rm #{files.join('.bak ')}.bak"
+ files = Dir.glob('lib/bundler/vendor/molinillo*/**/*.rb')
+ clean_files(files, 'Molinillo', 'Bundler::Molinillo')
+ clean_files(files, /require (["'])molinillo/, 'require \1bundler/vendor/molinillo/lib/molinillo')
end
task :clean do
- files = Dir.glob('lib/bundler/vendor/Molinillo*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last }
- puts files
- sh "rm -r #{files.join(' ')}"
+ files = Dir.glob('lib/bundler/vendor/molinillo*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last }
+ rm_r files
end
task :update, [:tag] => [] do |t, args|
tag = args[:tag]
Dir.chdir 'lib/bundler/vendor' do
- `curl -L https://github.com/CocoaPods/molinillo/archive/#{tag}.tar.gz | tar -xz`
+ rm_rf 'molinillo'
+ sh "curl -L https://github.com/CocoaPods/molinillo/archive/#{tag}.tar.gz | tar -xz"
+ sh "mv Molinillo-* molinillo"
end
Rake::Task['molinillo:namespace'].invoke
Rake::Task['molinillo:clean'].invoke
@@ -53,20 +62,22 @@ end
namespace :thor do
task :namespace do
files = Dir.glob('lib/bundler/vendor/thor*/**/*.rb')
- sh "sed -i.bak 's/Thor/Bundler::Thor/g' #{files.join(' ')}"
- sh "rm #{files.join('.bak ')}.bak"
+ clean_files(files, 'Thor', 'Bundler::Thor')
+ clean_files(files, /require (["'])thor/, 'require \1bundler/vendor/thor/lib/thor')
+ clean_files(files, /(autoload\s+[:\w]+,\s+["'])(thor[\w\/]+["'])/, '\1bundler/vendor/thor/lib/\2')
end
task :clean do
files = Dir.glob('lib/bundler/vendor/thor*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last }
- puts files
- sh "rm -r #{files.join(' ')}"
+ rm_r files
end
task :update, [:tag] => [] do |t, args|
tag = args[:tag]
Dir.chdir 'lib/bundler/vendor' do
- `curl -L https://github.com/erikhuda/thor/archive/#{tag}.tar.gz | tar -xz`
+ rm_rf 'thor'
+ sh "curl -L https://github.com/erikhuda/thor/archive/#{tag}.tar.gz | tar -xz"
+ sh "mv thor-* thor"
end
Rake::Task['thor:namespace'].invoke
Rake::Task['thor:clean'].invoke
@@ -87,8 +98,8 @@ namespace :spec do
end
deps.sort_by{|name, _| name }.each do |name, version|
- sh "#{Gem.ruby} -S gem list -i '^#{name}$' -v '#{version}' || " \
- "#{Gem.ruby} -S gem install #{name} -v '#{version}' --no-ri --no-rdoc"
+ sh %{#{Gem.ruby} -S gem list -i "^#{name}$" -v "#{version}" || } +
+ %{#{Gem.ruby} -S gem install #{name} -v "#{version}" --no-ri --no-rdoc}
end
# Download and install gems used inside tests
diff --git a/bin/bundle_ruby b/bin/bundle_ruby
index 1e02c57501..d0cfdc2778 100755
--- a/bin/bundle_ruby
+++ b/bin/bundle_ruby
@@ -41,6 +41,8 @@ module Bundler
end
end
+STDERR.puts "Warning: bundle_ruby will be deprecated in Bundler 2.0.0."
+
dsl = Bundler::Dsl.new
begin
dsl.eval_gemfile(Bundler::SharedHelpers.default_gemfile)
diff --git a/bin/bundler b/bin/bundler
index 63285e96e2..89c823eae3 100755
--- a/bin/bundler
+++ b/bin/bundler
@@ -6,7 +6,7 @@ Signal.trap("INT") { exit 1 }
require 'bundler'
# Check if an older version of bundler is installed
$LOAD_PATH.each do |path|
- if path =~ %r'/bundler-0.(\d+)' && $1.to_i < 9
+ if path =~ %r'/bundler-0\.(\d+)' && $1.to_i < 9
err = "Looks like you have a version of bundler that's older than 0.9.\n"
err << "Please remove your old versions.\n"
err << "An easy way to do this is by running `gem cleanup bundler`."
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 83c066e5e5..49d9fd6883 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -120,12 +120,7 @@ module Bundler
# Load all groups, but only once
@setup = load.setup
else
- @completed_groups ||= []
- # Figure out which groups haven't been loaded yet
- unloaded = groups - @completed_groups
- # Record groups that are now loaded
- @completed_groups = groups
- unloaded.any? ? load.setup(*groups) : load
+ load.setup(*groups)
end
end
@@ -216,7 +211,7 @@ module Bundler
end
def cleanup
- FileUtils.remove_entry_secure(@tmp) if @tmp
+ FileUtils.remove_entry_secure(@tmp) if defined?(@tmp) && @tmp
rescue
end
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 6a22072565..b1a19f5530 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -379,6 +379,20 @@ module Bundler
Inject.new(options, name, version, gems).run
end
+ desc "lock", "Creates a lockfile without installing"
+ method_option "update", :type => :boolean, :default => false, :banner =>
+ "ignore the existing lockfile"
+ method_option "local", :type => :boolean, :default => false, :banner =>
+ "do not attempt to fetch remote gemspecs and use the local gem cache only"
+ method_option "print", :type => :boolean, :default => false, :banner =>
+ "print the lockfile to STDOUT instead of writing to the file system"
+ method_option "lockfile", :type => :string, :default => nil, :banner =>
+ "the path the lockfile should be written to"
+ def lock
+ require 'bundler/cli/lock'
+ Lock.new(options).run
+ end
+
desc "env", "Print information about the environment Bundler is running under"
def env
Env.new.write($stdout)
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index da747992c4..a201c89910 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -61,6 +61,7 @@ module Bundler
"of enforcing it, so be sure that you are prepared to do that. For suggestions about " \
"how to enforce codes of conduct, see bit.ly/coc-enforcement."
)
+ Bundler.ui.info "Code of conduct enabled in config"
templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
end
@@ -70,10 +71,12 @@ module Bundler
"at choosealicense.com/licenses/mit."
)
config[:mit] = true
+ Bundler.ui.info "MIT License enabled in config"
templates.merge!("LICENSE.txt.tt" => "LICENSE.txt")
end
if test_framework = ask_and_set_test_framework
+ config[:test] = test_framework
templates.merge!(".travis.yml.tt" => ".travis.yml")
case test_framework
@@ -85,8 +88,8 @@ module Bundler
)
when 'minitest'
templates.merge!(
- "test/minitest_helper.rb.tt" => "test/minitest_helper.rb",
- "test/test_newgem.rb.tt" => "test/test_#{namespaced_path}.rb"
+ "test/test_helper.rb.tt" => "test/test_helper.rb",
+ "test/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
)
end
end
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 4d6715120b..24445542c2 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -92,8 +92,7 @@ module Bundler
end
Installer.post_install_messages.to_a.each do |name, msg|
- Bundler.ui.confirm "Post-install message from #{name}:"
- Bundler.ui.info msg
+ print_post_install_message(name, msg) unless Bundler.settings["ignore_messages.#{name}"]
end
Installer.ambiguous_gems.to_a.each do |name, installed_from_uri, *also_found_in_uris|
@@ -152,5 +151,10 @@ module Bundler
"#{count} #{count == 1 ? 'gem' : 'gems'} now installed"
end
+ def print_post_install_message(name, msg)
+ Bundler.ui.confirm "Post-install message from #{name}:"
+ Bundler.ui.info msg
+ end
+
end
end
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
new file mode 100644
index 0000000000..543deb5945
--- /dev/null
+++ b/lib/bundler/cli/lock.rb
@@ -0,0 +1,36 @@
+module Bundler
+ class CLI::Lock
+ attr_reader :options
+
+ def initialize(options)
+ @options = options
+ end
+
+ def run
+ unless Bundler.default_gemfile
+ Bundler.ui.error "Unable to find a Gemfile to lock"
+ exit 1
+ end
+
+ print = options[:print]
+ ui = Bundler.ui
+ Bundler.ui = UI::Silent.new if print
+
+ unlock = options[:update]
+ definition = Bundler.definition(unlock)
+ definition.resolve_remotely! unless options[:local]
+
+ if print
+ puts definition.to_lock
+ else
+ file = options[:lockfile]
+ file = file ? File.expand_path(file) : Bundler.default_lockfile
+ puts "Writing lockfile to #{file}"
+ definition.lock(file)
+ end
+
+ Bundler.ui = ui
+ end
+
+ end
+end
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index e6c4b975ef..d1cdfd2470 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -30,18 +30,14 @@ module Bundler
def eval_gemfile(gemfile, contents = nil)
contents ||= Bundler.read_file(gemfile.to_s)
instance_eval(contents, gemfile.to_s, 1)
- rescue SyntaxError => e
- syntax_msg = e.message.gsub("#{gemfile}:", 'on line ')
- raise GemfileError, "Gemfile syntax error #{syntax_msg}"
- rescue ScriptError, RegexpError, NameError, ArgumentError, RuntimeError => e
- e.backtrace[0] = "#{e.backtrace[0]}: #{e.message} (#{e.class})"
- Bundler.ui.warn e.backtrace.join("\n ")
- raise GemfileError, "There was an error in your Gemfile," \
- " and Bundler cannot continue."
+ rescue Exception => e
+ message = "There was an error parsing `#{File.basename gemfile.to_s}`: #{e.message}"
+ raise DSLError.new(message, gemfile, e.backtrace, contents)
end
def gemspec(opts = nil)
path = opts && opts[:path] || '.'
+ glob = opts && opts[:glob]
name = opts && opts[:name] || '{,*}'
development_group = opts && opts[:development_group] || :development
expanded_path = File.expand_path(path, Bundler.default_gemfile.dirname)
@@ -52,7 +48,7 @@ module Bundler
when 1
spec = Bundler.load_gemspec(gemspecs.first)
raise InvalidOption, "There was an error loading the gemspec at #{gemspecs.first}." unless spec
- gem spec.name, :path => path
+ gem spec.name, :path => path, :glob => glob
group(development_group) do
spec.development_dependencies.each do |dep|
gem dep.name, *(dep.requirement.as_list + [:type => :development])
@@ -184,9 +180,7 @@ module Bundler
end
def method_missing(name, *args)
- location = caller[0].split(':')[0..1].join(':')
- raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile\n" \
- " from #{location}"
+ raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile"
end
private
@@ -224,7 +218,7 @@ module Bundler
end
def valid_keys
- @valid_keys ||= %w(group groups git path name branch ref tag require submodules platform platforms type source)
+ @valid_keys ||= %w(group groups git path glob name branch ref tag require submodules platform platforms type source)
end
def normalize_options(name, version, opts)
@@ -327,5 +321,107 @@ module Bundler
end
end
+ class DSLError < GemfileError
+ # @return [String] the description that should be presented to the user.
+ #
+ attr_reader :description
+
+ # @return [String] the path of the dsl file that raised the exception.
+ #
+ attr_reader :dsl_path
+
+ # @return [Exception] the backtrace of the exception raised by the
+ # evaluation of the dsl file.
+ #
+ attr_reader :backtrace
+
+ # @param [Exception] backtrace @see backtrace
+ # @param [String] dsl_path @see dsl_path
+ #
+ def initialize(description, dsl_path, backtrace, contents = nil)
+ @status_code = $!.respond_to?(:status_code) && $!.status_code
+
+ @description = description
+ @dsl_path = dsl_path
+ @backtrace = backtrace
+ @contents = contents
+ end
+
+ def status_code
+ @status_code || super
+ end
+
+ # @return [String] the contents of the DSL that cause the exception to
+ # be raised.
+ #
+ def contents
+ @contents ||= begin
+ dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
+ end
+ end
+
+ # The message of the exception reports the content of podspec for the
+ # line that generated the original exception.
+ #
+ # @example Output
+ #
+ # Invalid podspec at `RestKit.podspec` - undefined method
+ # `exclude_header_search_paths=' for #<Pod::Specification for
+ # `RestKit/Network (0.9.3)`>
+ #
+ # from spec-repos/master/RestKit/0.9.3/RestKit.podspec:36
+ # -------------------------------------------
+ # # because it would break: #import <CoreData/CoreData.h>
+ # > ns.exclude_header_search_paths = 'Code/RestKit.h'
+ # end
+ # -------------------------------------------
+ #
+ # @return [String] the message of the exception.
+ #
+ def message
+ @message ||= begin
+ trace_line, description = parse_line_number_from_description
+
+ m = "\n[!] "
+ m << description
+ m << ". Bundler cannot continue.\n"
+
+ return m unless backtrace && dsl_path && contents
+
+ trace_line = backtrace.find { |l| l.include?(dsl_path.to_s) } || trace_line
+ return m unless trace_line
+ line_numer = trace_line.split(':')[1].to_i - 1
+ return m unless line_numer
+
+ lines = contents.lines.to_a
+ indent = ' # '
+ indicator = indent.gsub('#', '>')
+ first_line = (line_numer.zero?)
+ last_line = (line_numer == (lines.count - 1))
+
+ m << "\n"
+ m << "#{indent}from #{trace_line.gsub(/:in.*$/, '')}\n"
+ m << "#{indent}-------------------------------------------\n"
+ m << "#{indent}#{ lines[line_numer - 1] }" unless first_line
+ m << "#{indicator}#{ lines[line_numer] }"
+ m << "#{indent}#{ lines[line_numer + 1] }" unless last_line
+ m << "\n" unless m.end_with?("\n")
+ m << "#{indent}-------------------------------------------\n"
+ end
+ end
+
+ private
+
+ def parse_line_number_from_description
+ description = self.description
+ if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path.to_s}):\d+)/
+ trace_line = Regexp.last_match[1]
+ description = description.sub(/#{Regexp.quote trace_line}:\s*/, '').sub("\n", ' - ')
+ end
+ [trace_line, description]
+ end
+ end
+
end
+
end
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index a60adcabb2..b29e8dfb8a 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -1,11 +1,15 @@
require 'bundler/vendored_persistent'
-require 'securerandom'
require 'cgi'
+require 'securerandom'
module Bundler
# Handles all the fetching with the rubygems server
class Fetcher
+ autoload :Downloader, 'bundler/fetcher/downloader'
+ autoload :Dependency, 'bundler/fetcher/dependency'
+ autoload :Index, 'bundler/fetcher/index'
+
# This error is raised when it looks like the network is down
class NetworkDownError < HTTPError; end
# This error is raised if the API returns a 413 (only printed in verbose)
@@ -52,93 +56,19 @@ module Bundler
class << self
attr_accessor :disable_endpoint, :api_timeout, :redirect_limit, :max_retries
-
- def download_gem_from_uri(spec, uri)
- spec.fetch_platform
-
- download_path = Bundler.requires_sudo? ? Bundler.tmp(spec.full_name) : Bundler.rubygems.gem_dir
- gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem"
-
- FileUtils.mkdir_p("#{download_path}/cache")
- Bundler.rubygems.download_gem(spec, uri, download_path)
-
- if Bundler.requires_sudo?
- Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/cache"
- Bundler.sudo "mv #{Bundler.tmp(spec.full_name)}/cache/#{spec.full_name}.gem #{gem_path}"
- end
-
- gem_path
- end
-
- def user_agent
- @user_agent ||= begin
- ruby = Bundler.ruby_version
-
- agent = "bundler/#{Bundler::VERSION}"
- agent << " rubygems/#{Gem::VERSION}"
- agent << " ruby/#{ruby.version}"
- agent << " (#{ruby.host})"
- agent << " command/#{ARGV.first}"
-
- if ruby.engine != "ruby"
- # engine_version raises on unknown engines
- engine_version = ruby.engine_version rescue "???"
- agent << " #{ruby.engine}/#{engine_version}"
- end
-
- agent << " options/#{Bundler.settings.all.join(",")}"
-
- # add a random ID so we can consolidate runs server-side
- agent << " " << SecureRandom.hex(8)
-
- # add any user agent strings set in the config
- extra_ua = Bundler.settings[:user_agent]
- agent << " " << extra_ua if extra_ua
-
- agent
- end
- end
-
end
- def initialize(remote)
- @redirect_limit = 5 # How many redirects to allow in one request
- @api_timeout = 10 # How long to wait for each API call
- @max_retries = 3 # How many retries for the API call
+ self.redirect_limit = 5 # How many redirects to allow in one request
+ self.api_timeout = 10 # How long to wait for each API call
+ self.max_retries = 3 # How many retries for the API call
+ def initialize(remote)
@remote = remote
Socket.do_not_reverse_lookup = true
connection # create persistent connection
end
- def connection
- @connection ||= begin
- needs_ssl = remote_uri.scheme == "https" ||
- Bundler.settings[:ssl_verify_mode] ||
- Bundler.settings[:ssl_client_cert]
- raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
-
- con = Net::HTTP::Persistent.new 'bundler', :ENV
-
- if remote_uri.scheme == "https"
- con.verify_mode = (Bundler.settings[:ssl_verify_mode] ||
- OpenSSL::SSL::VERIFY_PEER)
- con.cert_store = bundler_cert_store
- end
-
- if Bundler.settings[:ssl_client_cert]
- pem = File.read(Bundler.settings[:ssl_client_cert])
- con.cert = OpenSSL::X509::Certificate.new(pem)
- con.key = OpenSSL::PKey::RSA.new(pem)
- end
-
- con.read_timeout = @api_timeout
- con.override_headers["User-Agent"] = self.class.user_agent
- con
- end
- end
-
def uri
@remote.anonymized_uri
end
@@ -154,37 +84,26 @@ module Bundler
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
Bundler.load_gemspec(cached_spec_path)
else
- Bundler.load_marshal Gem.inflate(fetch(uri))
+ Bundler.load_marshal Gem.inflate(downloader.fetch uri)
end
rescue MarshalError
raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
"Your network or your gem server is probably having issues right now."
end
- # cached gem specification path, if one exists
- def gemspec_cached_path spec_file_name
- paths = Bundler.rubygems.spec_cache_dirs.map { |dir| File.join(dir, spec_file_name) }
- paths = paths.select {|path| File.file? path }
- paths.first
- end
-
# return the specs in the bundler format as an index
def specs(gem_names, source)
old = Bundler.rubygems.sources
- index = Index.new
-
- if gem_names && use_api
- specs = fetch_remote_specs(gem_names)
- end
-
- if specs.nil?
- # API errors mean we should treat this as a non-API source
- @use_api = false
+ index = Bundler::Index.new
- specs = Bundler::Retry.new("source fetch", AUTH_ERRORS).attempts do
- fetch_all_remote_specs
+ specs = {}
+ fetchers.dup.each do |f|
+ unless f.api_fetcher? && !gem_names
+ break if specs = f.specs(gem_names)
end
+ fetchers.delete(f)
end
+ @use_api = false if fetchers.none?(&:api_fetcher?)
specs[remote_uri].each do |name, version, platform, dependencies|
next if name == 'bundler'
@@ -200,184 +119,106 @@ module Bundler
end
index
- rescue CertificateFailureError => e
+ rescue CertificateFailureError
Bundler.ui.info "" if gem_names && use_api # newline after dots
- raise e
+ raise
ensure
Bundler.rubygems.sources = old
end
- # fetch index
- def fetch_remote_specs(gem_names, full_dependency_list = [], last_spec_list = [])
- query_list = gem_names - full_dependency_list
-
- # only display the message on the first run
- if Bundler.ui.debug?
- Bundler.ui.debug "Query List: #{query_list.inspect}"
- else
- Bundler.ui.info ".", false
- end
-
- return {remote_uri => last_spec_list} if query_list.empty?
-
- remote_specs = Bundler::Retry.new("dependency api", AUTH_ERRORS).attempts do
- fetch_dependency_remote_specs(query_list)
- end
-
- spec_list, deps_list = remote_specs
- returned_gems = spec_list.map {|spec| spec.first }.uniq
- fetch_remote_specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
- rescue HTTPError, MarshalError, GemspecError
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
- Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
- @use_api = false
- return nil
- end
-
def use_api
return @use_api if defined?(@use_api)
if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
@use_api = false
- elsif fetch(dependency_api_uri)
- @use_api = true
+ else
+ fetchers.reject! { |f| f.api_fetcher? && !f.api_available? }
+ @use_api = fetchers.any?(&:api_fetcher?)
end
- rescue NetworkDownError => e
- raise HTTPError, e.message
- rescue AuthenticationRequiredError
- # We got a 401 from the server. Don't fall back to the full index, just fail.
- raise
- rescue HTTPError
- @use_api = false
end
- def inspect
- "#<#{self.class}:0x#{object_id} uri=#{uri}>"
- end
+ def user_agent
+ @user_agent ||= begin
+ ruby = Bundler.ruby_version
- private
+ agent = "bundler/#{Bundler::VERSION}"
+ agent << " rubygems/#{Gem::VERSION}"
+ agent << " ruby/#{ruby.version}"
+ agent << " (#{ruby.host})"
+ agent << " command/#{ARGV.first}"
- HTTP_ERRORS = [
- Timeout::Error, EOFError, SocketError, Errno::ENETDOWN,
- Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
- Net::HTTP::Persistent::Error
- ]
+ if ruby.engine != "ruby"
+ # engine_version raises on unknown engines
+ engine_version = ruby.engine_version rescue "???"
+ agent << " #{ruby.engine}/#{engine_version}"
+ end
- def fetch(uri, counter = 0)
- raise HTTPError, "Too many redirects" if counter >= @redirect_limit
+ agent << " options/#{Bundler.settings.all.join(",")}"
- response = request(uri)
- Bundler.ui.debug("HTTP #{response.code} #{response.message}")
+ # add a random ID so we can consolidate runs server-side
+ agent << " " << SecureRandom.hex(8)
- case response
- when Net::HTTPRedirection
- new_uri = URI.parse(response["location"])
- if new_uri.host == uri.host
- new_uri.user = uri.user
- new_uri.password = uri.password
- end
- fetch(new_uri, counter + 1)
- when Net::HTTPSuccess
- response.body
- when Net::HTTPRequestEntityTooLarge
- raise FallbackError, response.body
- when Net::HTTPUnauthorized
- raise AuthenticationRequiredError, remote_uri.host
- else
- raise HTTPError, "#{response.class}: #{response.body}"
+ # add any user agent strings set in the config
+ extra_ua = Bundler.settings[:user_agent]
+ agent << " " << extra_ua if extra_ua
+
+ agent
end
end
- def request(uri)
- Bundler.ui.debug "HTTP GET #{uri}"
- req = Net::HTTP::Get.new uri.request_uri
- if uri.user
- user = CGI.unescape(uri.user)
- password = uri.password ? CGI.unescape(uri.password) : nil
- req.basic_auth(user, password)
- end
- connection.request(uri, req)
- rescue OpenSSL::SSL::SSLError
- raise CertificateFailureError.new(uri)
- rescue *HTTP_ERRORS => e
- Bundler.ui.trace e
- case e.message
- when /host down:/, /getaddrinfo: nodename nor servname provided/
- raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
- "connection and try again."
- else
- raise HTTPError, "Network error while fetching #{uri}"
- end
+ def fetchers
+ @fetchers ||= FETCHERS.map { |f| f.new(downloader, remote_uri, fetch_uri, uri) }
end
- def dependency_api_uri(gem_names = [])
- uri = fetch_uri + "api/v1/dependencies"
- uri.query = "gems=#{URI.encode(gem_names.join(","))}" if gem_names.any?
- uri
+ def inspect
+ "#<#{self.class}:0x#{object_id} uri=#{uri}>"
end
- # fetch from Gemcutter Dependency Endpoint API
- def fetch_dependency_remote_specs(gem_names)
- Bundler.ui.debug "Query Gemcutter Dependency Endpoint API: #{gem_names.join(',')}"
- gem_list = []
- deps_list = []
+ private
- gem_names.each_slice(Source::Rubygems::API_REQUEST_SIZE) do |names|
- marshalled_deps = fetch dependency_api_uri(names)
- gem_list += Bundler.load_marshal(marshalled_deps)
- end
+ FETCHERS = [Dependency, Index]
- spec_list = gem_list.map do |s|
- dependencies = s[:dependencies].map do |name, requirement|
- dep = well_formed_dependency(name, requirement.split(", "))
- deps_list << dep.name
- dep
- end
+ def connection
+ @connection ||= begin
+ needs_ssl = remote_uri.scheme == "https" ||
+ Bundler.settings[:ssl_verify_mode] ||
+ Bundler.settings[:ssl_client_cert]
+ raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
- [s[:name], Gem::Version.new(s[:number]), s[:platform], dependencies]
- end
+ con = Net::HTTP::Persistent.new 'bundler', :ENV
- [spec_list, deps_list.uniq]
- end
+ if remote_uri.scheme == "https"
+ con.verify_mode = (Bundler.settings[:ssl_verify_mode] ||
+ OpenSSL::SSL::VERIFY_PEER)
+ con.cert_store = bundler_cert_store
+ end
- # fetch from modern index: specs.4.8.gz
- def fetch_all_remote_specs
- old_sources = Bundler.rubygems.sources
- Bundler.rubygems.sources = [remote_uri.to_s]
- Bundler.rubygems.fetch_all_remote_specs
- rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError => e
- case e.message
- when /certificate verify failed/
- raise CertificateFailureError.new(uri)
- when /401/
- raise AuthenticationRequiredError, remote_uri
- when /403/
- if remote_uri.userinfo
- raise BadAuthenticationError, remote_uri
- else
- raise AuthenticationRequiredError, remote_uri
+ if Bundler.settings[:ssl_client_cert]
+ pem = File.read(Bundler.settings[:ssl_client_cert])
+ con.cert = OpenSSL::X509::Certificate.new(pem)
+ con.key = OpenSSL::PKey::RSA.new(pem)
end
- else
- Bundler.ui.trace e
- raise HTTPError, "Could not fetch specs from #{uri}"
+
+ con.read_timeout = Fetcher.api_timeout
+ con.override_headers["User-Agent"] = user_agent
+ con
end
- ensure
- Bundler.rubygems.sources = old_sources
end
- def well_formed_dependency(name, *requirements)
- Gem::Dependency.new(name, *requirements)
- rescue ArgumentError => e
- illformed = 'Ill-formed requirement ["#<YAML::Syck::DefaultKey'
- raise e unless e.message.include?(illformed)
- puts # we shouldn't print the error message on the "fetching info" status line
- raise GemspecError,
- "Unfortunately, the gem #{s[:name]} (#{s[:number]}) has an invalid " \
- "gemspec. \nPlease ask the gem author to yank the bad version to fix " \
- "this issue. For more information, see http://bit.ly/syck-defaultkey."
+ # cached gem specification path, if one exists
+ def gemspec_cached_path spec_file_name
+ paths = Bundler.rubygems.spec_cache_dirs.map { |dir| File.join(dir, spec_file_name) }
+ paths = paths.select {|path| File.file? path }
+ paths.first
end
+ HTTP_ERRORS = [
+ Timeout::Error, EOFError, SocketError, Errno::ENETDOWN,
+ Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
+ Net::HTTP::Persistent::Error
+ ]
+
def bundler_cert_store
store = OpenSSL::X509::Store.new
if Bundler.settings[:ssl_ca_cert]
@@ -411,5 +252,10 @@ module Bundler
def remote_uri
@remote.uri
end
+
+ def downloader
+ @downloader ||= Downloader.new(connection, self.class.redirect_limit)
+ end
+
end
end
diff --git a/lib/bundler/fetcher/base.rb b/lib/bundler/fetcher/base.rb
new file mode 100644
index 0000000000..31d6f8a09b
--- /dev/null
+++ b/lib/bundler/fetcher/base.rb
@@ -0,0 +1,27 @@
+module Bundler
+ class Fetcher
+ class Base
+ attr_reader :downloader
+ attr_reader :remote_uri
+ attr_reader :fetch_uri
+ attr_reader :display_uri
+
+ def initialize(downloader, remote_uri, fetch_uri, display_uri)
+ raise 'Abstract class' if self.class == Base
+ @downloader = downloader
+ @remote_uri = remote_uri
+ @fetch_uri = fetch_uri
+ @display_uri = display_uri
+ end
+
+ def api_available?
+ api_fetcher?
+ end
+
+ def api_fetcher?
+ false
+ end
+
+ end
+ end
+end
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
new file mode 100644
index 0000000000..ca36dcb53f
--- /dev/null
+++ b/lib/bundler/fetcher/dependency.rb
@@ -0,0 +1,88 @@
+require 'bundler/fetcher/base'
+
+module Bundler
+ class Fetcher
+ class Dependency < Base
+ def api_available?
+ downloader.fetch(dependency_api_uri)
+ rescue NetworkDownError => e
+ raise HTTPError, e.message
+ rescue AuthenticationRequiredError
+ # We got a 401 from the server. Just fail.
+ raise
+ rescue HTTPError
+ end
+
+ def api_fetcher?
+ true
+ end
+
+ def specs(gem_names, full_dependency_list = [], last_spec_list = [])
+ query_list = gem_names - full_dependency_list
+
+ # only display the message on the first run
+ if Bundler.ui.debug?
+ Bundler.ui.debug "Query List: #{query_list.inspect}"
+ else
+ Bundler.ui.info ".", false
+ end
+
+ return {remote_uri => last_spec_list} if query_list.empty?
+
+ remote_specs = Bundler::Retry.new("dependency api", AUTH_ERRORS).attempts do
+ dependency_specs(query_list)
+ end
+
+ spec_list, deps_list = remote_specs
+ returned_gems = spec_list.map(&:first).uniq
+ specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
+ rescue HTTPError, MarshalError, GemspecError
+ Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
+ Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
+ return nil
+ end
+
+ def dependency_specs(gem_names)
+ Bundler.ui.debug "Query Gemcutter Dependency Endpoint API: #{gem_names.join(',')}"
+ gem_list = []
+ deps_list = []
+
+ gem_names.each_slice(Source::Rubygems::API_REQUEST_SIZE) do |names|
+ marshalled_deps = downloader.fetch dependency_api_uri(names)
+ gem_list += Bundler.load_marshal(marshalled_deps)
+ end
+
+ spec_list = gem_list.map do |s|
+ dependencies = s[:dependencies].map do |name, requirement|
+ dep = well_formed_dependency(name, requirement.split(", "))
+ deps_list << dep.name
+ dep
+ end
+
+ [s[:name], Gem::Version.new(s[:number]), s[:platform], dependencies]
+ end
+
+ [spec_list, deps_list.uniq]
+ end
+
+ def dependency_api_uri(gem_names = [])
+ uri = fetch_uri + "api/v1/dependencies"
+ uri.query = "gems=#{URI.encode(gem_names.join(","))}" if gem_names.any?
+ uri
+ end
+
+ def well_formed_dependency(name, *requirements)
+ Gem::Dependency.new(name, *requirements)
+ rescue ArgumentError => e
+ illformed = 'Ill-formed requirement ["#<YAML::Syck::DefaultKey'
+ raise e unless e.message.include?(illformed)
+ puts # we shouldn't print the error message on the "fetching info" status line
+ raise GemspecError,
+ "Unfortunately, the gem #{s[:name]} (#{s[:number]}) has an invalid " \
+ "gemspec. \nPlease ask the gem author to yank the bad version to fix " \
+ "this issue. For more information, see http://bit.ly/syck-defaultkey."
+ end
+
+ end
+ end
+end
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
new file mode 100644
index 0000000000..b480b4bae9
--- /dev/null
+++ b/lib/bundler/fetcher/downloader.rb
@@ -0,0 +1,61 @@
+module Bundler
+ class Fetcher
+ class Downloader
+ attr_reader :connection
+ attr_reader :redirect_limit
+
+ def initialize(connection, redirect_limit)
+ @connection = connection
+ @redirect_limit = redirect_limit
+ end
+
+ def fetch(uri, counter = 0)
+ raise HTTPError, "Too many redirects" if counter >= redirect_limit
+
+ response = request(uri)
+ Bundler.ui.debug("HTTP #{response.code} #{response.message}")
+
+ case response
+ when Net::HTTPRedirection
+ new_uri = URI.parse(response["location"])
+ if new_uri.host == uri.host
+ new_uri.user = uri.user
+ new_uri.password = uri.password
+ end
+ fetch(new_uri, counter + 1)
+ when Net::HTTPSuccess
+ response.body
+ when Net::HTTPRequestEntityTooLarge
+ raise FallbackError, response.body
+ when Net::HTTPUnauthorized
+ raise AuthenticationRequiredError, uri.host
+ else
+ raise HTTPError, "#{response.class}: #{response.body}"
+ end
+ end
+
+ def request(uri)
+ Bundler.ui.debug "HTTP GET #{uri}"
+ req = Net::HTTP::Get.new uri.request_uri
+ if uri.user
+ user = CGI.unescape(uri.user)
+ password = uri.password ? CGI.unescape(uri.password) : nil
+ req.basic_auth(user, password)
+ end
+ connection.request(uri, req)
+ rescue OpenSSL::SSL::SSLError
+ raise CertificateFailureError.new(uri)
+ rescue *HTTP_ERRORS => e
+ Bundler.ui.trace e
+ case e.message
+ when /host down:/, /getaddrinfo: nodename nor servname provided/
+ raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
+ "connection and try again."
+ else
+ raise HTTPError, "Network error while fetching #{uri}"
+ end
+ end
+
+ end
+ end
+end \ No newline at end of file
diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb
new file mode 100644
index 0000000000..f9bd279d0d
--- /dev/null
+++ b/lib/bundler/fetcher/index.rb
@@ -0,0 +1,31 @@
+require 'bundler/fetcher/base'
+
+module Bundler
+ class Fetcher
+ class Index < Base
+ def specs(_gem_names)
+ old_sources = Bundler.rubygems.sources
+ Bundler.rubygems.sources = [remote_uri.to_s]
+ Bundler.rubygems.fetch_all_remote_specs
+ rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError => e
+ case e.message
+ when /certificate verify failed/
+ raise CertificateFailureError.new(display_uri)
+ when /401/
+ raise AuthenticationRequiredError, remote_uri
+ when /403/
+ if remote_uri.userinfo
+ raise BadAuthenticationError, remote_uri
+ else
+ raise AuthenticationRequiredError, remote_uri
+ end
+ else
+ Bundler.ui.trace e
+ raise HTTPError, "Could not fetch specs from #{display_uri}"
+ end
+ ensure
+ Bundler.rubygems.sources = old_sources
+ end
+ end
+ end
+end
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 1431725d3d..4bd3e53381 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -5,6 +5,9 @@ require "bundler/vendored_thor"
module Bundler
def self.with_friendly_errors
yield
+ rescue Bundler::Dsl::DSLError => e
+ Bundler.ui.error e.message
+ exit e.status_code
rescue Bundler::BundlerError => e
Bundler.ui.error e.message, :wrap => true
Bundler.ui.trace e
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
new file mode 100644
index 0000000000..b38a925df2
--- /dev/null
+++ b/lib/bundler/inline.rb
@@ -0,0 +1,50 @@
+# Allows for declaring a Gemfile inline in a ruby script, optionally installing
+# any gems that aren't already installed on the user's system.
+#
+# @note Every gem that is specified in this 'Gemfile' will be `require`d, as if
+# the user had manually called `Bundler.require`. To avoid a requested gem
+# being automatically required, add the `:require => false` option to the
+# `gem` dependency declaration.
+#
+# @param install [Boolean] whether gems that aren't already installed on the
+# user's system should be installed.
+# Defaults to `false`.
+#
+# @param gemfile [Proc] a block that is evaluated as a `Gemfile`.
+#
+# @example Using an inline Gemfile
+#
+# #!/usr/bin/env ruby
+#
+# require 'bundler/inline'
+#
+# gemfile do
+# source 'https://rubygems.org'
+# gem 'json', require: false
+# gem 'nap', require: 'rest'
+# gem 'cocoapods', '~> 0.34.1'
+# end
+#
+# puts Pod::VERSION => "0.34.4"
+#
+def gemfile(install = false, &gemfile)
+ require 'bundler'
+ old_root = Bundler.method(:root)
+ def Bundler.root
+ Pathname.pwd.expand_path
+ end
+ ENV['BUNDLE_GEMFILE'] ||= 'Gemfile'
+
+ builder = Bundler::Dsl.new
+ builder.instance_eval(&gemfile)
+ definition = builder.to_definition(nil, true)
+ def definition.lock(file); end
+ definition.validate_ruby!
+ Bundler::Installer.install(Bundler.root, definition, :system => true) if install
+ runtime = Bundler::Runtime.new(nil, definition)
+ runtime.setup_environment
+ runtime.setup.require
+
+ bundler_module = class << Bundler; self; end
+ bundler_module.send(:define_method, :root, old_root)
+end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 8f504bcf7f..b6e6ecf500 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -293,7 +293,7 @@ module Bundler
end
def api_fetchers
- fetchers.select{|f| f.use_api }
+ fetchers.select(&:use_api)
end
def remote_specs
@@ -334,7 +334,7 @@ module Bundler
end
end until idxcount == idx.size
- if api_fetchers.any? && api_fetchers.all?{|f| f.use_api }
+ if api_fetchers.any?
# it's possible that gems from one source depend on gems from some
# other source, so now we download gemspecs and iterate over those
# dependencies, looking for gems we don't have info on yet.
@@ -351,7 +351,7 @@ module Bundler
end
end
- if !allow_api
+ unless allow_api
api_fetchers.each do |f|
Bundler.ui.info "Fetching source index from #{f.uri}"
idx.use f.specs(nil, self)
@@ -362,7 +362,21 @@ module Bundler
def fetch_gem(spec)
return false unless spec.remote
- Fetcher.download_gem_from_uri(spec, spec.remote.uri)
+ uri = spec.remote.uri
+ spec.fetch_platform
+
+ download_path = Bundler.requires_sudo? ? Bundler.tmp(spec.full_name) : Bundler.rubygems.gem_dir
+ gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem"
+
+ FileUtils.mkdir_p("#{download_path}/cache")
+ Bundler.rubygems.download_gem(spec, uri, download_path)
+
+ if Bundler.requires_sudo?
+ Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/cache"
+ Bundler.sudo "mv #{Bundler.tmp(spec.full_name)}/cache/#{spec.full_name}.gem #{gem_path}"
+ end
+
+ gem_path
end
def builtin_gem?(spec)
diff --git a/lib/bundler/templates/newgem/.travis.yml.tt b/lib/bundler/templates/newgem/.travis.yml.tt
index 4c7eba6364..d78885d0ee 100644
--- a/lib/bundler/templates/newgem/.travis.yml.tt
+++ b/lib/bundler/templates/newgem/.travis.yml.tt
@@ -1,3 +1,4 @@
language: ruby
rvm:
- <%= RUBY_VERSION %>
+before_install: gem install bundler -v <%= Bundler::VERSION %>
diff --git a/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt b/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
index c5393d1403..4ead0e1daf 100644
--- a/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
+++ b/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
@@ -10,4 +10,4 @@ Project maintainers have the right and responsibility to remove, edit, or reject
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
-This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
+This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
diff --git a/lib/bundler/templates/newgem/Rakefile.tt b/lib/bundler/templates/newgem/Rakefile.tt
index e0e87e59a7..3d3fb674a0 100644
--- a/lib/bundler/templates/newgem/Rakefile.tt
+++ b/lib/bundler/templates/newgem/Rakefile.tt
@@ -4,6 +4,8 @@ require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
+ t.libs << "lib"
+ t.test_files = FileList['test/**/*_test.rb']
end
task :default => :test
diff --git a/lib/bundler/templates/newgem/test/test_newgem.rb.tt b/lib/bundler/templates/newgem/test/newgem_test.rb.tt
index d50f7da243..95e33a34ea 100644
--- a/lib/bundler/templates/newgem/test/test_newgem.rb.tt
+++ b/lib/bundler/templates/newgem/test/newgem_test.rb.tt
@@ -1,6 +1,6 @@
-require 'minitest_helper'
+require 'test_helper'
-class Test<%= config[:constant_name] %> < Minitest::Test
+class <%= config[:constant_name] %>Test < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::<%= config[:constant_name] %>::VERSION
end
diff --git a/lib/bundler/templates/newgem/test/minitest_helper.rb.tt b/lib/bundler/templates/newgem/test/test_helper.rb.tt
index 49a56c1800..49a56c1800 100644
--- a/lib/bundler/templates/newgem/test/minitest_helper.rb.tt
+++ b/lib/bundler/templates/newgem/test/test_helper.rb.tt
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo.rb b/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo.rb
deleted file mode 100644
index bf740e4848..0000000000
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'molinillo/gem_metadata'
-require 'molinillo/errors'
-require 'molinillo/resolver'
-require 'molinillo/modules/ui'
-require 'molinillo/modules/specification_provider'
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo.rb b/lib/bundler/vendor/molinillo/lib/molinillo.rb
new file mode 100644
index 0000000000..50af4a912c
--- /dev/null
+++ b/lib/bundler/vendor/molinillo/lib/molinillo.rb
@@ -0,0 +1,5 @@
+require 'bundler/vendor/molinillo/lib/molinillo/gem_metadata'
+require 'bundler/vendor/molinillo/lib/molinillo/errors'
+require 'bundler/vendor/molinillo/lib/molinillo/resolver'
+require 'bundler/vendor/molinillo/lib/molinillo/modules/ui'
+require 'bundler/vendor/molinillo/lib/molinillo/modules/specification_provider'
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/dependency_graph.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
index 4ee5708a56..4ee5708a56 100644
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/dependency_graph.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/errors.rb b/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb
index b828d0c20d..b828d0c20d 100644
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/errors.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/gem_metadata.rb b/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb
index 0736b89c3c..0736b89c3c 100644
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/gem_metadata.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/specification_provider.rb b/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb
index 79a85e778f..79a85e778f 100644
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/specification_provider.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/ui.rb b/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb
index 097c0264ac..097c0264ac 100644
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/ui.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolution.rb b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
index 376e4d4ed2..46a47d8028 100644
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolution.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
@@ -73,6 +73,19 @@ module Bundler::Molinillo
end_resolution
end
+ # @return [Integer] the number of resolver iterations in between calls to
+ # {#resolver_ui}'s {UI#indicate_progress} method
+ attr_accessor :iteration_rate
+ private :iteration_rate
+
+ # @return [Time] the time at which resolution began
+ attr_accessor :started_at
+ private :started_at
+
+ # @return [Array<ResolutionState>] the stack of states for the resolution
+ attr_accessor :states
+ private :states
+
private
# Sets up the resolution process
@@ -98,18 +111,8 @@ module Bundler::Molinillo
debug { 'Activated: ' + Hash[activated.vertices.select { |_n, v| v.payload }].keys.join(', ') } if state
end
- require 'molinillo/state'
- require 'molinillo/modules/specification_provider'
-
- # @return [Integer] the number of resolver iterations in between calls to
- # {#resolver_ui}'s {UI#indicate_progress} method
- attr_accessor :iteration_rate
-
- # @return [Time] the time at which resolution began
- attr_accessor :started_at
-
- # @return [Array<ResolutionState>] the stack of states for the resolution
- attr_accessor :states
+ require 'bundler/vendor/molinillo/lib/molinillo/state'
+ require 'bundler/vendor/molinillo/lib/molinillo/modules/specification_provider'
ResolutionState.new.members.each do |member|
define_method member do |*args, &block|
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolver.rb b/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
index 7cfe914d34..9a9d8fd1f8 100644
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolver.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
@@ -1,4 +1,4 @@
-require 'molinillo/dependency_graph'
+require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph'
module Bundler::Molinillo
# This class encapsulates a dependency resolver.
@@ -7,7 +7,7 @@ module Bundler::Molinillo
#
#
class Resolver
- require 'molinillo/resolution'
+ require 'bundler/vendor/molinillo/lib/molinillo/resolution'
# @return [SpecificationProvider] the specification provider used
# in the resolution process
diff --git a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/state.rb b/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
index 8e394f8672..8e394f8672 100644
--- a/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/state.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb b/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb
deleted file mode 100644
index 74c789b763..0000000000
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require "thor/parser/argument"
-require "thor/parser/arguments"
-require "thor/parser/option"
-require "thor/parser/options"
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor.rb b/lib/bundler/vendor/thor/lib/thor.rb
index 8775d6a3e0..9ed67a44e2 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor.rb
+++ b/lib/bundler/vendor/thor/lib/thor.rb
@@ -1,5 +1,5 @@
require "set"
-require "thor/base"
+require "bundler/vendor/thor/lib/thor/base"
class Bundler::Thor # rubocop:disable ClassLength
class << self
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions.rb b/lib/bundler/vendor/thor/lib/thor/actions.rb
index 7edc70f472..5a82dfd45f 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions.rb
@@ -1,12 +1,12 @@
require "fileutils"
require "uri"
-require "thor/core_ext/io_binary_read"
-require "thor/actions/create_file"
-require "thor/actions/create_link"
-require "thor/actions/directory"
-require "thor/actions/empty_directory"
-require "thor/actions/file_manipulation"
-require "thor/actions/inject_into_file"
+require "bundler/vendor/thor/lib/thor/core_ext/io_binary_read"
+require "bundler/vendor/thor/lib/thor/actions/create_file"
+require "bundler/vendor/thor/lib/thor/actions/create_link"
+require "bundler/vendor/thor/lib/thor/actions/directory"
+require "bundler/vendor/thor/lib/thor/actions/empty_directory"
+require "bundler/vendor/thor/lib/thor/actions/file_manipulation"
+require "bundler/vendor/thor/lib/thor/actions/inject_into_file"
class Bundler::Thor
module Actions
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
index 711ccb7d7b..a0f5640333 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_file.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
@@ -1,4 +1,4 @@
-require "thor/actions/empty_directory"
+require "bundler/vendor/thor/lib/thor/actions/empty_directory"
class Bundler::Thor
module Actions
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_link.rb b/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb
index f633f25c18..be437922b6 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/create_link.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb
@@ -1,4 +1,4 @@
-require "thor/actions/create_file"
+require "bundler/vendor/thor/lib/thor/actions/create_file"
class Bundler::Thor
module Actions
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
index 3ed0649c27..1a2e25da2f 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/directory.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
@@ -1,4 +1,4 @@
-require "thor/actions/empty_directory"
+require "bundler/vendor/thor/lib/thor/actions/empty_directory"
class Bundler::Thor
module Actions
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/empty_directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
index cdc3768b4c..cdc3768b4c 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/empty_directory.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
index 2bdc78f578..2bdc78f578 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/file_manipulation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/inject_into_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
index 45a70701b1..91ab245ae1 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/actions/inject_into_file.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
@@ -1,4 +1,4 @@
-require "thor/actions/empty_directory"
+require "bundler/vendor/thor/lib/thor/actions/empty_directory"
class Bundler::Thor
module Actions
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/base.rb b/lib/bundler/vendor/thor/lib/thor/base.rb
index 56b78ebad6..c3667521a5 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/base.rb
+++ b/lib/bundler/vendor/thor/lib/thor/base.rb
@@ -1,17 +1,17 @@
-require "thor/command"
-require "thor/core_ext/hash_with_indifferent_access"
-require "thor/core_ext/ordered_hash"
-require "thor/error"
-require "thor/invocation"
-require "thor/parser"
-require "thor/shell"
-require "thor/line_editor"
-require "thor/util"
+require "bundler/vendor/thor/lib/thor/command"
+require "bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access"
+require "bundler/vendor/thor/lib/thor/core_ext/ordered_hash"
+require "bundler/vendor/thor/lib/thor/error"
+require "bundler/vendor/thor/lib/thor/invocation"
+require "bundler/vendor/thor/lib/thor/parser"
+require "bundler/vendor/thor/lib/thor/shell"
+require "bundler/vendor/thor/lib/thor/line_editor"
+require "bundler/vendor/thor/lib/thor/util"
class Bundler::Thor
- autoload :Actions, "thor/actions"
- autoload :RakeCompat, "thor/rake_compat"
- autoload :Group, "thor/group"
+ autoload :Actions, "bundler/vendor/thor/lib/thor/actions"
+ autoload :RakeCompat, "bundler/vendor/thor/lib/thor/rake_compat"
+ autoload :Group, "bundler/vendor/thor/lib/thor/group"
# Shortcuts for help.
HELP_MAPPINGS = %w[-h -? --help -D]
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/command.rb b/lib/bundler/vendor/thor/lib/thor/command.rb
index 72c8348cb6..72c8348cb6 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/command.rb
+++ b/lib/bundler/vendor/thor/lib/thor/command.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/hash_with_indifferent_access.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
index 6cf61db812..6cf61db812 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/hash_with_indifferent_access.rb
+++ b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/io_binary_read.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb
index 19f3c3d43e..19f3c3d43e 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/io_binary_read.rb
+++ b/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/ordered_hash.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb
index 7e80672a07..7e80672a07 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/core_ext/ordered_hash.rb
+++ b/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/error.rb b/lib/bundler/vendor/thor/lib/thor/error.rb
index fc34c11268..fc34c11268 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/error.rb
+++ b/lib/bundler/vendor/thor/lib/thor/error.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/group.rb b/lib/bundler/vendor/thor/lib/thor/group.rb
index 71e7f1c3b8..13d168ad62 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/group.rb
+++ b/lib/bundler/vendor/thor/lib/thor/group.rb
@@ -1,4 +1,4 @@
-require "thor/base"
+require "bundler/vendor/thor/lib/thor/base"
# Bundler::Thor has a special class called Bundler::Thor::Group. The main difference to Bundler::Thor class
# is that it invokes all commands at once. It also include some methods that allows
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/invocation.rb b/lib/bundler/vendor/thor/lib/thor/invocation.rb
index 684df2c616..684df2c616 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/invocation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/invocation.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb b/lib/bundler/vendor/thor/lib/thor/line_editor.rb
index 95c848e0e3..ce81a17484 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb
+++ b/lib/bundler/vendor/thor/lib/thor/line_editor.rb
@@ -1,5 +1,5 @@
-require "thor/line_editor/basic"
-require "thor/line_editor/readline"
+require "bundler/vendor/thor/lib/thor/line_editor/basic"
+require "bundler/vendor/thor/lib/thor/line_editor/readline"
class Bundler::Thor
module LineEditor
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/basic.rb b/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
index b121e95575..b121e95575 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/basic.rb
+++ b/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/readline.rb b/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
index dd39cff35d..dd39cff35d 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor/readline.rb
+++ b/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
diff --git a/lib/bundler/vendor/thor/lib/thor/parser.rb b/lib/bundler/vendor/thor/lib/thor/parser.rb
new file mode 100644
index 0000000000..08f80e565d
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/parser.rb
@@ -0,0 +1,4 @@
+require "bundler/vendor/thor/lib/thor/parser/argument"
+require "bundler/vendor/thor/lib/thor/parser/arguments"
+require "bundler/vendor/thor/lib/thor/parser/option"
+require "bundler/vendor/thor/lib/thor/parser/options"
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/argument.rb b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
index 84957903cd..84957903cd 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/argument.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/arguments.rb b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
index c7bb648e31..c7bb648e31 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/arguments.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/option.rb b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
index eb893617f4..eb893617f4 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/option.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/options.rb b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
index deac6a0c16..deac6a0c16 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/parser/options.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/rake_compat.rb b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
index fcf6719df6..60282e2991 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/rake_compat.rb
+++ b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
@@ -5,7 +5,7 @@ class Bundler::Thor
# Adds a compatibility layer to your Bundler::Thor classes which allows you to use
# rake package tasks. For example, to use rspec rake tasks, one can do:
#
- # require 'thor/rake_compat'
+ # require 'bundler/vendor/thor/lib/thor/rake_compat'
# require 'rspec/core/rake_task'
#
# class Default < Bundler::Thor
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/runner.rb b/lib/bundler/vendor/thor/lib/thor/runner.rb
index 5552fe44bd..f0d7bfe2e0 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/runner.rb
+++ b/lib/bundler/vendor/thor/lib/thor/runner.rb
@@ -1,6 +1,6 @@
-require "thor"
-require "thor/group"
-require "thor/core_ext/io_binary_read"
+require "bundler/vendor/thor/lib/thor"
+require "bundler/vendor/thor/lib/thor/group"
+require "bundler/vendor/thor/lib/thor/core_ext/io_binary_read"
require "fileutils"
require "open-uri"
@@ -102,7 +102,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
desc "version", "Show Bundler::Thor version"
def version
- require "thor/version"
+ require "bundler/vendor/thor/lib/thor/version"
say "Bundler::Thor #{Bundler::Thor::VERSION}"
end
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/shell.rb b/lib/bundler/vendor/thor/lib/thor/shell.rb
index 6a6ec5e0a4..91afdce2aa 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/shell.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell.rb
@@ -24,9 +24,9 @@ class Bundler::Thor
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
attr_writer :shell
- autoload :Basic, "thor/shell/basic"
- autoload :Color, "thor/shell/color"
- autoload :HTML, "thor/shell/html"
+ autoload :Basic, "bundler/vendor/thor/lib/thor/shell/basic"
+ autoload :Color, "bundler/vendor/thor/lib/thor/shell/color"
+ autoload :HTML, "bundler/vendor/thor/lib/thor/shell/html"
# Add shell to initialize config values.
#
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/basic.rb b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
index 278ffa3df0..278ffa3df0 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/basic.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/color.rb b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
index 3c2feba4e5..1e2d26cfc5 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/color.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
@@ -1,4 +1,4 @@
-require "thor/shell/basic"
+require "bundler/vendor/thor/lib/thor/shell/basic"
class Bundler::Thor
module Shell
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/html.rb b/lib/bundler/vendor/thor/lib/thor/shell/html.rb
index 9e28690ad0..e1ea0de599 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/shell/html.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/html.rb
@@ -1,4 +1,4 @@
-require "thor/shell/basic"
+require "bundler/vendor/thor/lib/thor/shell/basic"
class Bundler::Thor
module Shell
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/util.rb b/lib/bundler/vendor/thor/lib/thor/util.rb
index f4e98fc19f..f4e98fc19f 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/util.rb
+++ b/lib/bundler/vendor/thor/lib/thor/util.rb
diff --git a/lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb b/lib/bundler/vendor/thor/lib/thor/version.rb
index 74b020a5ab..74b020a5ab 100644
--- a/lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb
+++ b/lib/bundler/vendor/thor/lib/thor/version.rb
diff --git a/lib/bundler/vendored_molinillo.rb b/lib/bundler/vendored_molinillo.rb
index ce9ef0a3a1..4081f3fa92 100644
--- a/lib/bundler/vendored_molinillo.rb
+++ b/lib/bundler/vendored_molinillo.rb
@@ -1,5 +1,2 @@
-vendor = File.expand_path('../vendor/Molinillo-0.2.1/lib', __FILE__)
-loaded = $:.include?(vendor)
-$:.unshift(vendor) unless loaded
-require 'molinillo'
-$:.delete(vendor) unless loaded
+module Bundler; end
+require 'bundler/vendor/molinillo/lib/molinillo'
diff --git a/lib/bundler/vendored_thor.rb b/lib/bundler/vendored_thor.rb
index 2426f0c406..1931b5f278 100644
--- a/lib/bundler/vendored_thor.rb
+++ b/lib/bundler/vendored_thor.rb
@@ -1,5 +1,3 @@
-vendor = File.expand_path('../vendor/thor-0.19.1/lib', __FILE__)
-loaded = $:.include?(vendor)
-$:.unshift(vendor) unless loaded
-require 'thor'
-require 'thor/actions'
+module Bundler; end
+require 'bundler/vendor/thor/lib/thor'
+require 'bundler/vendor/thor/lib/thor/actions'
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 6d53a18d95..1854799dcb 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -2,5 +2,5 @@ module Bundler
# We're doing this because we might write tests that deal
# with other versions of bundler and we are unsure how to
# handle this better.
- VERSION = "1.9.0.rc" unless defined?(::Bundler::VERSION)
+ VERSION = "1.9.1" unless defined?(::Bundler::VERSION)
end
diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn
index 8bbc5140e1..1a47fc150f 100644
--- a/man/bundle-config.ronn
+++ b/man/bundle-config.ronn
@@ -35,6 +35,10 @@ local and global sources. Not compatible with --global or --local flag.
Executing bundle with the `BUNDLE_IGNORE_CONFIG` environment variable set will
cause it to ignore all configuration.
+Executing `bundle config disable_multisource true` upgrades the warning about
+the Gemfile containing multiple primary sources to an error. Executing `bundle
+config --delete disable_multisource` downgrades this error to a warning.
+
## BUILD OPTIONS
You can use `bundle config` to give bundler the flags to pass to the gem
diff --git a/man/bundle.ronn b/man/bundle.ronn
index 7b69c6735c..f7b9e94fd4 100644
--- a/man/bundle.ronn
+++ b/man/bundle.ronn
@@ -67,6 +67,9 @@ We divide `bundle` subcommands into primary commands and utilities.
* `bundle open(1)`:
Open an installed gem in the editor
+* `bundle lock(1)`:
+ Generate a lockfile for your dependencies
+
* `bundle viz(1)`:
Generate a visual representation of your dependencies
@@ -92,7 +95,4 @@ and execute it, passing down any extra arguments to it.
These commands are obsolete and should no longer be used
-* `bundle lock(1)`
-* `bundle unlock(1)`
* `bundle cache(1)`
-
diff --git a/man/gemfile.5.ronn b/man/gemfile.5.ronn
index 876c927380..1340b59a27 100644
--- a/man/gemfile.5.ronn
+++ b/man/gemfile.5.ronn
@@ -453,10 +453,10 @@ files in your test code as you would if the project were installed as a gem; you
need not manipulate the load path manually or require project files via relative
paths.
-The `gemspec` method supports optional `:path`, `:name`, and `:development_group`
-options, which control where bundler looks for the `.gemspec`, what named
-`.gemspec` it uses (if more than one is present), and which group development
-dependencies are included in.
+The `gemspec` method supports optional `:path`, `:glob`, `:name`, and `:development_group`
+options, which control where bundler looks for the `.gemspec`, the glob it uses to look
+for the gemspec (defaults to: "{,*,*/*}.gemspec"), what named `.gemspec` it uses
+(if more than one is present), and which group development dependencies are included in.
## SOURCE PRIORITY
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index c2dacedd08..5c6be9efca 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -69,8 +69,7 @@ describe Bundler::Dsl do
expect(Bundler).to receive(:read_file).with("Gemfile").
and_return("unknown")
- error_msg = "Undefined local variable or method `unknown'" \
- " for Gemfile\\s+from Gemfile:1"
+ error_msg = "There was an error parsing `Gemfile`: Undefined local variable or method `unknown' for Gemfile. Bundler cannot continue."
expect { subject.eval_gemfile("Gemfile") }.
to raise_error(Bundler::GemfileError, Regexp.new(error_msg))
end
@@ -80,7 +79,7 @@ describe Bundler::Dsl do
it "handles syntax errors with a useful message" do
expect(Bundler).to receive(:read_file).with("Gemfile").and_return("}")
expect { subject.eval_gemfile("Gemfile") }.
- to raise_error(Bundler::GemfileError, /Gemfile syntax error/)
+ to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`: (syntax error, unexpected tSTRING_DEND|(compile error - )?syntax error, unexpected '}'). Bundler cannot continue./)
end
end
@@ -177,7 +176,7 @@ describe Bundler::Dsl do
it "will raise a Bundler::GemfileError" do
gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
- to raise_error(Bundler::GemfileError, /Gemfile syntax error/)
+ to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`:( compile error -)? unknown regexp options - trg. Bundler cannot continue./)
end
end
@@ -185,7 +184,7 @@ describe Bundler::Dsl do
it "will raise a Bundler::GemfileError" do
gemfile "s = 'foo'.freeze; s.strip!"
expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
- to raise_error(Bundler::GemfileError, /There was an error in your Gemfile/)
+ to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`: can't modify frozen String. Bundler cannot continue./)
end
end
end
diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb
index 4640f63519..0d47bc5e90 100644
--- a/spec/bundler/fetcher_spec.rb
+++ b/spec/bundler/fetcher_spec.rb
@@ -1,6 +1,9 @@
require 'spec_helper'
+require 'bundler/fetcher'
describe Bundler::Fetcher do
+ subject(:fetcher) { Bundler::Fetcher.new(double("remote", :uri => URI("https://example.com"))) }
+
before do
allow(Bundler).to receive(:root){ Pathname.new("root") }
end
@@ -8,10 +11,10 @@ describe Bundler::Fetcher do
describe "#user_agent" do
it "builds user_agent with current ruby version and Bundler settings" do
allow(Bundler.settings).to receive(:all).and_return(["foo", "bar"])
- expect(described_class.user_agent).to match(/bundler\/(\d.)/)
- expect(described_class.user_agent).to match(/rubygems\/(\d.)/)
- expect(described_class.user_agent).to match(/ruby\/(\d.)/)
- expect(described_class.user_agent).to match(/options\/foo,bar/)
+ expect(fetcher.user_agent).to match(/bundler\/(\d.)/)
+ expect(fetcher.user_agent).to match(/rubygems\/(\d.)/)
+ expect(fetcher.user_agent).to match(/ruby\/(\d.)/)
+ expect(fetcher.user_agent).to match(/options\/foo,bar/)
end
end
end
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
new file mode 100644
index 0000000000..b3f4f8cb63
--- /dev/null
+++ b/spec/commands/lock_spec.rb
@@ -0,0 +1,94 @@
+require "spec_helper"
+
+describe "bundle lock" do
+ def strip_lockfile(lockfile)
+ strip_whitespace(lockfile).sub(/\n\Z/, '')
+ end
+
+ def read_lockfile(file = "Gemfile.lock")
+ strip_lockfile bundled_app(file).read
+ end
+
+ before :each do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rails"
+ gem "with_license"
+ gem "foo"
+ G
+
+ @lockfile = strip_lockfile <<-L
+ GEM
+ remote: file:#{gem_repo1}/
+ specs:
+ actionmailer (2.3.2)
+ activesupport (= 2.3.2)
+ actionpack (2.3.2)
+ activesupport (= 2.3.2)
+ activerecord (2.3.2)
+ activesupport (= 2.3.2)
+ activeresource (2.3.2)
+ activesupport (= 2.3.2)
+ activesupport (2.3.2)
+ foo (1.0)
+ rails (2.3.2)
+ actionmailer (= 2.3.2)
+ actionpack (= 2.3.2)
+ activerecord (= 2.3.2)
+ activeresource (= 2.3.2)
+ rake (= 10.0.2)
+ rake (10.0.2)
+ with_license (1.0)
+
+ PLATFORMS
+ ruby
+
+ DEPENDENCIES
+ foo
+ rails
+ with_license
+ L
+ end
+
+ it "prints a lockfile when there is no existing lockfile with --print" do
+ bundle "lock --print"
+
+ expect(out).to eq(@lockfile)
+ end
+
+ it "prints a lockfile when there is an existing lockfile with --print" do
+ lockfile @lockfile
+
+ bundle "lock --print"
+
+ expect(out).to eq(@lockfile)
+ end
+
+ it "writes a lockfile when there is no existing lockfile" do
+ bundle "lock"
+
+ expect(read_lockfile).to eq(@lockfile)
+ end
+
+ it "writes a lockfile when there is an outdated lockfile using --update" do
+ lockfile @lockfile.gsub('2.3.2', '2.3.1')
+
+ bundle "lock --update"
+
+ expect(read_lockfile).to eq(@lockfile)
+ end
+
+ it "does not fetch remote specs when using the --local option" do
+ bundle "lock --update --local"
+
+ expect(out).to include("in the gems available on this machine.")
+ end
+
+ it "writes to a custom location using --lockfile" do
+ bundle "lock --lockfile=lock"
+
+ expect(out).to match(/Writing lockfile to.+lock/)
+ expect(read_lockfile "lock").to eq(@lockfile)
+ expect { read_lockfile }.to raise_error
+ end
+end
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 7ea10cc247..ef653d306d 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -255,8 +255,8 @@ describe "bundle gem" do
end
it "builds spec skeleton" do
- expect(bundled_app("test_gem/test/test_test_gem.rb")).to exist
- expect(bundled_app("test_gem/test/minitest_helper.rb")).to exist
+ expect(bundled_app("test_gem/test/test_gem_test.rb")).to exist
+ expect(bundled_app("test_gem/test/test_helper.rb")).to exist
end
end
@@ -268,20 +268,20 @@ describe "bundle gem" do
end
it "builds spec skeleton" do
- expect(bundled_app("test_gem/test/test_test_gem.rb")).to exist
- expect(bundled_app("test_gem/test/minitest_helper.rb")).to exist
+ expect(bundled_app("test_gem/test/test_gem_test.rb")).to exist
+ expect(bundled_app("test_gem/test/test_helper.rb")).to exist
end
it "requires 'test-gem'" do
- expect(bundled_app("test_gem/test/minitest_helper.rb").read).to include("require 'test_gem'")
+ expect(bundled_app("test_gem/test/test_helper.rb").read).to include("require 'test_gem'")
end
it "requires 'minitest_helper'" do
- expect(bundled_app("test_gem/test/test_test_gem.rb").read).to include("require 'minitest_helper'")
+ expect(bundled_app("test_gem/test/test_gem_test.rb").read).to include("require 'test_helper'")
end
it "creates a default test which fails" do
- expect(bundled_app("test_gem/test/test_test_gem.rb").read).to include("assert false")
+ expect(bundled_app("test_gem/test/test_gem_test.rb").read).to include("assert false")
end
end
@@ -499,20 +499,20 @@ describe "bundle gem" do
end
it "builds spec skeleton" do
- expect(bundled_app("test-gem/test/test_test/gem.rb")).to exist
- expect(bundled_app("test-gem/test/minitest_helper.rb")).to exist
+ expect(bundled_app("test-gem/test/test/gem_test.rb")).to exist
+ expect(bundled_app("test-gem/test/test_helper.rb")).to exist
end
it "requires 'test/gem'" do
- expect(bundled_app("test-gem/test/minitest_helper.rb").read).to match(/require 'test\/gem'/)
+ expect(bundled_app("test-gem/test/test_helper.rb").read).to match(/require 'test\/gem'/)
end
- it "requires 'minitest_helper'" do
- expect(bundled_app("test-gem/test/test_test/gem.rb").read).to match(/require 'minitest_helper'/)
+ it "requires 'test_helper'" do
+ expect(bundled_app("test-gem/test/test/gem_test.rb").read).to match(/require 'test_helper'/)
end
it "creates a default test which fails" do
- expect(bundled_app("test-gem/test/test_test/gem.rb").read).to match(/assert false/)
+ expect(bundled_app("test-gem/test/test/gem_test.rb").read).to match(/assert false/)
end
it "creates a default rake task to run the test suite" do
@@ -522,6 +522,8 @@ describe "bundle gem" do
Rake::TestTask.new(:test) do |t|
t.libs << "test"
+ t.libs << "lib"
+ t.test_files = FileList['test/**/*_test.rb']
end
task :default => :test
@@ -600,6 +602,17 @@ describe "bundle gem" do
end
expect(bundled_app("foobar/spec/spec_helper.rb")).to exist
+ rakefile = strip_whitespace <<-RAKEFILE
+ require "bundler/gem_tasks"
+ require "rspec/core/rake_task"
+
+ RSpec::Core::RakeTask.new(:spec)
+
+ task :default => :spec
+ RAKEFILE
+
+ expect(bundled_app("foobar/Rakefile").read).to eq(rakefile)
+ expect(bundled_app("foobar/foobar.gemspec").read).to include('spec.add_development_dependency "rspec"')
end
it "asks about MIT license" do
diff --git a/spec/install/gems/post_install_spec.rb b/spec/install/gems/post_install_spec.rb
index 69841fea44..e12c3e3827 100644
--- a/spec/install/gems/post_install_spec.rb
+++ b/spec/install/gems/post_install_spec.rb
@@ -1,121 +1,136 @@
require 'spec_helper'
-describe "bundle install with gem sources" do
- describe "when gems include post install messages" do
- it "should display the post-install messages after installing" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'rack'
- gem 'thin'
- gem 'rack-obama'
- G
-
- bundle :install
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
- expect(out).to include("Post-install message from thin:")
- expect(out).to include("Thin's post install message")
- expect(out).to include("Post-install message from rack-obama:")
- expect(out).to include("Rack-obama's post install message")
+describe "bundle install" do
+ context "with gem sources" do
+ context "when gems include post install messages" do
+ it "should display the post-install messages after installing" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'rack'
+ gem 'thin'
+ gem 'rack-obama'
+ G
+
+ bundle :install
+ expect(out).to include("Post-install message from rack:")
+ expect(out).to include("Rack's post install message")
+ expect(out).to include("Post-install message from thin:")
+ expect(out).to include("Thin's post install message")
+ expect(out).to include("Post-install message from rack-obama:")
+ expect(out).to include("Rack-obama's post install message")
+ end
end
- end
- describe "when gems do not include post install messages" do
- it "should not display any post-install messages" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "activesupport"
- G
+ context "when gems do not include post install messages" do
+ it "should not display any post-install messages" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "activesupport"
+ G
- bundle :install
- expect(out).not_to include("Post-install message")
+ bundle :install
+ expect(out).not_to include("Post-install message")
+ end
end
- end
- describe "when a dependecy includes a post install message" do
- it "should display the post install message" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'rack_middleware'
- G
+ context "when a dependecy includes a post install message" do
+ it "should display the post install message" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'rack_middleware'
+ G
- bundle :install
- expect(out).to include("Post-install message from rack:")
- expect(out).to include("Rack's post install message")
+ bundle :install
+ expect(out).to include("Post-install message from rack:")
+ expect(out).to include("Rack's post install message")
+ end
end
end
-end
-describe "bundle install with git sources" do
- describe "when gems include post install messages" do
- it "should display the post-install messages after installing" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
+ context "with git sources" do
+ context "when gems include post install messages" do
+ it "should display the post-install messages after installing" do
+ build_git "foo" do |s|
+ s.post_install_message = "Foo's post install message"
+ end
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'foo', :git => '#{lib_path("foo-1.0")}'
+ G
+
+ bundle :install
+ expect(out).to include("Post-install message from foo:")
+ expect(out).to include("Foo's post install message")
end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
- bundle :install
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's post install message")
- end
-
- it "should display the post-install messages if repo is updated" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
+ it "should display the post-install messages if repo is updated" do
+ build_git "foo" do |s|
+ s.post_install_message = "Foo's post install message"
+ end
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'foo', :git => '#{lib_path("foo-1.0")}'
+ G
+ bundle :install
+
+ build_git "foo", "1.1" do |s|
+ s.post_install_message = "Foo's 1.1 post install message"
+ end
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'foo', :git => '#{lib_path("foo-1.1")}'
+ G
+ bundle :install
+
+ expect(out).to include("Post-install message from foo:")
+ expect(out).to include("Foo's 1.1 post install message")
end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
- bundle :install
- build_git "foo", "1.1" do |s|
- s.post_install_message = "Foo's 1.1 post install message"
+ it "should not display the post-install messages if repo is not updated" do
+ build_git "foo" do |s|
+ s.post_install_message = "Foo's post install message"
+ end
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'foo', :git => '#{lib_path("foo-1.0")}'
+ G
+
+ bundle :install
+ expect(out).to include("Post-install message from foo:")
+ expect(out).to include("Foo's post install message")
+
+ bundle :install
+ expect(out).not_to include("Post-install message")
end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.1")}'
- G
- bundle :install
-
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's 1.1 post install message")
end
- it "should not display the post-install messages if repo is not updated" do
- build_git "foo" do |s|
- s.post_install_message = "Foo's post install message"
+ context "when gems do not include post install messages" do
+ it "should not display any post-install messages" do
+ build_git "foo" do |s|
+ s.post_install_message = nil
+ end
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'foo', :git => '#{lib_path("foo-1.0")}'
+ G
+
+ bundle :install
+ expect(out).not_to include("Post-install message")
end
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
- G
-
- bundle :install
- expect(out).to include("Post-install message from foo:")
- expect(out).to include("Foo's post install message")
-
- bundle :install
- expect(out).not_to include("Post-install message")
end
end
- describe "when gems do not include post install messages" do
- it "should not display any post-install messages" do
- build_git "foo" do |s|
- s.post_install_message = nil
- end
+ context "when ignore post-install messages for gem is set" do
+ it "doesn't display any post-install messages" do
gemfile <<-G
source "file://#{gem_repo1}"
- gem 'foo', :git => '#{lib_path("foo-1.0")}'
+ gem "rack"
G
+ bundle "config ignore_messages.rack true"
+
bundle :install
expect(out).not_to include("Post-install message")
end
end
-
end
diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb
index 759de0884f..0f05588c4d 100644
--- a/spec/install/gems/simple_case_spec.rb
+++ b/spec/install/gems/simple_case_spec.rb
@@ -17,7 +17,7 @@ describe "bundle install with gem sources" do
G
expect(err).to eq ""
- expect(out).to match(/StandardError: FAIL/)
+ expect(out).to match(/StandardError, "FAIL"/)
expect(bundled_app("Gemfile.lock")).not_to exist
end
diff --git a/spec/other/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb
index 739c3d0ffb..1f55ebd92d 100644
--- a/spec/other/bundle_ruby_spec.rb
+++ b/spec/other/bundle_ruby_spec.rb
@@ -1,6 +1,22 @@
require "spec_helper"
describe "bundle_ruby" do
+ context "when run" do
+ it "displays a deprecation warning" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3'
+
+ gem "foo"
+ G
+
+ bundle_ruby
+
+ expect(err).to eq("Warning: bundle_ruby will be deprecated in " \
+ "Bundler 2.0.0.")
+ end
+ end
+
context "without patchlevel" do
it "returns the ruby version" do
gemfile <<-G
@@ -12,7 +28,7 @@ describe "bundle_ruby" do
bundle_ruby
- expect(out).to eq("ruby 1.9.3")
+ expect(out).to include("ruby 1.9.3")
end
it "engine defaults to MRI" do
@@ -25,7 +41,7 @@ describe "bundle_ruby" do
bundle_ruby
- expect(out).to eq("ruby 1.9.3")
+ expect(out).to include("ruby 1.9.3")
end
it "handles jruby" do
@@ -38,7 +54,7 @@ describe "bundle_ruby" do
bundle_ruby
- expect(out).to eq("ruby 1.8.7 (jruby 1.6.5)")
+ expect(out).to include("ruby 1.8.7 (jruby 1.6.5)")
end
it "handles rbx" do
@@ -51,7 +67,7 @@ describe "bundle_ruby" do
bundle_ruby
- expect(out).to eq("ruby 1.8.7 (rbx 1.2.4)")
+ expect(out).to include("ruby 1.8.7 (rbx 1.2.4)")
end
it "raises an error if engine is used but engine version is not" do
@@ -66,7 +82,7 @@ describe "bundle_ruby" do
expect(exitstatus).not_to eq(0) if exitstatus
bundle_ruby
- expect(out).to eq("Please define :engine_version")
+ expect(out).to include("Please define :engine_version")
end
it "raises an error if engine_version is used but engine is not" do
@@ -81,7 +97,7 @@ describe "bundle_ruby" do
expect(exitstatus).not_to eq(0) if exitstatus
bundle_ruby
- expect(out).to eq("Please define :engine")
+ expect(out).to include("Please define :engine")
end
it "raises an error if engine version doesn't match ruby version for MRI" do
@@ -96,7 +112,7 @@ describe "bundle_ruby" do
expect(exitstatus).not_to eq(0) if exitstatus
bundle_ruby
- expect(out).to eq("ruby_version must match the :engine_version for MRI")
+ expect(out).to include("ruby_version must match the :engine_version for MRI")
end
it "should print if no ruby version is specified" do
@@ -108,7 +124,7 @@ describe "bundle_ruby" do
bundle_ruby
- expect(out).to eq("No ruby version specified")
+ expect(out).to include("No ruby version specified")
end
end
@@ -123,7 +139,7 @@ describe "bundle_ruby" do
bundle_ruby
- expect(out).to eq("ruby 1.9.3p429")
+ expect(out).to include("ruby 1.9.3p429")
end
it "handles an engine" do
@@ -136,7 +152,7 @@ describe "bundle_ruby" do
bundle_ruby
- expect(out).to eq("ruby 1.9.3p392 (jruby 1.7.4)")
+ expect(out).to include("ruby 1.9.3p392 (jruby 1.7.4)")
end
end
end
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index 81fcddfb32..79d3e0bd2a 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -97,7 +97,7 @@ describe "The library itself" do
end
end
- expect(@err.split("\n").reject { |f| f =~ %r{lib/bundler/vendor} }).to eq([])
+ expect(@err.split("\n").reject { |f| f =~ %r{(lib|\.)/bundler/vendor} }).to eq([])
expect(@out).to eq("")
end
end
diff --git a/spec/realworld/parallel_spec.rb b/spec/realworld/parallel_spec.rb
index 67311a7e7c..409c146d9b 100644
--- a/spec/realworld/parallel_spec.rb
+++ b/spec/realworld/parallel_spec.rb
@@ -6,7 +6,7 @@ describe "parallel", :realworld => true do
source "https://rubygems.org"
gem 'activesupport', '~> 3.2.13'
gem 'faker', '~> 1.1.2'
- gem 'i18n', '~> 0.6.0' # Because 1.7+ requires Ruby 1.9.3+
+ gem 'i18n', '~> 0.6.0' # Because 0.7+ requires Ruby 1.9.3+
G
bundle :install, :jobs => 4, :env => {"DEBUG" => "1"}
@@ -38,7 +38,7 @@ describe "parallel", :realworld => true do
source "https://rubygems.org"
gem 'activesupport', '~> 3.2.12'
gem 'faker', '~> 1.1.2'
- gem 'i18n', '~> 0.6.0' # Because 1.7+ requires Ruby 1.9.3+
+ gem 'i18n', '~> 0.6.0' # Because 0.7+ requires Ruby 1.9.3+
G
bundle :update, :jobs => 4, :env => {"DEBUG" => "1"}
diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb
new file mode 100644
index 0000000000..176c962953
--- /dev/null
+++ b/spec/runtime/inline_spec.rb
@@ -0,0 +1,88 @@
+require "spec_helper"
+
+describe "bundler/inline#gemfile" do
+ def script(code, options = {})
+ @out = ruby("require 'bundler/inline'\n\n" << code, options)
+ end
+
+ before :each do
+ build_lib "one", "1.0.0" do |s|
+ s.write "lib/baz.rb", "puts 'baz'"
+ s.write "lib/qux.rb", "puts 'qux'"
+ end
+
+ build_lib "two", "1.0.0" do |s|
+ s.write "lib/two.rb", "puts 'two'"
+ s.add_dependency "three", "= 1.0.0"
+ end
+
+ build_lib "three", "1.0.0" do |s|
+ s.write "lib/three.rb", "puts 'three'"
+ s.add_dependency "seven", "= 1.0.0"
+ end
+
+ build_lib "four", "1.0.0" do |s|
+ s.write "lib/four.rb", "puts 'four'"
+ end
+
+ build_lib "five", "1.0.0", :no_default => true do |s|
+ s.write "lib/mofive.rb", "puts 'five'"
+ end
+
+ build_lib "six", "1.0.0" do |s|
+ s.write "lib/six.rb", "puts 'six'"
+ end
+
+ build_lib "seven", "1.0.0" do |s|
+ s.write "lib/seven.rb", "puts 'seven'"
+ end
+
+ build_lib "eight", "1.0.0" do |s|
+ s.write "lib/eight.rb", "puts 'eight'"
+ end
+
+ build_lib "four", "1.0.0" do |s|
+ s.write "lib/four.rb", "puts 'four'"
+ end
+
+ @gemfile = <<-G
+ path "#{lib_path}"
+ gem "two"
+ gem "four", :require => false
+ G
+ end
+
+ it "requires the gems" do
+ script <<-RUBY
+ gemfile do
+ path "#{lib_path}"
+ gem "two"
+ end
+ RUBY
+
+ expect(out).to eq("two")
+ expect(exitstatus).to be_zero if exitstatus
+
+ script <<-RUBY, :expect_err => true
+ gemfile do
+ path "#{lib_path}"
+ gem "eleven"
+ end
+
+ puts "success"
+ RUBY
+
+ expect(err).to include "Could not find gem 'eleven (>= 0) ruby'"
+ expect(out).not_to include "success"
+
+ script <<-RUBY
+ gemfile(true) do
+ source "file://#{gem_repo1}"
+ gem "rack"
+ end
+ RUBY
+
+ expect(out).to eq("Rack's post install message")
+ expect(exitstatus).to be_zero if exitstatus
+ end
+end
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 02ce0de369..2834689db1 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -90,6 +90,21 @@ describe "Bundler.setup" do
expect(err).to eq("")
expect(out).to match("WIN")
end
+
+ it "handles multiple non-additive invocations" do
+ ruby <<-RUBY
+ require 'bundler'
+ Bundler.setup(:default, :test)
+ Bundler.setup(:default)
+ require 'rack'
+
+ puts "FAIL"
+ RUBY
+
+ expect(err).to match("rack")
+ expect(err).to match("LoadError")
+ expect(out).not_to match("FAIL")
+ end
end
it "raises if the Gemfile was not yet installed" do
diff --git a/spec/update/gems_spec.rb b/spec/update/gems_spec.rb
index ed503e3607..4989bcfd5f 100644
--- a/spec/update/gems_spec.rb
+++ b/spec/update/gems_spec.rb
@@ -99,6 +99,16 @@ describe "bundle update" do
should_not_be_installed "rack 1.2"
end
end
+
+ describe "in a frozen bundle" do
+ it "should fail loudly" do
+ bundle "install --deployment"
+ bundle "update"
+
+ expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
+ expect(exitstatus).not_to eq(0) if exitstatus
+ end
+ end
end
describe "bundle update in more complicated situations" do