bundler 1.16.1 → 1.17.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +195 -0
- data/README.md +5 -1
- data/bundler.gemspec +9 -2
- data/lib/bundler/build_metadata.rb +19 -4
- data/lib/bundler/cli/add.rb +15 -5
- data/lib/bundler/cli/binstubs.rb +8 -2
- data/lib/bundler/cli/check.rb +1 -1
- data/lib/bundler/cli/doctor.rb +47 -1
- data/lib/bundler/cli/exec.rb +4 -4
- data/lib/bundler/cli/gem.rb +5 -2
- data/lib/bundler/cli/init.rb +5 -0
- data/lib/bundler/cli/install.rb +10 -7
- data/lib/bundler/cli/list.rb +41 -5
- data/lib/bundler/cli/outdated.rb +8 -2
- data/lib/bundler/cli/pristine.rb +4 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/update.rb +3 -3
- data/lib/bundler/cli.rb +66 -22
- data/lib/bundler/compact_index_client/updater.rb +10 -1
- data/lib/bundler/current_ruby.rb +8 -1
- data/lib/bundler/definition.rb +48 -39
- data/lib/bundler/dep_proxy.rb +2 -2
- data/lib/bundler/dependency.rb +3 -2
- data/lib/bundler/deprecate.rb +2 -1
- data/lib/bundler/dsl.rb +19 -3
- data/lib/bundler/endpoint_specification.rb +1 -1
- data/lib/bundler/env.rb +10 -8
- data/lib/bundler/feature_flag.rb +7 -0
- data/lib/bundler/fetcher/downloader.rb +10 -5
- data/lib/bundler/fetcher/index.rb +2 -2
- data/lib/bundler/fetcher.rb +3 -3
- data/lib/bundler/friendly_errors.rb +2 -0
- data/lib/bundler/gem_helper.rb +1 -1
- data/lib/bundler/gem_version_promoter.rb +16 -2
- data/lib/bundler/injector.rb +173 -14
- data/lib/bundler/installer/gem_installer.rb +9 -2
- data/lib/bundler/installer/parallel_installer.rb +6 -1
- data/lib/bundler/installer.rb +41 -10
- data/lib/bundler/lazy_specification.rb +1 -1
- data/lib/bundler/mirror.rb +2 -2
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +7 -2
- data/lib/bundler/plugin.rb +12 -5
- data/lib/bundler/process_lock.rb +1 -1
- data/lib/bundler/resolver/spec_group.rb +0 -5
- data/lib/bundler/resolver.rb +11 -10
- data/lib/bundler/ruby_version.rb +1 -1
- data/lib/bundler/rubygems_gem_installer.rb +7 -0
- data/lib/bundler/rubygems_integration.rb +9 -3
- data/lib/bundler/runtime.rb +10 -4
- data/lib/bundler/settings/validator.rb +23 -0
- data/lib/bundler/settings.rb +24 -3
- data/lib/bundler/shared_helpers.rb +33 -5
- data/lib/bundler/source/git/git_proxy.rb +6 -1
- data/lib/bundler/source/git.rb +2 -1
- data/lib/bundler/source/metadata.rb +2 -3
- data/lib/bundler/source/rubygems/remote.rb +4 -1
- data/lib/bundler/source/rubygems.rb +11 -2
- data/lib/bundler/source.rb +9 -9
- data/lib/bundler/spec_set.rb +4 -1
- data/lib/bundler/templates/Executable +1 -1
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +8 -2
- data/lib/bundler/templates/newgem/travis.yml.tt +2 -0
- data/lib/bundler/ui/shell.rb +3 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +7 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler.rb +38 -16
- data/man/bundle-add.1 +18 -3
- data/man/bundle-add.1.txt +17 -5
- data/man/bundle-add.ronn +13 -2
- data/man/bundle-binstubs.1 +4 -4
- data/man/bundle-binstubs.1.txt +4 -4
- data/man/bundle-binstubs.ronn +3 -3
- data/man/bundle-check.1 +4 -4
- data/man/bundle-check.1.txt +6 -5
- data/man/bundle-check.ronn +3 -3
- data/man/bundle-clean.1 +1 -1
- data/man/bundle-clean.1.txt +1 -1
- data/man/bundle-config.1 +48 -6
- data/man/bundle-config.1.txt +64 -26
- data/man/bundle-config.ronn +34 -9
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/man/bundle-exec.1 +4 -4
- data/man/bundle-exec.1.txt +9 -9
- data/man/bundle-exec.ronn +3 -3
- data/man/bundle-gem.1 +2 -2
- data/man/bundle-gem.1.txt +2 -2
- data/man/bundle-gem.ronn +1 -1
- data/man/bundle-info.1 +1 -1
- data/man/bundle-info.1.txt +1 -1
- data/man/bundle-init.1 +9 -4
- data/man/bundle-init.1.txt +16 -6
- data/man/bundle-init.ronn +15 -4
- data/man/bundle-inject.1 +4 -4
- data/man/bundle-inject.1.txt +5 -5
- data/man/bundle-inject.ronn +3 -3
- data/man/bundle-install.1 +7 -4
- data/man/bundle-install.1.txt +119 -108
- data/man/bundle-install.ronn +13 -4
- data/man/bundle-list.1 +32 -2
- data/man/bundle-list.1.txt +24 -2
- data/man/bundle-list.ronn +19 -1
- data/man/bundle-lock.1 +2 -2
- data/man/bundle-lock.1.txt +2 -2
- data/man/bundle-lock.ronn +1 -1
- data/man/bundle-open.1 +1 -1
- data/man/bundle-open.1.txt +1 -1
- data/man/bundle-outdated.1 +7 -3
- data/man/bundle-outdated.1.txt +11 -7
- data/man/bundle-outdated.ronn +5 -1
- data/man/bundle-package.1 +3 -3
- data/man/bundle-package.1.txt +6 -6
- data/man/bundle-package.ronn +3 -3
- data/man/bundle-platform.1 +1 -1
- data/man/bundle-platform.1.txt +1 -1
- data/man/bundle-pristine.1 +1 -1
- data/man/bundle-pristine.1.txt +1 -1
- data/man/bundle-remove.1 +31 -0
- data/man/bundle-remove.1.txt +34 -0
- data/man/bundle-remove.ronn +23 -0
- data/man/bundle-show.1 +3 -3
- data/man/bundle-show.1.txt +6 -4
- data/man/bundle-show.ronn +3 -2
- data/man/bundle-update.1 +17 -13
- data/man/bundle-update.1.txt +68 -63
- data/man/bundle-update.ronn +19 -15
- data/man/bundle-viz.1 +2 -2
- data/man/bundle-viz.1.txt +3 -2
- data/man/bundle-viz.ronn +1 -1
- data/man/bundle.1 +32 -28
- data/man/bundle.1.txt +31 -28
- data/man/bundle.ronn +30 -27
- data/man/gemfile.5 +19 -9
- data/man/gemfile.5.ronn +24 -9
- data/man/gemfile.5.txt +114 -97
- data/man/index.txt +2 -0
- metadata +16 -3
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
module Plugin
|
5
|
+
module Events
|
6
|
+
def self.define(const, event)
|
7
|
+
const = const.to_sym.freeze
|
8
|
+
if const_defined?(const) && const_get(const) != event
|
9
|
+
raise ArgumentError, "Attempting to reassign #{const} to a different value"
|
10
|
+
end
|
11
|
+
const_set(const, event) unless const_defined?(const)
|
12
|
+
@events ||= {}
|
13
|
+
@events[event] = const
|
14
|
+
end
|
15
|
+
private_class_method :define
|
16
|
+
|
17
|
+
def self.reset
|
18
|
+
@events.each_value do |const|
|
19
|
+
remove_const(const)
|
20
|
+
end
|
21
|
+
@events = nil
|
22
|
+
end
|
23
|
+
private_class_method :reset
|
24
|
+
|
25
|
+
# Check if an event has been defined
|
26
|
+
# @param event [String] An event to check
|
27
|
+
# @return [Boolean] A boolean indicating if the event has been defined
|
28
|
+
def self.defined_event?(event)
|
29
|
+
@events ||= {}
|
30
|
+
@events.key?(event)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @!parse
|
34
|
+
# A hook called before each individual gem is installed
|
35
|
+
# Includes a Bundler::ParallelInstaller::SpecInstallation.
|
36
|
+
# No state, error, post_install_message will be present as nothing has installed yet
|
37
|
+
# GEM_BEFORE_INSTALL = "before-install"
|
38
|
+
define :GEM_BEFORE_INSTALL, "before-install"
|
39
|
+
|
40
|
+
# @!parse
|
41
|
+
# A hook called after each individual gem is installed
|
42
|
+
# Includes a Bundler::ParallelInstaller::SpecInstallation.
|
43
|
+
# - If state is failed, an error will be present.
|
44
|
+
# - If state is success, a post_install_message may be present.
|
45
|
+
# GEM_AFTER_INSTALL = "after-install"
|
46
|
+
define :GEM_AFTER_INSTALL, "after-install"
|
47
|
+
|
48
|
+
# @!parse
|
49
|
+
# A hook called before any gems install
|
50
|
+
# Includes an Array of Bundler::Dependency objects
|
51
|
+
# GEM_BEFORE_INSTALL_ALL = "before-install-all"
|
52
|
+
define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
|
53
|
+
|
54
|
+
# @!parse
|
55
|
+
# A hook called after any gems install
|
56
|
+
# Includes an Array of Bundler::Dependency objects
|
57
|
+
# GEM_AFTER_INSTALL_ALL = "after-install-all"
|
58
|
+
define :GEM_AFTER_INSTALL_ALL, "after-install-all"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/bundler/plugin/index.rb
CHANGED
@@ -29,7 +29,12 @@ module Bundler
|
|
29
29
|
@hooks = {}
|
30
30
|
@load_paths = {}
|
31
31
|
|
32
|
-
|
32
|
+
begin
|
33
|
+
load_index(global_index_file, true)
|
34
|
+
rescue GenericSystemCallError
|
35
|
+
# no need to fail when on a read-only FS, for example
|
36
|
+
nil
|
37
|
+
end
|
33
38
|
load_index(local_index_file) if SharedHelpers.in_bundle?
|
34
39
|
end
|
35
40
|
|
@@ -58,7 +63,7 @@ module Bundler
|
|
58
63
|
@plugin_paths[name] = path
|
59
64
|
@load_paths[name] = load_paths
|
60
65
|
save_index
|
61
|
-
rescue
|
66
|
+
rescue StandardError
|
62
67
|
@commands = old_commands
|
63
68
|
raise
|
64
69
|
end
|
data/lib/bundler/plugin.rb
CHANGED
@@ -5,6 +5,7 @@ require "bundler/plugin/api"
|
|
5
5
|
module Bundler
|
6
6
|
module Plugin
|
7
7
|
autoload :DSL, "bundler/plugin/dsl"
|
8
|
+
autoload :Events, "bundler/plugin/events"
|
8
9
|
autoload :Index, "bundler/plugin/index"
|
9
10
|
autoload :Installer, "bundler/plugin/installer"
|
10
11
|
autoload :SourceList, "bundler/plugin/source_list"
|
@@ -66,7 +67,7 @@ module Bundler
|
|
66
67
|
installed_specs = Installer.new.install_definition(definition)
|
67
68
|
|
68
69
|
save_plugins plugins, installed_specs, builder.inferred_plugins
|
69
|
-
rescue => e
|
70
|
+
rescue RuntimeError => e
|
70
71
|
unless e.is_a?(GemfileError)
|
71
72
|
Bundler.ui.error "Failed to install plugin: #{e.message}\n #{e.backtrace[0]}"
|
72
73
|
end
|
@@ -80,8 +81,8 @@ module Bundler
|
|
80
81
|
|
81
82
|
# The directory root for all plugin related data
|
82
83
|
#
|
83
|
-
#
|
84
|
-
# in user_bundle_path
|
84
|
+
# If run in an app, points to local root, in app_config_path
|
85
|
+
# Otherwise, points to global root, in Bundler.user_bundle_path("plugin")
|
85
86
|
def root
|
86
87
|
@root ||= if SharedHelpers.in_bundle?
|
87
88
|
local_root
|
@@ -96,7 +97,7 @@ module Bundler
|
|
96
97
|
|
97
98
|
# The global directory root for all plugin related data
|
98
99
|
def global_root
|
99
|
-
Bundler.user_bundle_path
|
100
|
+
Bundler.user_bundle_path("plugin")
|
100
101
|
end
|
101
102
|
|
102
103
|
# The cache directory for plugin stuffs
|
@@ -155,6 +156,9 @@ module Bundler
|
|
155
156
|
# To be called via the API to register a hooks and corresponding block that
|
156
157
|
# will be called to handle the hook
|
157
158
|
def add_hook(event, &block)
|
159
|
+
unless Events.defined_event?(event)
|
160
|
+
raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
|
161
|
+
end
|
158
162
|
@hooks_by_event[event.to_s] << block
|
159
163
|
end
|
160
164
|
|
@@ -166,6 +170,9 @@ module Bundler
|
|
166
170
|
# @param [String] event
|
167
171
|
def hook(event, *args, &arg_blk)
|
168
172
|
return unless Bundler.feature_flag.plugins?
|
173
|
+
unless Events.defined_event?(event)
|
174
|
+
raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events"
|
175
|
+
end
|
169
176
|
|
170
177
|
plugins = index.hook_plugins(event)
|
171
178
|
return unless plugins.any?
|
@@ -264,7 +271,7 @@ module Bundler
|
|
264
271
|
load path.join(PLUGIN_FILE_NAME)
|
265
272
|
|
266
273
|
@loaded_plugin_names << name
|
267
|
-
rescue => e
|
274
|
+
rescue RuntimeError => e
|
268
275
|
Bundler.ui.error "Failed loading plugin #{name}: #{e.message}"
|
269
276
|
raise
|
270
277
|
end
|
data/lib/bundler/process_lock.rb
CHANGED
@@ -12,7 +12,7 @@ module Bundler
|
|
12
12
|
yield
|
13
13
|
f.flock(File::LOCK_UN)
|
14
14
|
end
|
15
|
-
rescue Errno::EACCES, Errno::ENOLCK
|
15
|
+
rescue Errno::EACCES, Errno::ENOLCK, *[SharedHelpers.const_get_safely(:ENOTSUP, Errno)].compact
|
16
16
|
# In the case the user does not have access to
|
17
17
|
# create the lock file or is using NFS where
|
18
18
|
# locks are not available we skip locking.
|
@@ -14,7 +14,6 @@ module Bundler
|
|
14
14
|
@version = exemplary_spec.version
|
15
15
|
@source = exemplary_spec.source
|
16
16
|
|
17
|
-
@required_by = []
|
18
17
|
@activated_platforms = []
|
19
18
|
@dependencies = nil
|
20
19
|
@specs = Hash.new do |specs, platform|
|
@@ -55,10 +54,6 @@ module Bundler
|
|
55
54
|
dependencies.concat(metadata_dependencies).flatten
|
56
55
|
end
|
57
56
|
|
58
|
-
def platforms_for_dependency_named(dependency)
|
59
|
-
__dependencies.select {|_, deps| deps.map(&:name).include? dependency }.keys
|
60
|
-
end
|
61
|
-
|
62
57
|
def ==(other)
|
63
58
|
return unless other.is_a?(SpecGroup)
|
64
59
|
name == other.name &&
|
data/lib/bundler/resolver.rb
CHANGED
@@ -39,10 +39,11 @@ module Bundler
|
|
39
39
|
@gem_version_promoter = gem_version_promoter
|
40
40
|
@allow_bundler_dependency_conflicts = Bundler.feature_flag.allow_bundler_dependency_conflicts?
|
41
41
|
@lockfile_uses_separate_rubygems_sources = Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
|
42
|
+
@use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major?
|
42
43
|
end
|
43
44
|
|
44
45
|
def start(requirements)
|
45
|
-
@prerelease_specified = {}
|
46
|
+
@gem_version_promoter.prerelease_specified = @prerelease_specified = {}
|
46
47
|
requirements.each {|dep| @prerelease_specified[dep.name] ||= dep.prerelease? }
|
47
48
|
|
48
49
|
verify_gemfile_dependencies_are_found!(requirements)
|
@@ -104,16 +105,17 @@ module Bundler
|
|
104
105
|
index = index_for(dependency)
|
105
106
|
results = index.search(dependency, @base[dependency.name])
|
106
107
|
|
107
|
-
|
108
|
+
if vertex = @base_dg.vertex_named(dependency.name)
|
109
|
+
locked_requirement = vertex.payload.requirement
|
110
|
+
end
|
111
|
+
|
112
|
+
if !@prerelease_specified[dependency.name] && (!@use_gvp || locked_requirement.nil?)
|
108
113
|
# Move prereleases to the beginning of the list, so they're considered
|
109
114
|
# last during resolution.
|
110
115
|
pre, results = results.partition {|spec| spec.version.prerelease? }
|
111
116
|
results = pre + results
|
112
117
|
end
|
113
118
|
|
114
|
-
if vertex = @base_dg.vertex_named(dependency.name)
|
115
|
-
locked_requirement = vertex.payload.requirement
|
116
|
-
end
|
117
119
|
spec_groups = if results.any?
|
118
120
|
nested = []
|
119
121
|
results.each do |spec|
|
@@ -135,7 +137,7 @@ module Bundler
|
|
135
137
|
end
|
136
138
|
# GVP handles major itself, but it's still a bit risky to trust it with it
|
137
139
|
# until we get it settled with new behavior. For 2.x it can take over all cases.
|
138
|
-
if
|
140
|
+
if !@use_gvp
|
139
141
|
spec_groups
|
140
142
|
else
|
141
143
|
@gem_version_promoter.sort_versions(dependency, spec_groups)
|
@@ -179,10 +181,6 @@ module Bundler
|
|
179
181
|
|
180
182
|
def requirement_satisfied_by?(requirement, activated, spec)
|
181
183
|
return false unless requirement.matches_spec?(spec) || spec.source.is_a?(Source::Gemspec)
|
182
|
-
if spec.version.prerelease? && !requirement.prerelease? && search_for(requirement).any? {|sg| !sg.version.prerelease? }
|
183
|
-
vertex = activated.vertex_named(spec.name)
|
184
|
-
return false if vertex.requirements.none?(&:prerelease?)
|
185
|
-
end
|
186
184
|
spec.activate_platform!(requirement.__platform) if !@platforms || @platforms.include?(requirement.__platform)
|
187
185
|
true
|
188
186
|
end
|
@@ -306,6 +304,9 @@ module Bundler
|
|
306
304
|
:solver_name => "Bundler",
|
307
305
|
:possibility_type => "gem",
|
308
306
|
:reduce_trees => lambda do |trees|
|
307
|
+
# called first, because we want to reduce the amount of work required to find maximal empty sets
|
308
|
+
trees = trees.uniq {|t| t.flatten.map {|dep| [dep.name, dep.requirement] } }
|
309
|
+
|
309
310
|
# bail out if tree size is too big for Array#combination to make any sense
|
310
311
|
return trees if trees.size > 15
|
311
312
|
maximal = 1.upto(trees.size).map do |size|
|
data/lib/bundler/ruby_version.rb
CHANGED
@@ -10,6 +10,13 @@ module Bundler
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
attr_reader :options
|
14
|
+
|
15
|
+
def initialize(gem, options = {})
|
16
|
+
@options = {}
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
13
20
|
def check_executable_overwrite(filename)
|
14
21
|
# Bundler needs to install gems regardless of binstub overwriting
|
15
22
|
end
|
@@ -132,7 +132,11 @@ module Bundler
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def inflate(obj)
|
135
|
-
Gem
|
135
|
+
if defined?(Gem::Util)
|
136
|
+
Gem::Util.inflate(obj)
|
137
|
+
else
|
138
|
+
Gem.inflate(obj)
|
139
|
+
end
|
136
140
|
end
|
137
141
|
|
138
142
|
def sources=(val)
|
@@ -570,8 +574,10 @@ module Bundler
|
|
570
574
|
@replaced_methods.each do |(sym, klass), method|
|
571
575
|
redefine_method(klass, sym, method)
|
572
576
|
end
|
573
|
-
|
574
|
-
proc.binding.
|
577
|
+
if Binding.public_method_defined?(:source_location)
|
578
|
+
post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
|
579
|
+
else
|
580
|
+
post_reset_hooks.reject! {|proc| proc.binding.eval("__FILE__") == __FILE__ }
|
575
581
|
end
|
576
582
|
@replaced_methods.clear
|
577
583
|
end
|
data/lib/bundler/runtime.rb
CHANGED
@@ -10,7 +10,7 @@ module Bundler
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def setup(*groups)
|
13
|
-
@definition.ensure_equivalent_gemfile_and_lockfile if Bundler.
|
13
|
+
@definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
|
14
14
|
|
15
15
|
groups.map!(&:to_sym)
|
16
16
|
|
@@ -79,7 +79,7 @@ module Bundler
|
|
79
79
|
required_file = file
|
80
80
|
begin
|
81
81
|
Kernel.require file
|
82
|
-
rescue => e
|
82
|
+
rescue RuntimeError => e
|
83
83
|
raise e if e.is_a?(LoadError) # we handle this a little later
|
84
84
|
raise Bundler::GemRequireError.new e,
|
85
85
|
"There was an error while trying to load the gem '#{file}'."
|
@@ -163,6 +163,7 @@ module Bundler
|
|
163
163
|
gem_dirs = Dir["#{Gem.dir}/gems/*"]
|
164
164
|
gem_files = Dir["#{Gem.dir}/cache/*.gem"]
|
165
165
|
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
|
166
|
+
extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"]
|
166
167
|
spec_gem_paths = []
|
167
168
|
# need to keep git sources around
|
168
169
|
spec_git_paths = @definition.spec_git_paths
|
@@ -170,6 +171,7 @@ module Bundler
|
|
170
171
|
spec_gem_executables = []
|
171
172
|
spec_cache_paths = []
|
172
173
|
spec_gemspec_paths = []
|
174
|
+
spec_extension_paths = []
|
173
175
|
specs.each do |spec|
|
174
176
|
spec_gem_paths << spec.full_gem_path
|
175
177
|
# need to check here in case gems are nested like for the rails git repo
|
@@ -181,6 +183,7 @@ module Bundler
|
|
181
183
|
end
|
182
184
|
spec_cache_paths << spec.cache_file
|
183
185
|
spec_gemspec_paths << spec.spec_file
|
186
|
+
spec_extension_paths << spec.extension_dir if spec.respond_to?(:extension_dir)
|
184
187
|
spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
|
185
188
|
end
|
186
189
|
spec_gem_paths.uniq!
|
@@ -192,6 +195,7 @@ module Bundler
|
|
192
195
|
stale_gem_dirs = gem_dirs - spec_gem_paths
|
193
196
|
stale_gem_files = gem_files - spec_cache_paths
|
194
197
|
stale_gemspec_files = gemspec_files - spec_gemspec_paths
|
198
|
+
stale_extension_dirs = extension_dirs - spec_extension_paths
|
195
199
|
|
196
200
|
removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
197
201
|
removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
@@ -204,8 +208,10 @@ module Bundler
|
|
204
208
|
FileUtils.rm(file) if File.exist?(file)
|
205
209
|
end
|
206
210
|
end
|
207
|
-
|
208
|
-
|
211
|
+
|
212
|
+
stale_dirs = stale_git_cache_dirs + stale_extension_dirs
|
213
|
+
stale_dirs.each do |stale_dir|
|
214
|
+
SharedHelpers.filesystem_access(stale_dir) do |dir|
|
209
215
|
FileUtils.rm_rf(dir) if File.exist?(dir)
|
210
216
|
end
|
211
217
|
end
|
@@ -74,6 +74,29 @@ module Bundler
|
|
74
74
|
fail!(key, value, "`#{other_key}` is current set to #{other_setting.inspect}", "the `#{conflicting.join("`, `")}` groups conflict")
|
75
75
|
end
|
76
76
|
end
|
77
|
+
|
78
|
+
rule %w[path], "relative paths are expanded relative to the current working directory" do |key, value, settings|
|
79
|
+
next if value.nil?
|
80
|
+
|
81
|
+
path = Pathname.new(value)
|
82
|
+
next if !path.relative? || !Bundler.feature_flag.path_relative_to_cwd?
|
83
|
+
|
84
|
+
path = path.expand_path
|
85
|
+
|
86
|
+
root = begin
|
87
|
+
Bundler.root
|
88
|
+
rescue GemfileNotFound
|
89
|
+
Pathname.pwd.expand_path
|
90
|
+
end
|
91
|
+
|
92
|
+
path = begin
|
93
|
+
path.relative_path_from(root)
|
94
|
+
rescue ArgumentError
|
95
|
+
path
|
96
|
+
end
|
97
|
+
|
98
|
+
set(settings, key, path.to_s)
|
99
|
+
end
|
77
100
|
end
|
78
101
|
end
|
79
102
|
end
|
data/lib/bundler/settings.rb
CHANGED
@@ -14,6 +14,7 @@ module Bundler
|
|
14
14
|
allow_offline_install
|
15
15
|
auto_clean_without_path
|
16
16
|
auto_install
|
17
|
+
auto_config_jobs
|
17
18
|
cache_all
|
18
19
|
cache_all_platforms
|
19
20
|
cache_command_is_package
|
@@ -25,6 +26,7 @@ module Bundler
|
|
25
26
|
disable_exec_load
|
26
27
|
disable_local_branch_check
|
27
28
|
disable_multisource
|
29
|
+
disable_platform_warnings
|
28
30
|
disable_shared_gems
|
29
31
|
disable_version_check
|
30
32
|
error_on_stderr
|
@@ -33,6 +35,7 @@ module Bundler
|
|
33
35
|
frozen
|
34
36
|
gem.coc
|
35
37
|
gem.mit
|
38
|
+
global_path_appends_ruby_scope
|
36
39
|
global_gem_cache
|
37
40
|
ignore_messages
|
38
41
|
init_gems_rb
|
@@ -42,6 +45,7 @@ module Bundler
|
|
42
45
|
no_install
|
43
46
|
no_prune
|
44
47
|
only_update_to_newer_versions
|
48
|
+
path_relative_to_cwd
|
45
49
|
path.system
|
46
50
|
plugins
|
47
51
|
prefer_gems_rb
|
@@ -53,9 +57,12 @@ module Bundler
|
|
53
57
|
suppress_install_using_messages
|
54
58
|
unlock_source_unlocks_spec
|
55
59
|
update_requires_all_flag
|
60
|
+
use_gem_version_promoter_for_major_updates
|
61
|
+
viz_command
|
56
62
|
].freeze
|
57
63
|
|
58
64
|
NUMBER_KEYS = %w[
|
65
|
+
jobs
|
59
66
|
redirect
|
60
67
|
retry
|
61
68
|
ssl_verify_mode
|
@@ -213,13 +220,13 @@ module Bundler
|
|
213
220
|
locations
|
214
221
|
end
|
215
222
|
|
216
|
-
# for legacy reasons, the ruby scope isnt appended when the setting comes from ENV or the global config,
|
223
|
+
# for legacy reasons, in Bundler 1, the ruby scope isnt appended when the setting comes from ENV or the global config,
|
217
224
|
# nor do we respect :disable_shared_gems
|
218
225
|
def path
|
219
226
|
key = key_for(:path)
|
220
227
|
path = ENV[key] || @global_config[key]
|
221
228
|
if path && !@temporary.key?(key) && !@local_config.key?(key)
|
222
|
-
return Path.new(path,
|
229
|
+
return Path.new(path, Bundler.feature_flag.global_path_appends_ruby_scope?, false, false)
|
223
230
|
end
|
224
231
|
|
225
232
|
system_path = self["path.system"] || (self[:disable_shared_gems] == false)
|
@@ -246,6 +253,20 @@ module Bundler
|
|
246
253
|
path
|
247
254
|
end
|
248
255
|
|
256
|
+
def base_path_relative_to_pwd
|
257
|
+
base_path = Pathname.new(self.base_path)
|
258
|
+
expanded_base_path = base_path.expand_path(Bundler.root)
|
259
|
+
relative_path = expanded_base_path.relative_path_from(Pathname.pwd)
|
260
|
+
if relative_path.to_s.start_with?("..")
|
261
|
+
relative_path = base_path if base_path.absolute?
|
262
|
+
else
|
263
|
+
relative_path = Pathname.new(File.join(".", relative_path))
|
264
|
+
end
|
265
|
+
relative_path
|
266
|
+
rescue ArgumentError
|
267
|
+
expanded_base_path
|
268
|
+
end
|
269
|
+
|
249
270
|
def validate!
|
250
271
|
return unless explicit_path && system_path
|
251
272
|
path = Bundler.settings.pretty_values_for(:path)
|
@@ -374,7 +395,7 @@ module Bundler
|
|
374
395
|
Pathname.new(ENV["BUNDLE_CONFIG"])
|
375
396
|
else
|
376
397
|
begin
|
377
|
-
Bundler.user_bundle_path
|
398
|
+
Bundler.user_bundle_path("config")
|
378
399
|
rescue PermissionError, GenericSystemCallError
|
379
400
|
nil
|
380
401
|
end
|
@@ -197,10 +197,12 @@ module Bundler
|
|
197
197
|
def pretty_dependency(dep, print_source = false)
|
198
198
|
msg = String.new(dep.name)
|
199
199
|
msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
|
200
|
+
|
200
201
|
if dep.is_a?(Bundler::Dependency)
|
201
202
|
platform_string = dep.platforms.join(", ")
|
202
203
|
msg << " " << platform_string if !platform_string.empty? && platform_string != Gem::Platform::RUBY
|
203
204
|
end
|
205
|
+
|
204
206
|
msg << " from the `#{dep.source}` source" if print_source && dep.source
|
205
207
|
msg
|
206
208
|
end
|
@@ -223,6 +225,10 @@ module Bundler
|
|
223
225
|
Digest(name)
|
224
226
|
end
|
225
227
|
|
228
|
+
def write_to_gemfile(gemfile_path, contents)
|
229
|
+
filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
|
230
|
+
end
|
231
|
+
|
226
232
|
private
|
227
233
|
|
228
234
|
def validate_bundle_path
|
@@ -268,7 +274,15 @@ module Bundler
|
|
268
274
|
until !File.directory?(current) || current == previous
|
269
275
|
if ENV["BUNDLE_SPEC_RUN"]
|
270
276
|
# avoid stepping above the tmp directory when testing
|
271
|
-
|
277
|
+
gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
|
278
|
+
# for Ruby Core
|
279
|
+
"lib/bundler.gemspec"
|
280
|
+
else
|
281
|
+
"bundler.gemspec"
|
282
|
+
end
|
283
|
+
|
284
|
+
# avoid stepping above the tmp directory when testing
|
285
|
+
return nil if File.file?(File.join(current, gemspec))
|
272
286
|
end
|
273
287
|
|
274
288
|
names.each do |name|
|
@@ -293,9 +307,16 @@ module Bundler
|
|
293
307
|
|
294
308
|
def set_bundle_variables
|
295
309
|
begin
|
296
|
-
|
310
|
+
exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
|
311
|
+
unless File.exist?(exe_file)
|
312
|
+
exe_file = File.expand_path("../../../exe/bundle", __FILE__)
|
313
|
+
end
|
314
|
+
Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
|
297
315
|
rescue Gem::GemNotFoundException
|
298
|
-
|
316
|
+
exe_file = File.expand_path("../../../exe/bundle", __FILE__)
|
317
|
+
# for Ruby core repository
|
318
|
+
exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
|
319
|
+
Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
|
299
320
|
end
|
300
321
|
|
301
322
|
# Set BUNDLE_GEMFILE
|
@@ -324,7 +345,7 @@ module Bundler
|
|
324
345
|
end
|
325
346
|
|
326
347
|
def bundler_ruby_lib
|
327
|
-
File.expand_path("../..", __FILE__)
|
348
|
+
resolve_path File.expand_path("../..", __FILE__)
|
328
349
|
end
|
329
350
|
|
330
351
|
def clean_load_path
|
@@ -336,12 +357,19 @@ module Bundler
|
|
336
357
|
loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
|
337
358
|
|
338
359
|
$LOAD_PATH.reject! do |p|
|
339
|
-
next if
|
360
|
+
next if resolve_path(p).start_with?(bundler_lib)
|
340
361
|
loaded_gem_paths.delete(p)
|
341
362
|
end
|
342
363
|
$LOAD_PATH.uniq!
|
343
364
|
end
|
344
365
|
|
366
|
+
def resolve_path(path)
|
367
|
+
expanded = File.expand_path(path)
|
368
|
+
return expanded unless File.respond_to?(:realpath) && File.exist?(expanded)
|
369
|
+
|
370
|
+
File.realpath(expanded)
|
371
|
+
end
|
372
|
+
|
345
373
|
def prints_major_deprecations?
|
346
374
|
require "bundler"
|
347
375
|
deprecation_release = Bundler::VERSION.split(".").drop(1).include?("99")
|
@@ -131,7 +131,12 @@ module Bundler
|
|
131
131
|
# method 2
|
132
132
|
SharedHelpers.chdir(destination) do
|
133
133
|
git_retry %(fetch --force --quiet --tags "#{path}")
|
134
|
-
|
134
|
+
|
135
|
+
begin
|
136
|
+
git "reset --hard #{@revision}"
|
137
|
+
rescue GitCommandError
|
138
|
+
raise MissingGitRevisionError.new(@revision, URICredentialsFilter.credential_filtered_uri(uri))
|
139
|
+
end
|
135
140
|
|
136
141
|
if submodules
|
137
142
|
git_retry "submodule update --init --recursive"
|
data/lib/bundler/source/git.rb
CHANGED
@@ -21,6 +21,7 @@ module Bundler
|
|
21
21
|
%w[ref branch tag revision].each {|k| options[k] = options[k].to_s if options[k] }
|
22
22
|
|
23
23
|
@uri = options["uri"] || ""
|
24
|
+
@safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
|
24
25
|
@branch = options["branch"]
|
25
26
|
@ref = options["ref"] || options["branch"] || options["tag"] || "master"
|
26
27
|
@submodules = options["submodules"]
|
@@ -77,7 +78,7 @@ module Bundler
|
|
77
78
|
nil
|
78
79
|
end
|
79
80
|
|
80
|
-
"#{
|
81
|
+
"#{@safe_uri} (at #{at}#{rev})"
|
81
82
|
end
|
82
83
|
|
83
84
|
def name
|
@@ -19,9 +19,8 @@ module Bundler
|
|
19
19
|
# can't point to the actual gemspec or else the require paths will be wrong
|
20
20
|
s.loaded_from = File.expand_path("..", __FILE__)
|
21
21
|
end
|
22
|
-
|
23
|
-
|
24
|
-
elsif local_spec = Bundler.rubygems.find_name("bundler").find {|s| s.version.to_s == VERSION }
|
22
|
+
|
23
|
+
if local_spec = Bundler.rubygems.find_name("bundler").find {|s| s.version.to_s == VERSION }
|
25
24
|
idx << local_spec
|
26
25
|
end
|
27
26
|
|
@@ -25,7 +25,10 @@ module Bundler
|
|
25
25
|
|
26
26
|
cache_uri = original_uri || uri
|
27
27
|
|
28
|
-
|
28
|
+
# URI::File of Ruby 2.6 returns empty string when given "file://".
|
29
|
+
host = defined?(URI::File) && cache_uri.is_a?(URI::File) ? nil : cache_uri.host
|
30
|
+
|
31
|
+
uri_parts = [host, cache_uri.user, cache_uri.port, cache_uri.path]
|
29
32
|
uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.compact.join("."))
|
30
33
|
|
31
34
|
uri_parts[-1] = uri_digest
|
@@ -138,6 +138,8 @@ module Bundler
|
|
138
138
|
bin_path = Bundler.system_bindir
|
139
139
|
end
|
140
140
|
|
141
|
+
Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
|
142
|
+
|
141
143
|
installed_spec = nil
|
142
144
|
Bundler.rubygems.preserve_paths do
|
143
145
|
installed_spec = Bundler::RubyGemsGemInstaller.at(
|
@@ -336,7 +338,11 @@ module Bundler
|
|
336
338
|
end
|
337
339
|
|
338
340
|
def remove_auth(remote)
|
339
|
-
remote.
|
341
|
+
if remote.user || remote.password
|
342
|
+
remote.dup.tap {|uri| uri.user = uri.password = nil }.to_s
|
343
|
+
else
|
344
|
+
remote.to_s
|
345
|
+
end
|
340
346
|
end
|
341
347
|
|
342
348
|
def installed_specs
|
@@ -477,7 +483,10 @@ module Bundler
|
|
477
483
|
else
|
478
484
|
uri = spec.remote.uri
|
479
485
|
Bundler.ui.confirm("Fetching #{version_message(spec)}")
|
480
|
-
Bundler.rubygems.download_gem(spec, uri, download_path)
|
486
|
+
rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path)
|
487
|
+
if rubygems_local_path != local_path
|
488
|
+
FileUtils.mv(rubygems_local_path, local_path)
|
489
|
+
end
|
481
490
|
cache_globally(spec, local_path)
|
482
491
|
end
|
483
492
|
end
|