-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Invalid ruby
in Gemfile raises confusing error
#5380
Comments
Please share your Gemfile so we can attempt to reproduce the issue? |
Here is my Gemfile:
The last line (ruby version) would contain Thanks for looking into it. Please let me know if I can help you with anything! |
@wintersolutions I'm pretty sure that the last line is the cause of your problem. I also think you can achieve what you want by using |
@mvz you are right, works perfectly now. Idk why I did not see it because its kinda obvious now, especially since I wrote out what it does. Thanks a lot! I use |
We should definitely have a better error message for this, thanks for bringing it to our attention! |
ruby
in Gemfile raises confusing error
Can you share the contents of |
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index ebdefe63f..6fd65b5c1 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -21,7 +21,7 @@ module Bundler
# must not be specified, or the engine version
# specified must match the version.
- @versions = Array(versions)
+ @versions = Array(versions).map {|v| Gem::Requirement.parse(v).last }
@gem_version = Gem::Requirement.create(@versions.first).requirements.first.last
@input_engine = engine && engine.to_s
@engine = engine && engine.to_s || "ruby"
diff --git a/spec/install/gemfile/ruby_spec.rb b/spec/install/gemfile/ruby_spec.rb
index 3f8957916..cff338429 100644
--- a/spec/install/gemfile/ruby_spec.rb
+++ b/spec/install/gemfile/ruby_spec.rb
@@ -86,4 +86,24 @@ RSpec.describe "ruby requirement" do
expect(the_bundle).to include_gems "rack 1.0.0"
expect(locked_ruby_version.versions).to eq(["5100"])
end
+
+ it "allows requirements with trailing whitespace" do
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ ruby "#{Gem.ruby_version}\\n \t\\n"
+ gem "rack"
+ G
+
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
+ it "fails gracefully with malformed requirements" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ ruby ">= 0", "-.\\0"
+ gem "rack"
+ G
+
+ expect(out).to include("There was an error parsing") # i.e. DSL error, not error template
+ end
end |
Here is the version file (zipped since github won't accept it otherwise): Thanks for your help and the improvement! |
…ndirect [RubyVersion] Ensure passed-in versions are valid during init Closes #5380
…ndirect [RubyVersion] Ensure passed-in versions are valid during init Closes #5380
Error Report
Questions
Please fill out answers to these questions, it'll help us figure out
why things are going wrong.
What did you do?
I ran the command
/home/foo_user/.rvm/gems/ruby-2.3.3@foo_project/bin/bundle update
What did you expect to happen?
I expected Bundler to update the gems. Because this fails, I wanted Bundler to give me a name for the Gem that has illformed requirements or a linenumber in my Gemfile to identify the root cause.
What happened instead?
Instead, what happened was that bundler quit with an error.
Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?
I tried to:
rubygems
package withgem update --system
Have you read our issues document, https://github.com/bundler/bundler/blob/master/ISSUES.md?
Tried to, but gitbhub it gives me a 404.
...
Backtrace
Environment
Bundler settings
The text was updated successfully, but these errors were encountered: