Make bundle config get return status 1 when the value is not set#9505
Open
willnet wants to merge 1 commit intoruby:masterfrom
Open
Make bundle config get return status 1 when the value is not set#9505willnet wants to merge 1 commit intoruby:masterfrom
bundle config get return status 1 when the value is not set#9505willnet wants to merge 1 commit intoruby:masterfrom
Conversation
Fix ruby#3215 Change the exit status to 1 when trying to `get` a config key that does not exist, as shown below. ```sh $ bundle config get foo Settings for `foo` in order of priority. The top value will be used You have not configured a value for `foo` $ echo $? 1 ``` It seems that showing “Settings for `foo` in order of priority. The top value will be used” when the key does not exist is not very meaningful, but for now I have left the behavior unchanged except for the exit status. In the tests, some existing cases try to `get` a missing config without `raise_on_error: false`, so set the value in advance or add `raise_on_error: false` to handle them.
kou
reviewed
Apr 30, 2026
Comment on lines
+91
to
+110
| configured = Bundler.settings.locations(name).any? | ||
|
|
||
| if options[:parseable] | ||
| if value = Bundler.settings[name] | ||
| Bundler.ui.info("#{name}=#{value}") | ||
| end | ||
| return | ||
| if configured | ||
| return | ||
| else | ||
| exit 1 | ||
| end | ||
| end | ||
|
|
||
| confirm(name) | ||
| return | ||
|
|
||
| if configured | ||
| return | ||
| else | ||
| exit 1 | ||
| end |
Member
There was a problem hiding this comment.
How about simplifying this?
if value.nil?
warn_unused_scope "Ignoring --#{scope} since no value to set was given"
current_value = Bundler.settings[name]
if options[:parseable]
if current_value
Bundler.ui.info("#{name}=#{current_value}")
end
else
confirm(name)
end
if current_value
return
else
exit 1
end
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #3215
Change the exit status to 1 when trying to
geta config key that does not exist, as shown below.It seems that showing “Settings for
fooin order of priority. The top value will be used” when the key does not exist is not very meaningful, but for now I have left the behavior unchanged except for the exit status.In the tests, some existing cases try to
geta missing config withoutraise_on_error: false, so set the value in advance or addraise_on_error: falseto handle them.