summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-08-05 19:20:05 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-09-03 23:38:37 +0900
commit834b941253b0da4e162c4fc318559f5cb545aadd (patch)
tree4c0f3f552bd63aeeb3bf0c7a5b7b7dd7c580a3a8 /lib
parentcc1770b968257ca6d6ec5a49b6ef54d4a4853974 (diff)
Completely remove `bundle inject` command
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb8
-rw-r--r--lib/bundler/cli/inject.rb60
-rw-r--r--lib/bundler/man/bundle-inject.131
-rw-r--r--lib/bundler/man/bundle-inject.1.ronn32
-rw-r--r--lib/bundler/man/bundle.16
-rw-r--r--lib/bundler/man/bundle.1.ronn6
-rw-r--r--lib/bundler/man/index.txt1
7 files changed, 2 insertions, 142 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index c17dda30f3..38264c6ebe 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -575,12 +575,8 @@ module Bundler
end
desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", hide: true
- method_option "source", type: :string, banner: "Install gem from the given source"
- method_option "group", type: :string, banner: "Install gem into a bundler group"
- def inject(name, version)
- SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
- require_relative "cli/inject"
- Inject.new(options.dup, name, version).run
+ def inject(*)
+ SharedHelpers.feature_removed! "The `inject` command has been replaced by the `add` command"
end
desc "lock", "Creates a lockfile without installing"
diff --git a/lib/bundler/cli/inject.rb b/lib/bundler/cli/inject.rb
deleted file mode 100644
index a09d5c6bda..0000000000
--- a/lib/bundler/cli/inject.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-# frozen_string_literal: true
-
-module Bundler
- class CLI::Inject
- attr_reader :options, :name, :version, :group, :source, :gems
- def initialize(options, name, version)
- @options = options
- @name = name
- @version = version || last_version_number
- @group = options[:group].split(",") unless options[:group].nil?
- @source = options[:source]
- @gems = []
- end
-
- def run
- # The required arguments allow Thor to give useful feedback when the arguments
- # are incorrect. This adds those first two arguments onto the list as a whole.
- gems.unshift(source).unshift(group).unshift(version).unshift(name)
-
- # Build an array of Dependency objects out of the arguments
- deps = []
- # when `inject` support addition of more than one gem, then this loop will
- # help. Currently this loop is running once.
- gems.each_slice(4) do |gem_name, gem_version, gem_group, gem_source|
- ops = Gem::Requirement::OPS.map {|key, _val| key }
- has_op = ops.any? {|op| gem_version.start_with? op }
- gem_version = "~> #{gem_version}" unless has_op
- deps << Bundler::Dependency.new(gem_name, gem_version, "group" => gem_group, "source" => gem_source)
- end
-
- added = Injector.inject(deps, options)
-
- if added.any?
- Bundler.ui.confirm "Added to Gemfile:"
- Bundler.ui.confirm(added.map do |d|
- name = "'#{d.name}'"
- requirement = ", '#{d.requirement}'"
- group = ", group: #{d.groups.inspect}" if d.groups != Array(:default)
- source = ", source: '#{d.source}'" unless d.source.nil?
- %(gem #{name}#{requirement}#{group}#{source})
- end.join("\n"))
- else
- Bundler.ui.confirm "All gems were already present in the Gemfile"
- end
- end
-
- private
-
- def last_version_number
- definition = Bundler.definition(true)
- definition.remotely!
- specs = definition.index[name].sort_by(&:version)
- unless options[:pre]
- specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
- end
- spec = specs.last
- spec.version.to_s
- end
- end
-end
diff --git a/lib/bundler/man/bundle-inject.1 b/lib/bundler/man/bundle-inject.1
deleted file mode 100644
index 7e30e26a4e..0000000000
--- a/lib/bundler/man/bundle-inject.1
+++ /dev/null
@@ -1,31 +0,0 @@
-.\" generated with Ronn-NG/v0.10.1
-.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
-.TH "BUNDLE\-INJECT" "1" "August 2025" ""
-.SH "NAME"
-\fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile
-.SH "SYNOPSIS"
-\fBbundle inject\fR [GEM] [VERSION] [\-\-source=SOURCE] [\-\-group=GROUP]
-.SH "DESCRIPTION"
-Adds the named gem(s) with their version requirements to the resolved [\fBGemfile(5)\fR][Gemfile(5)]\.
-.P
-This command will add the gem to both your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock if it isn't listed yet\.
-.P
-Example:
-.IP "" 4
-.nf
-bundle install
-bundle inject 'rack' '> 0'
-.fi
-.IP "" 0
-.P
-This will inject the 'rack' gem with a version greater than 0 in your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock\.
-.P
-The \fBbundle inject\fR command was deprecated in Bundler 2\.1 and will be removed in Bundler 4\.0\.
-.SH "OPTIONS"
-.TP
-\fB\-\-source=SOURCE\fR
-Install gem from the given source\.
-.TP
-\fB\-\-group=GROUP\fR
-Install gem into a bundler group\.
-
diff --git a/lib/bundler/man/bundle-inject.1.ronn b/lib/bundler/man/bundle-inject.1.ronn
deleted file mode 100644
index 7f6f0fb5b6..0000000000
--- a/lib/bundler/man/bundle-inject.1.ronn
+++ /dev/null
@@ -1,32 +0,0 @@
-bundle-inject(1) -- Add named gem(s) with version requirements to Gemfile
-=========================================================================
-
-## SYNOPSIS
-
-`bundle inject` [GEM] [VERSION] [--source=SOURCE] [--group=GROUP]
-
-## DESCRIPTION
-
-Adds the named gem(s) with their version requirements to the resolved
-[`Gemfile(5)`][Gemfile(5)].
-
-This command will add the gem to both your [`Gemfile(5)`][Gemfile(5)] and Gemfile.lock if it
-isn't listed yet.
-
-Example:
-
- bundle install
- bundle inject 'rack' '> 0'
-
-This will inject the 'rack' gem with a version greater than 0 in your
-[`Gemfile(5)`][Gemfile(5)] and Gemfile.lock.
-
-The `bundle inject` command was deprecated in Bundler 2.1 and will be removed in Bundler 4.0.
-
-## OPTIONS
-
-* `--source=SOURCE`:
- Install gem from the given source.
-
-* `--group=GROUP`:
- Install gem into a bundler group.
diff --git a/lib/bundler/man/bundle.1 b/lib/bundler/man/bundle.1
index f87a98150d..9bee76e58b 100644
--- a/lib/bundler/man/bundle.1
+++ b/lib/bundler/man/bundle.1
@@ -94,9 +94,3 @@ Manage Bundler plugins
Prints Bundler version information
.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\.
-.SH "OBSOLETE"
-These commands are obsolete and should no longer be used:
-.IP "\(bu" 4
-\fBbundle inject(1)\fR
-.IP "" 0
-
diff --git a/lib/bundler/man/bundle.1.ronn b/lib/bundler/man/bundle.1.ronn
index 8245effabd..f368b32276 100644
--- a/lib/bundler/man/bundle.1.ronn
+++ b/lib/bundler/man/bundle.1.ronn
@@ -108,9 +108,3 @@ We divide `bundle` subcommands into primary commands and utilities:
When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES,
Bundler will try to find an executable on your path named `bundler-<command>`
and execute it, passing down any extra arguments to it.
-
-## OBSOLETE
-
-These commands are obsolete and should no longer be used:
-
-* `bundle inject(1)`
diff --git a/lib/bundler/man/index.txt b/lib/bundler/man/index.txt
index 3ea3495f1b..6cc5eb24cd 100644
--- a/lib/bundler/man/index.txt
+++ b/lib/bundler/man/index.txt
@@ -15,7 +15,6 @@ 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
bundle-install(1) bundle-install.1
bundle-issue(1) bundle-issue.1
bundle-licenses(1) bundle-licenses.1