diff options
Diffstat (limited to 'lib/bundler')
49 files changed, 365 insertions, 298 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 851ae9b840..1765621cb3 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -94,9 +94,8 @@ module Bundler def warn_if_root return if Bundler.settings[:silence_root_warning] || Gem.win_platform? || !Process.uid.zero? - Bundler.ui.warn "Don't run Bundler as root. Bundler can ask for sudo " \ - "if it is needed, and installing your bundle as root will break this " \ - "application for all non-root users on this machine.", :wrap => true + Bundler.ui.warn "Don't run Bundler as root. Installing your bundle as root " \ + "will break this application for all non-root users on this machine.", :wrap => true end def dependencies_count_for(definition) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 8bd9e11f32..79369ec374 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -485,7 +485,7 @@ module Bundler @resolver ||= begin last_resolve = converge_locked_specs remove_ruby_from_platforms_if_necessary!(dependencies) - Resolver.new(source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms) + Resolver.new(source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve(last_resolve), platforms) end end @@ -878,9 +878,9 @@ module Bundler end end - def additional_base_requirements_for_resolve + def additional_base_requirements_for_resolve(last_resolve) return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources) - converge_specs(@originally_locked_specs).map do |locked_spec| + converge_specs(@originally_locked_specs - last_resolve).map do |locked_spec| Dependency.new(locked_spec.name, ">= #{locked_spec.version}") end.uniq end diff --git a/lib/bundler/errors.rb b/lib/bundler/errors.rb index f10b6cc68f..15069065ff 100644 --- a/lib/bundler/errors.rb +++ b/lib/bundler/errors.rb @@ -55,7 +55,6 @@ module Bundler class CyclicDependencyError < BundlerError; status_code(21); end class GemfileLockNotFound < BundlerError; status_code(22); end class PluginError < BundlerError; status_code(29); end - class SudoNotPermittedError < BundlerError; status_code(30); end class ThreadCreationError < BundlerError; status_code(33); end class APIResponseMismatchError < BundlerError; status_code(34); end class APIResponseInvalidDependenciesError < BundlerError; status_code(35); end diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index e441b941c2..983de3137c 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -39,7 +39,6 @@ module Bundler settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? } settings_flag(:suppress_install_using_messages) { bundler_3_mode? } settings_flag(:update_requires_all_flag) { bundler_4_mode? } - settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_3_mode? } settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install } diff --git a/lib/bundler/gem_version_promoter.rb b/lib/bundler/gem_version_promoter.rb index ddf7446dd2..1ae41e2928 100644 --- a/lib/bundler/gem_version_promoter.rb +++ b/lib/bundler/gem_version_promoter.rb @@ -55,19 +55,17 @@ module Bundler @level = v end - # Given a Dependency and an Array of SpecGroups of available versions for a - # gem, this method will return the Array of SpecGroups sorted (and possibly + # Given a Dependency and an Array of Specifications of available versions for a + # gem, this method will return the Array of Specifications sorted (and possibly # truncated if strict is true) in an order to give preference to the current # level (:major, :minor or :patch) when resolution is deciding what versions # best resolve all dependencies in the bundle. # @param dep [Dependency] The Dependency of the gem. - # @param spec_groups [SpecGroup] An array of SpecGroups for the same gem + # @param spec_groups [Specification] An array of Specifications for the same gem # named in the @dep param. - # @return [SpecGroup] A new instance of the SpecGroup Array sorted and + # @return [Specification] A new instance of the Specification Array sorted and # possibly filtered. def sort_versions(dep, spec_groups) - before_result = "before sort_versions: #{debug_format_result(dep, spec_groups).inspect}" if DEBUG - @sort_versions[dep] ||= begin gem_name = dep.name @@ -79,11 +77,6 @@ module Bundler filter_dep_specs(spec_groups, locked_spec) else sort_dep_specs(spec_groups, locked_spec) - end.tap do |specs| - if DEBUG - puts before_result - puts " after sort_versions: #{debug_format_result(dep, specs).inspect}" - end end end end @@ -183,12 +176,5 @@ module Bundler move, keep = result.partition {|s| s.version.to_s == version.to_s } keep.concat(move) end - - def debug_format_result(dep, spec_groups) - a = [dep.to_s, - spec_groups.map {|sg| [sg.version, sg.dependencies_for_activated_platforms.map {|dp| [dp.name, dp.requirement.to_s] }] }] - last_map = a.last.map {|sg_data| [sg_data.first.version, sg_data.last.map {|aa| aa.join(" ") }] } - [a.first, last_map, level, strict ? :strict : :not_strict] - end end end diff --git a/lib/bundler/man/bundle-add.1 b/lib/bundler/man/bundle-add.1 index 62177095d0..e5f1e228b5 100644 --- a/lib/bundler/man/bundle-add.1 +++ b/lib/bundler/man/bundle-add.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-ADD" "1" "July 2022" "" "" +.TH "BUNDLE\-ADD" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install diff --git a/lib/bundler/man/bundle-binstubs.1 b/lib/bundler/man/bundle-binstubs.1 index 9c57c7c9c5..d1204104b1 100644 --- a/lib/bundler/man/bundle-binstubs.1 +++ b/lib/bundler/man/bundle-binstubs.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-BINSTUBS" "1" "July 2022" "" "" +.TH "BUNDLE\-BINSTUBS" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-binstubs\fR \- Install the binstubs of the listed gems diff --git a/lib/bundler/man/bundle-cache.1 b/lib/bundler/man/bundle-cache.1 index fdaaa3b92a..1393caec65 100644 --- a/lib/bundler/man/bundle-cache.1 +++ b/lib/bundler/man/bundle-cache.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-CACHE" "1" "July 2022" "" "" +.TH "BUNDLE\-CACHE" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application diff --git a/lib/bundler/man/bundle-check.1 b/lib/bundler/man/bundle-check.1 index 5be7886274..71ddb5cee3 100644 --- a/lib/bundler/man/bundle-check.1 +++ b/lib/bundler/man/bundle-check.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-CHECK" "1" "July 2022" "" "" +.TH "BUNDLE\-CHECK" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems diff --git a/lib/bundler/man/bundle-clean.1 b/lib/bundler/man/bundle-clean.1 index 2bb95ed2de..e5dc4ccf92 100644 --- a/lib/bundler/man/bundle-clean.1 +++ b/lib/bundler/man/bundle-clean.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-CLEAN" "1" "July 2022" "" "" +.TH "BUNDLE\-CLEAN" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory diff --git a/lib/bundler/man/bundle-config.1 b/lib/bundler/man/bundle-config.1 index 9f7887ca91..ffc91ed492 100644 --- a/lib/bundler/man/bundle-config.1 +++ b/lib/bundler/man/bundle-config.1 @@ -1,13 +1,22 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-CONFIG" "1" "July 2022" "" "" +.TH "BUNDLE\-CONFIG" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-config\fR \- Set bundler configuration options . .SH "SYNOPSIS" -\fBbundle config\fR [list|get|set|unset] [\fIname\fR [\fIvalue\fR]] +\fBbundle config\fR list +. +.br +\fBbundle config\fR [get] NAME +. +.br +\fBbundle config\fR [set] NAME VALUE +. +.br +\fBbundle config\fR unset NAME . .SH "DESCRIPTION" This command allows you to interact with Bundler\'s configuration system\. diff --git a/lib/bundler/man/bundle-config.1.ronn b/lib/bundler/man/bundle-config.1.ronn index 905c85fcd9..6f9edc9c39 100644 --- a/lib/bundler/man/bundle-config.1.ronn +++ b/lib/bundler/man/bundle-config.1.ronn @@ -3,7 +3,10 @@ bundle-config(1) -- Set bundler configuration options ## SYNOPSIS -`bundle config` [list|get|set|unset] [<name> [<value>]] +`bundle config` list<br> +`bundle config` [get] NAME<br> +`bundle config` [set] NAME VALUE<br> +`bundle config` unset NAME ## DESCRIPTION diff --git a/lib/bundler/man/bundle-doctor.1 b/lib/bundler/man/bundle-doctor.1 index 6aad9858db..3f18aaf569 100644 --- a/lib/bundler/man/bundle-doctor.1 +++ b/lib/bundler/man/bundle-doctor.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-DOCTOR" "1" "July 2022" "" "" +.TH "BUNDLE\-DOCTOR" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-doctor\fR \- Checks the bundle for common problems diff --git a/lib/bundler/man/bundle-exec.1 b/lib/bundler/man/bundle-exec.1 index 210dd178e8..7f6a892f6c 100644 --- a/lib/bundler/man/bundle-exec.1 +++ b/lib/bundler/man/bundle-exec.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-EXEC" "1" "July 2022" "" "" +.TH "BUNDLE\-EXEC" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-exec\fR \- Execute a command in the context of the bundle diff --git a/lib/bundler/man/bundle-gem.1 b/lib/bundler/man/bundle-gem.1 index 0fb6f7d0ab..63d611bdd2 100644 --- a/lib/bundler/man/bundle-gem.1 +++ b/lib/bundler/man/bundle-gem.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-GEM" "1" "July 2022" "" "" +.TH "BUNDLE\-GEM" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem diff --git a/lib/bundler/man/bundle-help.1 b/lib/bundler/man/bundle-help.1 new file mode 100644 index 0000000000..c089342582 --- /dev/null +++ b/lib/bundler/man/bundle-help.1 @@ -0,0 +1,13 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "BUNDLE\-HELP" "1" "August 2022" "" "" +. +.SH "NAME" +\fBbundle\-help\fR \- Displays detailed help for each subcommand +. +.SH "SYNOPSIS" +\fBbundle help\fR [COMMAND] +. +.SH "DESCRIPTION" +Displays detailed help for the given subcommand\. You can specify a single \fBCOMMAND\fR at the same time\. When \fBCOMMAND\fR is omitted, help for \fBhelp\fR command will be displayed\. diff --git a/lib/bundler/man/bundle-help.1.ronn b/lib/bundler/man/bundle-help.1.ronn new file mode 100644 index 0000000000..0e144aead7 --- /dev/null +++ b/lib/bundler/man/bundle-help.1.ronn @@ -0,0 +1,12 @@ +bundle-help(1) -- Displays detailed help for each subcommand +============================================================ + +## SYNOPSIS + +`bundle help` [COMMAND] + +## DESCRIPTION + +Displays detailed help for the given subcommand. +You can specify a single `COMMAND` at the same time. +When `COMMAND` is omitted, help for `help` command will be displayed. diff --git a/lib/bundler/man/bundle-info.1 b/lib/bundler/man/bundle-info.1 index d3bad843b8..ae9bc48539 100644 --- a/lib/bundler/man/bundle-info.1 +++ b/lib/bundler/man/bundle-info.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-INFO" "1" "July 2022" "" "" +.TH "BUNDLE\-INFO" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-info\fR \- Show information for the given gem in your bundle diff --git a/lib/bundler/man/bundle-init.1 b/lib/bundler/man/bundle-init.1 index 0b3abfeefc..0b06ce8997 100644 --- a/lib/bundler/man/bundle-init.1 +++ b/lib/bundler/man/bundle-init.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-INIT" "1" "July 2022" "" "" +.TH "BUNDLE\-INIT" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-init\fR \- Generates a Gemfile into the current working directory diff --git a/lib/bundler/man/bundle-inject.1 b/lib/bundler/man/bundle-inject.1 index 53f2eaae0a..4ad37ec3eb 100644 --- a/lib/bundler/man/bundle-inject.1 +++ b/lib/bundler/man/bundle-inject.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-INJECT" "1" "July 2022" "" "" +.TH "BUNDLE\-INJECT" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile diff --git a/lib/bundler/man/bundle-install.1 b/lib/bundler/man/bundle-install.1 index 8e94fe2437..077a58f415 100644 --- a/lib/bundler/man/bundle-install.1 +++ b/lib/bundler/man/bundle-install.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-INSTALL" "1" "July 2022" "" "" +.TH "BUNDLE\-INSTALL" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-install\fR \- Install the dependencies specified in your Gemfile @@ -170,35 +170,6 @@ As a result, \fBbundle install \-\-deployment\fR installs gems to the \fBvendor/ . .IP "" 0 . -.SH "SUDO USAGE" -By default, Bundler installs gems to the same location as \fBgem install\fR\. -. -.P -In some cases, that location may not be writable by your Unix user\. In that case, Bundler will stage everything in a temporary directory, then ask you for your \fBsudo\fR password in order to copy the gems into their system location\. -. -.P -From your perspective, this is identical to installing the gems directly into the system\. -. -.P -You should never use \fBsudo bundle install\fR\. This is because several other steps in \fBbundle install\fR must be performed as the current user: -. -.IP "\(bu" 4 -Updating your \fBGemfile\.lock\fR -. -.IP "\(bu" 4 -Updating your \fBvendor/cache\fR, if necessary -. -.IP "\(bu" 4 -Checking out private git repositories using your user\'s SSH keys -. -.IP "" 0 -. -.P -Of these three, the first two could theoretically be performed by \fBchown\fRing the resulting files to \fB$SUDO_USER\fR\. The third, however, can only be performed by invoking the \fBgit\fR command as the current user\. Therefore, git gems are downloaded and installed into \fB~/\.bundle\fR rather than $GEM_HOME or $BUNDLE_PATH\. -. -.P -As a result, you should run \fBbundle install\fR as the current user, and Bundler will ask for your password if it is needed to put the gems into their final location\. -. .SH "INSTALLING GROUPS" By default, \fBbundle install\fR will install all gems in all groups in your Gemfile(5), except those declared for a different platform\. . diff --git a/lib/bundler/man/bundle-install.1.ronn b/lib/bundler/man/bundle-install.1.ronn index 47200ac2d5..be9ed0f974 100644 --- a/lib/bundler/man/bundle-install.1.ronn +++ b/lib/bundler/man/bundle-install.1.ronn @@ -224,35 +224,6 @@ will cause an error when the Gemfile(5) is modified. the `vendor/bundle` directory in the application. This may be overridden using the `--path` option. -## SUDO USAGE - -By default, Bundler installs gems to the same location as `gem install`. - -In some cases, that location may not be writable by your Unix user. In -that case, Bundler will stage everything in a temporary directory, -then ask you for your `sudo` password in order to copy the gems into -their system location. - -From your perspective, this is identical to installing the gems -directly into the system. - -You should never use `sudo bundle install`. This is because several -other steps in `bundle install` must be performed as the current user: - -* Updating your `Gemfile.lock` -* Updating your `vendor/cache`, if necessary -* Checking out private git repositories using your user's SSH keys - -Of these three, the first two could theoretically be performed by -`chown`ing the resulting files to `$SUDO_USER`. The third, however, -can only be performed by invoking the `git` command as -the current user. Therefore, git gems are downloaded and installed -into `~/.bundle` rather than $GEM_HOME or $BUNDLE_PATH. - -As a result, you should run `bundle install` as the current user, -and Bundler will ask for your password if it is needed to put the -gems into their final location. - ## INSTALLING GROUPS By default, `bundle install` will install all gems in all groups diff --git a/lib/bundler/man/bundle-list.1 b/lib/bundler/man/bundle-list.1 index 3a9cc9a237..6e89f810a1 100644 --- a/lib/bundler/man/bundle-list.1 +++ b/lib/bundler/man/bundle-list.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-LIST" "1" "July 2022" "" "" +.TH "BUNDLE\-LIST" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-list\fR \- List all the gems in the bundle diff --git a/lib/bundler/man/bundle-lock.1 b/lib/bundler/man/bundle-lock.1 index ac03c5478e..f5f0ce2bdb 100644 --- a/lib/bundler/man/bundle-lock.1 +++ b/lib/bundler/man/bundle-lock.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-LOCK" "1" "July 2022" "" "" +.TH "BUNDLE\-LOCK" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-lock\fR \- Creates / Updates a lockfile without installing diff --git a/lib/bundler/man/bundle-open.1 b/lib/bundler/man/bundle-open.1 index be6c5af248..7bda0afd33 100644 --- a/lib/bundler/man/bundle-open.1 +++ b/lib/bundler/man/bundle-open.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-OPEN" "1" "July 2022" "" "" +.TH "BUNDLE\-OPEN" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-open\fR \- Opens the source directory for a gem in your bundle diff --git a/lib/bundler/man/bundle-outdated.1 b/lib/bundler/man/bundle-outdated.1 index fc3d5e8caf..a2b8e2bf92 100644 --- a/lib/bundler/man/bundle-outdated.1 +++ b/lib/bundler/man/bundle-outdated.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-OUTDATED" "1" "July 2022" "" "" +.TH "BUNDLE\-OUTDATED" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-outdated\fR \- List installed gems with newer versions available diff --git a/lib/bundler/man/bundle-platform.1 b/lib/bundler/man/bundle-platform.1 index f5a90c59e9..7fda4ef046 100644 --- a/lib/bundler/man/bundle-platform.1 +++ b/lib/bundler/man/bundle-platform.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-PLATFORM" "1" "July 2022" "" "" +.TH "BUNDLE\-PLATFORM" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-platform\fR \- Displays platform compatibility information diff --git a/lib/bundler/man/bundle-plugin.1 b/lib/bundler/man/bundle-plugin.1 new file mode 100644 index 0000000000..7210806327 --- /dev/null +++ b/lib/bundler/man/bundle-plugin.1 @@ -0,0 +1,81 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "BUNDLE\-PLUGIN" "1" "August 2022" "" "" +. +.SH "NAME" +\fBbundle\-plugin\fR \- Manage Bundler plugins +. +.SH "SYNOPSIS" +\fBbundle plugin\fR install PLUGINS [\-\-source=\fISOURCE\fR] [\-\-version=\fIversion\fR] [\-\-git|\-\-local_git=\fIgit\-url\fR] [\-\-branch=\fIbranch\fR|\-\-ref=\fIrev\fR] +. +.br +\fBbundle plugin\fR uninstall PLUGINS +. +.br +\fBbundle plugin\fR list +. +.br +\fBbundle plugin\fR help [COMMAND] +. +.SH "DESCRIPTION" +You can install, uninstall, and list plugin(s) with this command to extend functionalities of Bundler\. +. +.SH "SUB\-COMMANDS" +. +.SS "install" +Install the given plugin(s)\. +. +.IP "\(bu" 4 +\fBbundle plugin install bundler\-graph\fR: Install bundler\-graph gem from RubyGems\.org\. The global source, specified in source in Gemfile is ignored\. +. +.IP "\(bu" 4 +\fBbundle plugin install bundler\-graph \-\-source https://example\.com\fR: Install bundler\-graph gem from example\.com\. The global source, specified in source in Gemfile is not considered\. +. +.IP "\(bu" 4 +\fBbundle plugin install bundler\-graph \-\-version 0\.2\.1\fR: You can specify the version of the gem via \fB\-\-version\fR\. +. +.IP "\(bu" 4 +\fBbundle plugin install bundler\-graph \-\-git https://github\.com/rubygems/bundler\-graph\fR: Install bundler\-graph gem from Git repository\. \fB\-\-git\fR can be replaced with \fB\-\-local\-git\fR\. You cannot use both \fB\-\-git\fR and \fB\-\-local\-git\fR\. You can use standard Git URLs like: +. +.IP "\(bu" 4 +\fBssh://[user@]host\.xz[:port]/path/to/repo\.git\fR +. +.IP "\(bu" 4 +\fBhttp[s]://host\.xz[:port]/path/to/repo\.git\fR +. +.IP "\(bu" 4 +\fB/path/to/repo\fR +. +.IP "\(bu" 4 +\fBfile:///path/to/repo\fR +. +.IP "" 0 +. +.IP +When you specify \fB\-\-git\fR/\fB\-\-local\-git\fR, you can use \fB\-\-branch\fR or \fB\-\-ref\fR to specify any branch, tag, or commit hash (revision) to use\. When you specify both, only the latter is used\. +. +.IP "" 0 +. +.SS "uninstall" +Uninstall the plugin(s) specified in PLUGINS\. +. +.SS "list" +List the installed plugins and available commands\. +. +.P +No options\. +. +.SS "help" +Describe subcommands or one specific subcommand\. +. +.P +No options\. +. +.SH "SEE ALSO" +. +.IP "\(bu" 4 +How to write a Bundler plugin \fIhttps://bundler\.io/guides/bundler_plugins\.html\fR +. +.IP "" 0 + diff --git a/lib/bundler/man/bundle-plugin.1.ronn b/lib/bundler/man/bundle-plugin.1.ronn new file mode 100644 index 0000000000..4f234eeba7 --- /dev/null +++ b/lib/bundler/man/bundle-plugin.1.ronn @@ -0,0 +1,59 @@ +bundle-plugin(1) -- Manage Bundler plugins +========================================== + +## SYNOPSIS + +`bundle plugin` install PLUGINS [--source=<SOURCE>] [--version=<version>] + [--git|--local_git=<git-url>] [--branch=<branch>|--ref=<rev>]<br> +`bundle plugin` uninstall PLUGINS<br> +`bundle plugin` list<br> +`bundle plugin` help [COMMAND] + +## DESCRIPTION + +You can install, uninstall, and list plugin(s) with this command to extend functionalities of Bundler. + +## SUB-COMMANDS + +### install + +Install the given plugin(s). + +* `bundle plugin install bundler-graph`: + Install bundler-graph gem from RubyGems.org. The global source, specified in source in Gemfile is ignored. + +* `bundle plugin install bundler-graph --source https://example.com`: + Install bundler-graph gem from example.com. The global source, specified in source in Gemfile is not considered. + +* `bundle plugin install bundler-graph --version 0.2.1`: + You can specify the version of the gem via `--version`. + +* `bundle plugin install bundler-graph --git https://github.com/rubygems/bundler-graph`: + Install bundler-graph gem from Git repository. `--git` can be replaced with `--local-git`. You cannot use both `--git` and `--local-git`. You can use standard Git URLs like: + + * `ssh://[user@]host.xz[:port]/path/to/repo.git` + * `http[s]://host.xz[:port]/path/to/repo.git` + * `/path/to/repo` + * `file:///path/to/repo` + + When you specify `--git`/`--local-git`, you can use `--branch` or `--ref` to specify any branch, tag, or commit hash (revision) to use. When you specify both, only the latter is used. + +### uninstall + +Uninstall the plugin(s) specified in PLUGINS. + +### list + +List the installed plugins and available commands. + +No options. + +### help + +Describe subcommands or one specific subcommand. + +No options. + +## SEE ALSO + +* [How to write a Bundler plugin](https://bundler.io/guides/bundler_plugins.html) diff --git a/lib/bundler/man/bundle-pristine.1 b/lib/bundler/man/bundle-pristine.1 index 44e5a83a01..d635d24e2d 100644 --- a/lib/bundler/man/bundle-pristine.1 +++ b/lib/bundler/man/bundle-pristine.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-PRISTINE" "1" "July 2022" "" "" +.TH "BUNDLE\-PRISTINE" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-pristine\fR \- Restores installed gems to their pristine condition diff --git a/lib/bundler/man/bundle-remove.1 b/lib/bundler/man/bundle-remove.1 index 29ec246018..4952e8094e 100644 --- a/lib/bundler/man/bundle-remove.1 +++ b/lib/bundler/man/bundle-remove.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-REMOVE" "1" "July 2022" "" "" +.TH "BUNDLE\-REMOVE" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-remove\fR \- Removes gems from the Gemfile diff --git a/lib/bundler/man/bundle-show.1 b/lib/bundler/man/bundle-show.1 index 227b1c8a1e..72ef3283cc 100644 --- a/lib/bundler/man/bundle-show.1 +++ b/lib/bundler/man/bundle-show.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-SHOW" "1" "July 2022" "" "" +.TH "BUNDLE\-SHOW" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem diff --git a/lib/bundler/man/bundle-update.1 b/lib/bundler/man/bundle-update.1 index 7d0988bfa5..06ceef85db 100644 --- a/lib/bundler/man/bundle-update.1 +++ b/lib/bundler/man/bundle-update.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-UPDATE" "1" "July 2022" "" "" +.TH "BUNDLE\-UPDATE" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-update\fR \- Update your gems to the latest available versions diff --git a/lib/bundler/man/bundle-viz.1 b/lib/bundler/man/bundle-viz.1 index f6f51cde0e..cf63dd8f9e 100644 --- a/lib/bundler/man/bundle-viz.1 +++ b/lib/bundler/man/bundle-viz.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE\-VIZ" "1" "July 2022" "" "" +.TH "BUNDLE\-VIZ" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile diff --git a/lib/bundler/man/bundle.1 b/lib/bundler/man/bundle.1 index f683e78cc6..d178b2f5dc 100644 --- a/lib/bundler/man/bundle.1 +++ b/lib/bundler/man/bundle.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BUNDLE" "1" "July 2022" "" "" +.TH "BUNDLE" "1" "August 2022" "" "" . .SH "NAME" \fBbundle\fR \- Ruby Dependency Management @@ -55,7 +55,7 @@ Execute a script in the current bundle Specify and read configuration options for Bundler . .TP -\fBbundle help(1)\fR +\fBbundle help(1)\fR \fIbundle\-help\.1\.html\fR Display detailed help for each subcommand . .SH "UTILITIES" @@ -120,6 +120,10 @@ Display warnings about common problems \fBbundle remove(1)\fR \fIbundle\-remove\.1\.html\fR Removes gems from the Gemfile . +.TP +\fBbundle plugin(1)\fR \fIbundle\-plugin\.1\.html\fR +Manage Bundler plugins +. .SH "PLUGINS" When running a command that isn\'t listed in PRIMARY COMMANDS or UTILITIES, Bundler will try to find an executable on your path named \fBbundler\-<command>\fR and execute it, passing down any extra arguments to it\. . diff --git a/lib/bundler/man/bundle.1.ronn b/lib/bundler/man/bundle.1.ronn index 8f0159eee5..35c0a7ef87 100644 --- a/lib/bundler/man/bundle.1.ronn +++ b/lib/bundler/man/bundle.1.ronn @@ -46,7 +46,7 @@ We divide `bundle` subcommands into primary commands and utilities: * [`bundle config(1)`](bundle-config.1.html): Specify and read configuration options for Bundler -* `bundle help(1)`: +* [`bundle help(1)`](bundle-help.1.html): Display detailed help for each subcommand ## UTILITIES @@ -97,6 +97,9 @@ We divide `bundle` subcommands into primary commands and utilities: * [`bundle remove(1)`](bundle-remove.1.html): Removes gems from the Gemfile +* [`bundle plugin(1)`](bundle-plugin.1.html): + Manage Bundler plugins + ## PLUGINS When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES, diff --git a/lib/bundler/man/gemfile.5 b/lib/bundler/man/gemfile.5 index 63a16ca3ff..3d3994153b 100644 --- a/lib/bundler/man/gemfile.5 +++ b/lib/bundler/man/gemfile.5 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GEMFILE" "5" "July 2022" "" "" +.TH "GEMFILE" "5" "August 2022" "" "" . .SH "NAME" \fBGemfile\fR \- A format for describing gem dependencies for Ruby programs diff --git a/lib/bundler/man/index.txt b/lib/bundler/man/index.txt index ef2956b2f9..6de81ea027 100644 --- a/lib/bundler/man/index.txt +++ b/lib/bundler/man/index.txt @@ -9,6 +9,7 @@ bundle-config(1) bundle-config.1 bundle-doctor(1) bundle-doctor.1 bundle-exec(1) bundle-exec.1 bundle-gem(1) bundle-gem.1 +bundle-help(1) bundle-help.1 bundle-info(1) bundle-info.1 bundle-init(1) bundle-init.1 bundle-inject(1) bundle-inject.1 @@ -18,6 +19,7 @@ bundle-lock(1) bundle-lock.1 bundle-open(1) bundle-open.1 bundle-outdated(1) bundle-outdated.1 bundle-platform(1) bundle-platform.1 +bundle-plugin(1) bundle-plugin.1 bundle-pristine(1) bundle-pristine.1 bundle-remove(1) bundle-remove.1 bundle-show(1) bundle-show.1 diff --git a/lib/bundler/match_remote_metadata.rb b/lib/bundler/match_remote_metadata.rb index e1b2f4d0e2..5e46d52441 100644 --- a/lib/bundler/match_remote_metadata.rb +++ b/lib/bundler/match_remote_metadata.rb @@ -2,8 +2,11 @@ module Bundler module FetchMetadata + # A fallback is included because the original version of the specification + # API didn't include that field, so some marshalled specs in the index have it + # set to +nil+. def matches_current_ruby? - @required_ruby_version ||= _remote_specification.required_ruby_version + @required_ruby_version ||= _remote_specification.required_ruby_version || Gem::Requirement.default super end diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index 158c69e1a1..26458bd596 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -36,6 +36,8 @@ module Bundler # @param [Hash] options various parameters as described in description. # Refer to cli/plugin for available options def install(names, options) + raise InvalidOption, "You cannot specify `--branch` and `--ref` at the same time." if options["branch"] && options["ref"] + specs = Installer.new.install(names, options) save_plugins names, specs diff --git a/lib/bundler/plugin/installer/rubygems.rb b/lib/bundler/plugin/installer/rubygems.rb index 7277234d9a..cb5db9c30e 100644 --- a/lib/bundler/plugin/installer/rubygems.rb +++ b/lib/bundler/plugin/installer/rubygems.rb @@ -6,10 +6,6 @@ module Bundler class Rubygems < Bundler::Source::Rubygems private - def requires_sudo? - false # Will change on implementation of project level plugins - end - def rubygems_dir Plugin.root end diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index a74af45027..fcb3812c5a 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -3,6 +3,7 @@ module Bundler class Resolver require_relative "vendored_molinillo" + require_relative "resolver/base" require_relative "resolver/spec_group" include GemHelpers @@ -25,15 +26,13 @@ module Bundler def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms) @source_requirements = source_requirements - @base = base + @base = Resolver::Base.new(base, additional_base_requirements) @resolver = Molinillo::Resolver.new(self, self) @results_for = {} @search_for = {} - @additional_base_requirements = additional_base_requirements @platforms = platforms @resolving_only_for_ruby = platforms == [Gem::Platform::RUBY] @gem_version_promoter = gem_version_promoter - @use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major? end def start(requirements, exclude_specs: []) @@ -43,18 +42,11 @@ module Bundler remove_from_candidates(spec) end - @base_dg = Molinillo::DependencyGraph.new - @base.each do |ls| - dep = Dependency.new(ls.name, ls.version) - @base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true) - end - @additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) } - @gem_version_promoter.prerelease_specified = @prerelease_specified = {} requirements.each {|dep| @prerelease_specified[dep.name] ||= dep.prerelease? } verify_gemfile_dependencies_are_found!(requirements) - result = @resolver.resolve(requirements, @base_dg). + result = @resolver.resolve(requirements). map(&:payload). reject {|sg| sg.name.end_with?("\0") }. map(&:to_specs). @@ -62,8 +54,20 @@ module Bundler SpecSet.new(SpecSet.new(result).for(regular_requirements, false, @platforms)) rescue Molinillo::VersionConflict => e + conflicts = e.conflicts + + deps_to_unlock = conflicts.values.inject([]) do |deps, conflict| + deps |= conflict.requirement_trees.flatten.map {|req| base_requirements[req.name] }.compact + end + + if deps_to_unlock.any? + @base.unlock_deps(deps_to_unlock) + reset_spec_cache + retry + end + message = version_conflict_message(e) - raise VersionConflict.new(e.conflicts.keys.uniq, message) + raise VersionConflict.new(conflicts.keys.uniq, message) rescue Molinillo::CircularDependencyError => e names = e.dependencies.sort_by(&:name).map {|d| "gem '#{d.name}'" } raise CyclicDependencyError, "Your bundle requires gems that depend" \ @@ -118,31 +122,22 @@ module Bundler dependency = dependency_proxy.dep name = dependency.name @search_for[dependency_proxy] ||= begin - results = results_for(dependency) + @base[name].select {|spec| requirement_satisfied_by?(dependency, nil, spec) } + locked_results = @base[name].select {|spec| requirement_satisfied_by?(dependency, nil, spec) } + locked_requirement = base_requirements[name] + results = results_for(dependency) + locked_results + results = results.select {|spec| requirement_satisfied_by?(locked_requirement, nil, spec) } if locked_requirement - if vertex = @base_dg.vertex_named(name) - locked_requirement = vertex.payload.requirement - end - - if !@prerelease_specified[name] && (!@use_gvp || locked_requirement.nil?) + if !@prerelease_specified[name] && locked_results.empty? # Move prereleases to the beginning of the list, so they're considered # last during resolution. pre, results = results.partition {|spec| spec.version.prerelease? } results = pre + results end - spec_groups = if results.any? - nested = [] - results.each do |spec| - version, specs = nested.last - if version == spec.version - specs << spec - else - nested << [spec.version, [spec]] - end - end - nested.reduce([]) do |groups, (version, specs)| - next groups if locked_requirement && !locked_requirement.satisfied_by?(version) + if results.any? + results = @gem_version_promoter.sort_versions(dependency, results) + + results.group_by(&:version).reduce([]) do |groups, (_, specs)| next groups unless specs.any? {|spec| spec.match_platform(platform) } specs_by_platform = Hash.new do |current_specs, current_platform| @@ -165,13 +160,6 @@ module Bundler else [] end - # GVP handles major itself, but it's still a bit risky to trust it with it - # until we get it settled with new behavior. For 2.x it can take over all cases. - if !@use_gvp - spec_groups - else - @gem_version_promoter.sort_versions(dependency, spec_groups) - end end end @@ -197,12 +185,6 @@ module Bundler "Gemfile" end - def name_for_locking_dependency_source - Bundler.default_lockfile.basename.to_s - rescue StandardError - "Gemfile.lock" - end - def requirement_satisfied_by?(requirement, activated, spec) requirement.matches_spec?(spec) || spec.source.is_a?(Source::Gemspec) end @@ -216,7 +198,7 @@ module Bundler name = name_for(dependency) vertex = activated.vertex_named(name) [ - @base_dg.vertex_named(name) ? 0 : 1, + @base[name].any? ? 0 : 1, vertex.payload ? 0 : 1, vertex.root? ? 0 : 1, amount_constrained(dependency), @@ -235,9 +217,12 @@ module Bundler private + def base_requirements + @base.base_requirements + end + def remove_from_candidates(spec) @base.delete(spec) - @gem_version_promoter.reset @results_for.keys.each do |dep| next unless dep.name == spec.name @@ -245,7 +230,12 @@ module Bundler @results_for[dep].reject {|s| s.name == spec.name && s.version == spec.version } end + reset_spec_cache + end + + def reset_spec_cache @search_for = {} + @gem_version_promoter.reset end # returns an integer \in (-\infty, 0] @@ -337,18 +327,6 @@ module Bundler e.message_with_trees( :full_message_for_conflict => lambda do |name, conflict| - o = if name.end_with?("\0") - String.new("Bundler found conflicting requirements for the #{name} version:") - else - String.new("Bundler could not find compatible versions for gem \"#{name}\":") - end - o << %(\n) - if conflict.locked_requirement - o << %( In snapshot (#{name_for_locking_dependency_source}):\n) - o << %( #{SharedHelpers.pretty_dependency(conflict.locked_requirement)}\n) - o << %(\n) - end - o << %( In #{name_for_explicit_dependency_source}:\n) trees = conflict.requirement_trees # called first, because we want to reduce the amount of work required to find maximal empty sets @@ -367,30 +345,41 @@ module Bundler trees.sort_by! {|t| t.reverse.map(&:name) } end - o << trees.map do |tree| - t = "".dup - depth = 2 + if trees.size > 1 || name == "bundler" + o = if name.end_with?("\0") + String.new("Bundler found conflicting requirements for the #{name} version:") + else + String.new("Bundler could not find compatible versions for gem \"#{name}\":") + end + o << %(\n) + o << %( In #{name_for_explicit_dependency_source}:\n) + o << trees.map do |tree| + t = "".dup + depth = 2 - base_tree = tree.first - base_tree_name = base_tree.name + base_tree = tree.first + base_tree_name = base_tree.name - if base_tree_name.end_with?("\0") - t = nil - else - tree.each do |req| - t << " " * depth << SharedHelpers.pretty_dependency(req) - unless tree.last == req - if spec = conflict.activated_by_name[req.name] - t << %( was resolved to #{spec.version}, which) + if base_tree_name.end_with?("\0") + t = nil + else + tree.each do |req| + t << " " * depth << SharedHelpers.pretty_dependency(req) + unless tree.last == req + if spec = conflict.activated_by_name[req.name] + t << %( was resolved to #{spec.version}, which) + end + t << %( depends on) end - t << %( depends on) + t << %(\n) + depth += 1 end - t << %(\n) - depth += 1 end - end - t - end.compact.join("\n") + t + end.compact.join("\n") + else + o = String.new + end if name == "bundler" o << %(\n Current Bundler version:\n bundler (#{Bundler::VERSION})) @@ -414,17 +403,13 @@ module Bundler end elsif name.end_with?("\0") o << %(\n Current #{name} version:\n #{SharedHelpers.pretty_dependency(@metadata_requirements.find {|req| req.name == name })}\n\n) - elsif conflict.locked_requirement - o << "\n" - o << %(Deleting your #{name_for_locking_dependency_source} file and running `bundle install` will rebuild your snapshot from scratch, using only\n) - o << %(the gems in your Gemfile, which may resolve the conflict.\n) elsif !conflict.existing o << "\n" relevant_source = conflict.requirement.source || source_for(name) - extra_message = if conflict.requirement_trees.first.size > 1 - ", which is required by gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}'," + extra_message = if trees.first.size > 1 + ", which is required by gem '#{SharedHelpers.pretty_dependency(trees.first[-2])}'," else "" end diff --git a/lib/bundler/resolver/base.rb b/lib/bundler/resolver/base.rb new file mode 100644 index 0000000000..84e087b0ae --- /dev/null +++ b/lib/bundler/resolver/base.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Bundler + class Resolver + class Base + def initialize(base, additional_base_requirements) + @base = base + @additional_base_requirements = additional_base_requirements + end + + def [](name) + @base[name] + end + + def delete(spec) + @base.delete(spec) + end + + def base_requirements + @base_requirements ||= build_base_requirements + end + + def unlock_deps(deps) + exact, lower_bound = deps.partition(&:specific?) + + exact.each do |exact_dep| + @base.delete_by_name_and_version(exact_dep.name, exact_dep.requirement.requirements.first.last) + end + + lower_bound.each do |lower_bound_dep| + @additional_base_requirements.delete(lower_bound_dep) + end + + @base_requirements = nil + end + + private + + def build_base_requirements + base_requirements = {} + @base.each do |ls| + dep = Dependency.new(ls.name, ls.version) + base_requirements[ls.name] = DepProxy.get_proxy(dep, ls.platform) + end + @additional_base_requirements.each {|d| base_requirements[d.name] = d } + base_requirements + end + end + end +end diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 08af0610c6..d14075c96b 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -504,10 +504,6 @@ module Bundler Gem::Package.build(spec, skip_validation) end - def repository_subdirectories - Gem::REPOSITORY_SUBDIRECTORIES - end - def path_separator Gem.path_separator end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index cf5675274e..a76a792743 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -45,7 +45,6 @@ module Bundler silence_root_warning suppress_install_using_messages update_requires_all_flag - use_gem_version_promoter_for_major_updates ].freeze NUMBER_KEYS = %w[ @@ -278,12 +277,6 @@ module Bundler end end - def allow_sudo? - key = key_for(:path) - path_configured = @temporary.key?(key) || @local_config.key?(key) - !path_configured - end - def ignore_config? ENV["BUNDLE_IGNORE_CONFIG"] end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index ed66dcdc12..fd34edffb7 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -102,13 +102,7 @@ module Bundler @install_path ||= begin git_scope = "#{base_name}-#{shortref_for_path(revision)}" - path = Bundler.install_path.join(git_scope) - - if !path.exist? && Bundler.requires_sudo? - Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope) - else - path - end + Bundler.install_path.join(git_scope) end end @@ -219,7 +213,7 @@ module Bundler # across different projects, this cache will be shared. # When using local git repos, this is set to the local repo. def cache_path - @cache_path ||= if Bundler.requires_sudo? || Bundler.feature_flag.global_gem_cache? + @cache_path ||= if Bundler.feature_flag.global_gem_cache? Bundler.user_cache else Bundler.bundle_path.join("cache", "bundler") diff --git a/lib/bundler/source/path/installer.rb b/lib/bundler/source/path/installer.rb index a70973bde7..0af28fe770 100644 --- a/lib/bundler/source/path/installer.rb +++ b/lib/bundler/source/path/installer.rb @@ -18,13 +18,7 @@ module Bundler @build_args = options[:build_args] || Bundler.rubygems.build_args @gem_bin_dir = "#{Bundler.rubygems.gem_dir}/bin" @disable_extensions = options[:disable_extensions] - - if Bundler.requires_sudo? - @tmp_dir = Bundler.tmp(spec.full_name).to_s - @bin_dir = "#{@tmp_dir}/bin" - else - @bin_dir = @gem_bin_dir - end + @bin_dir = @gem_bin_dir end def post_install @@ -38,25 +32,10 @@ module Bundler generate_bin unless spec.executables.empty? run_hooks(:post_install) - ensure - Bundler.rm_rf(@tmp_dir) if Bundler.requires_sudo? end private - def generate_bin - super - - if Bundler.requires_sudo? - SharedHelpers.filesystem_access(@gem_bin_dir) do |p| - Bundler.mkdir_p(p) - end - spec.executables.each do |exe| - Bundler.sudo "cp -R #{@bin_dir}/#{exe} #{@gem_bin_dir}" - end - end - end - def run_hooks(type) hooks_meth = "#{type}_hooks" return unless Gem.respond_to?(hooks_meth) diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index a50934b315..396465f0cb 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -160,15 +160,10 @@ module Bundler return if Bundler.settings[:no_install] - if requires_sudo? - install_path = Bundler.tmp(spec.full_name) - bin_path = install_path.join("bin") - else - install_path = rubygems_dir - bin_path = Bundler.system_bindir - end + install_path = rubygems_dir + bin_path = Bundler.system_bindir - Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5") + Bundler.mkdir_p bin_path unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5") require_relative "../rubygems_gem_installer" @@ -209,34 +204,7 @@ module Bundler spec.full_gem_path = installed_spec.full_gem_path spec.loaded_from = installed_spec.loaded_from - # SUDO HAX - if requires_sudo? - Bundler.rubygems.repository_subdirectories.each do |name| - src = File.join(install_path, name, "*") - dst = File.join(rubygems_dir, name) - if name == "extensions" && Dir.glob(src).any? - src = File.join(src, "*/*") - ext_src = Dir.glob(src).first - ext_src.gsub!(src[0..-6], "") - dst = File.dirname(File.join(dst, ext_src)) - end - SharedHelpers.filesystem_access(dst) do |p| - Bundler.mkdir_p(p) - end - Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any? - end - - spec.executables.each do |exe| - SharedHelpers.filesystem_access(Bundler.system_bindir) do |p| - Bundler.mkdir_p(p) - end - Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/" - end - end - spec.post_install_message - ensure - Bundler.rm_rf(install_path) if requires_sudo? end def cache(spec, custom_path = nil) @@ -475,38 +443,18 @@ module Bundler gem_path = package_path(cache_path, spec) return gem_path if File.exist?(gem_path) - if requires_sudo? - download_path = Bundler.tmp(spec.full_name) - download_cache_path = default_cache_path_for(download_path) - else - download_cache_path = cache_path - end - - SharedHelpers.filesystem_access(download_cache_path) do |p| + SharedHelpers.filesystem_access(cache_path) do |p| FileUtils.mkdir_p(p) end - download_gem(spec, download_cache_path, previous_spec) - - if requires_sudo? - SharedHelpers.filesystem_access(cache_path) do |p| - Bundler.mkdir_p(p) - end - Bundler.sudo "mv #{package_path(download_cache_path, spec)} #{gem_path}" - end + download_gem(spec, cache_path, previous_spec) gem_path - ensure - Bundler.rm_rf(download_path) if requires_sudo? end def installed?(spec) installed_specs[spec].any? && !spec.deleted_gem? end - def requires_sudo? - Bundler.requires_sudo? - end - def rubygems_dir Bundler.bundle_path end diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 4965ca9e60..1d0b7a460d 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -114,10 +114,20 @@ module Bundler SpecSet.new(arr) end + def -(other) + SpecSet.new(to_a - other.to_a) + end + def find_by_name_and_platform(name, platform) @specs.detect {|spec| spec.name == name && spec.match_platform(platform) } end + def delete_by_name_and_version(name, version) + @specs.reject! {|spec| spec.name == name && spec.version == version } + @lookup = nil + @sorted = nil + end + def what_required(spec) unless req = find {|s| s.dependencies.any? {|d| d.type == :runtime && d.name == spec.name } } return [spec] |