ruby/rubygems · error · InvalidOption
Cannot specify --all along with specific options.
Error message
Cannot specify --all along with specific options.
What it means
Bundler raises this Bundler::InvalidOption from the `bundle update` command when the --all flag is combined with any narrowing selector. In lib/bundler/cli/update.rb:21 a full update means no gem names, no --source, no --group, no --ruby and no --bundler; line 28 raises when --all contradicts that. Updating everything and updating a subset are mutually exclusive operations, so bundler aborts before resolution starts.
Source
Thrown at lib/bundler/cli/update.rb:29
def run
Bundler.ui.level = "warn" if options[:quiet]
update_bundler = options[:bundler]
Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler) if update_bundler
sources = Array(options[:source])
groups = Array(options[:group]).map(&:to_sym)
full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !update_bundler
if full_update && !options[:all]
if Bundler.settings[:update_requires_all_flag]
raise InvalidOption, "To update everything, pass the `--all` flag."
end
SharedHelpers.feature_deprecated! "Pass --all to `bundle update` to update everything"
elsif !full_update && options[:all]
raise InvalidOption, "Cannot specify --all along with specific options."
end
conservative = options[:conservative]
unlock = if full_update
if conservative
{ conservative: conservative }
else
true
end
else
unless Bundler.default_lockfile.exist?
raise GemfileLockNotFound, "This Bundle hasn't been installed yet. " \
"Run `bundle install` to update and install the bundled gems."
end
explicit_gems = gems.dup
if groups.any?View on GitHub (pinned to 86cbb817a3)
Solutions
- Remove --all and keep the targeted update, e.g. `bundle update rails`
- Or remove the gem names/groups/sources and run plain `bundle update --all`
- For bundler itself use `bundle update --bundler` alone, without --all
- For the ruby directive use `bundle update --ruby` alone
- Audit wrapper scripts and aliases so --all is never appended when gems are passed
Example fix
# before bundle update --all rails # => Cannot specify --all along with specific options. # after bundle update rails
Defensive patterns
Strategy: validation
Validate before calling
# bash wrapper: refuse --all mixed with selectors before invoking bundler
if printf '%s\n' "$@" | grep -q -- '--all'; then
for a in "$@"; do
case "$a" in
--all|--quiet|-*) ;;
*) echo "error: --all cannot be combined with $a"; exit 64 ;;
esac
done
fi
exec bundle update "$@" Try / catch
# Ruby-level, when driving the CLI object directly
begin
Bundler::CLI::Update.new(options, gems).run
rescue Bundler::InvalidOption => e
warn "usage error: #{e.message}"
exit 64
end Prevention
- Pick one mode per invocation: whole-bundle with --all or targeted with a gem list
- Keep --bundler and --ruby in their own dedicated bundle update calls
- Log the final command in wrapper scripts so bad flag combinations are visible
When it happens
Trigger: Commands like `bundle update --all rails`, `bundle update --all --group development`, `bundle update --all --source https://rubygems.org`, `bundle update --all --ruby`, or `bundle update --all --bundler`. Each makes full_update false while options[:all] is set, hitting the elsif at lib/bundler/cli/update.rb:28.
Common situations: CI or deploy scripts that accumulated flags over time (update everything plus keep bundler current); copy-pasted commands mixing a targeted update with --all; shell aliases or wrappers that append --all to a user-supplied gem list.
Related errors
- This Bundle hasn't been installed yet. Run `bundle install`
- #{gemfile} not found
- Your lockfile needs to be updated, but it can't be because f
- can't be updated because file system is read-only
- The Ruby version #{@locked_ruby_version} from #{@lockfile} c
AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23).
Data as JSON: /api/errors/6c093e1b71d3d95c.
Report an issue: GitHub.