Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gem install with custom source builds wrong gem URI #4935

Open
1 of 5 tasks
dudarenko-io opened this issue Sep 24, 2021 · 2 comments
Open
1 of 5 tasks

Gem install with custom source builds wrong gem URI #4935

dudarenko-io opened this issue Sep 24, 2021 · 2 comments

Comments

@dudarenko-io
Copy link

I'm having a problem with running gem install using custom spec source.
I've add custom gem server source:

$ gem source --add 'https://nexus.company.com/repository/rubygems'
$ gem source -c

Then trying to install gem that surely exists on the server on url 'https://nexus.tcsbank.ru/repository/rubygems/gems/my_gem-0.1.0.gem'.

$ gem install my_gem
Traceback (most recent call last):
	6: from /Users/User/.rbenv/versions/2.7.4/lib/ruby/site_ruby/2.7.0/rubygems/request_set.rb:173:in `block (2 levels) in install'
	5: from /Users/User/.rbenv/versions/2.7.4/lib/ruby/site_ruby/2.7.0/rubygems/resolver/specification.rb:112:in `download'
	4: from /Users/User/.rbenv/versions/2.7.4/lib/ruby/site_ruby/2.7.0/rubygems/source.rb:213:in `download'
	3: from /Users/User/.rbenv/versions/2.7.4/lib/ruby/site_ruby/2.7.0/rubygems/remote_fetcher.rb:146:in `download'
	2: from /Users/User/.rbenv/versions/2.7.4/lib/ruby/site_ruby/2.7.0/rubygems/remote_fetcher.rb:285:in `cache_update_path'
	1: from /Users/User/.rbenv/versions/2.7.4/lib/ruby/site_ruby/2.7.0/rubygems/remote_fetcher.rb:248:in `fetch_path'
/Users/User/.rbenv/versions/2.7.4/lib/ruby/site_ruby/2.7.0/rubygems/remote_fetcher.rb:232:in `fetch_http': bad response Repository not found 404 (https://nexus.company.ru/repository/gems/my_gem-0.1.0.gem) (Gem::RemoteFetcher::FetchError)
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    bad response Repository not found 404 (https://nexus.tcsbank.ru/repository/gems/my_gem-0.1.0.gem)

Notice bad url 'https://nexus.tcsbank.ru/repository/gems/my_gem-0.1.0.gem'. Rubygem builds wrong uri from source url and gem path. It happens at remote_fetcher.rb:144

This issue is related to:

  • Network problems
  • Installing a library
  • Publishing a library
  • The command line gem
  • Other

Here are my current environment details:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.2.27
  - RUBY VERSION: 2.7.4 (2021-07-07 patchlevel 191) [x86_64-darwin20]
  - INSTALLATION DIRECTORY: /Users/User/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0
  - USER INSTALLATION DIRECTORY: /Users/User/.gem/ruby/2.7.0
  - RUBY EXECUTABLE: /Users/User/.rbenv/versions/2.7.4/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /Users/User/.rbenv/versions/2.7.4/bin
  - SPEC CACHE DIRECTORY: /Users/User/.local/share/gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/User/.rbenv/versions/2.7.4/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-darwin-20
  - GEM PATHS:
     - /Users/User/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0
     - /Users/User/.gem/ruby/2.7.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
     - https://nexus.company.com/repository/rubygems
  - SHELL PATH:
     - /Users/User/.rbenv/versions/2.7.4/bin
     - /usr/local/Cellar/rbenv/1.1.2/libexec
     - /Users/User/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Library/Apple/usr/bin

I will abide by the code of conduct.

@dudarenko-io
Copy link
Author

Note about URI concat method (alias of URI#merge)

irb(main):003:0> uri = URI.parse('https://example.com/1/2')
=> #<URI::HTTPS https://example.com/1/2>
irb(main):004:0> uri + '3'
=> #<URI::HTTPS https://example.com/1/3>
irb(main):005:0> uri + '/3'
=> #<URI::HTTPS https://example.com/3>

@deivid-rodriguez
Copy link
Member

It seems similar to #1829. Does it work if you add a trailing slash to the source? It should be an easy fix similar to #3123, a pull request would be super appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants