Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

URI parsing issues with fallback config, for ruby < 2.1.x #4830

Closed
kevintpeng opened this issue Aug 2, 2016 · 3 comments
Closed

URI parsing issues with fallback config, for ruby < 2.1.x #4830

kevintpeng opened this issue Aug 2, 2016 · 3 comments

Comments

@kevintpeng
Copy link
Contributor

  • What did you do?

    I ran the command /Users/kevintpeng/.gem/ruby/2.1.8/bin/bundle config mirror.https://rubygems.org.fallback_timeout true

  • What did you expect to happen?

    I expected Bundler to set the configuration value of fallback_timeout to true

  • What happened instead?

    Instead, what actually happened was a URI parsing error, where the variable name was parsed as a part of the actual uri. I noticed this doesn't happen in newer versions of ruby.

Error details

URI::InvalidURIError: the scheme mirror.https does not accept registry part: rubygems.org.fallback_timeout (or bad hostname?)
  /opt/rubies/2.1.8/lib/ruby/2.1.0/uri/generic.rb:214:in `initialize'
  /opt/rubies/2.1.8/lib/ruby/2.1.0/uri/common.rb:218:in `new'
  /opt/rubies/2.1.8/lib/ruby/2.1.0/uri/common.rb:218:in `parse'
  /opt/rubies/2.1.8/lib/ruby/2.1.0/uri/common.rb:747:in `parse'
  /opt/rubies/2.1.8/lib/ruby/2.1.0/uri/common.rb:1232:in `URI'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/settings.rb:248:in `normalize_uri'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/settings.rb:159:in `key_for'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/settings.rb:82:in `locations'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/cli/config.rb:70:in `message'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/cli/config.rb:40:in `run'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/cli.rb:321:in `config'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.13.0.rc.1/exe/bundle:34:in `block in <top (required)>'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
  /Users/kevintpeng/.gem/ruby/2.1.8/gems/bundler-1.13.0.rc.1/exe/bundle:26:in `<top (required)>'
  /Users/kevintpeng/.gem/ruby/2.1.8/bin/bundle:23:in `load'
  /Users/kevintpeng/.gem/ruby/2.1.8/bin/bundle:23:in `<main>'

Environment

Bundler 1.12.5
Rubygems 2.2.5
Ruby 2.1.8p440 (2015-12-16 revision 53160) [x86_64-darwin15.0]
GEM_HOME /Users/kevintpeng/.gem/ruby/2.1.8
GEM_PATH /Users/kevintpeng/.gem/ruby/2.1.8:/opt/rubies/2.1.8/lib/ruby/gems/2.1.0
Git 2.7.4 (Apple Git-66)

  Bundler settings

jobs
Set for your local app (//.bundle/config): "4"
mirror.https://rubygems.org/
Set for your local app (//.bundle/config): "https://rubygems-proxy.org"
orig_path
Set via BUNDLE_ORIG_PATH: "/Users/kevintpeng/.gem/ruby/2.1.8/bin:/opt/rubies/2.1.8/lib/ruby/gems/2.1.0/bin:/opt/rubies/2.1.8/bin:/Users/kevintpeng/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
orig_gem_path
Set via BUNDLE_ORIG_GEM_PATH: "/Users/kevintpeng/.gem/ruby/2.1.8:/opt/rubies/2.1.8/lib/ruby/gems/2.1.0"

Is there some way we can change how the config file is parsed so that there is a distinction between uri portions and variable names? Something like mirror_rubygems.org_fallback_timeout. That way there won't be any ambiguity in parsing the URI out of these variable names.

@JuanitoFatas
Copy link
Contributor

@indirect Could you give me more clues? I tried to tackle this one but failed :( Thanks!

@indirect
Copy link
Member

@JuanitoFatas here's a reproduction script for the problem:

$ chruby 2.0
$ bundle config mirror.https://rubygems.org.fallback_timeout true
# => exception report

To fix this bug, we need to fix the normalize_uri method to correctly know which parts are the URL (https://rubygems.org), and which parts are not part of the url (mirror. at the start and (.fallback_timeout) at the end.

@segiddins
Copy link
Member

I think at the end of the day we may just need to enforce the trailing slash before the .fallback_timeout

bundlerbot added a commit that referenced this issue Apr 27, 2017
…ndirect

[Settings] Allow configuring a mirror fallback timeout without a trailing slash

Closes #4830
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants