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

Fails with stringio gem #3860

Closed
morgoth opened this issue Jul 28, 2020 · 4 comments · Fixed by #4081
Closed

Fails with stringio gem #3860

morgoth opened this issue Jul 28, 2020 · 4 comments · Fixed by #4081
Labels

Comments

@morgoth
Copy link

morgoth commented Jul 28, 2020

Recently I updated csv gem in my project, that contains adding stringio gem ruby/csv@09dd9f2

The bundler fails with:

/home/runner/.rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:312:in `check_for_activated_spec!': You have already activated stringio 0.0.2, but your Gemfile requires stringio 0.1.3. Since stringio is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports stringio as a default gem. (Gem::LoadError)

This error appears on Github Actions pipeline, but I cannot reproduce it locally.

I'm using Ruby 2.6.6 with newest bundler 2.1.4

@pocke
Copy link
Contributor

pocke commented Jul 31, 2020

I have the same problem with Ruby 2.7.1 and Bundler 1.17.3 on CIrcleCI with our Rails application.
It raises the same error.

/usr/local/lib/ruby/gems/2.7.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:319:in `check_for_activated_spec!': You have already activated stringio 0.1.0, but your Gemfile requires stringio 0.1.3. Since stringio is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports stringio as a default gem. (Gem::LoadError)
	from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:31:in `block in setup'
	from /usr/local/lib/ruby/2.7.0/forwardable.rb:235:in `each'
	from /usr/local/lib/ruby/2.7.0/forwardable.rb:235:in `each'
	from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:26:in `map'
	from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:26:in `setup'
	from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-1.17.3/lib/bundler.rb:107:in `setup'
	from /usr/local/lib/ruby/gems/2.7.0/gems/bundler-1.17.3/lib/bundler/setup.rb:20:in `<top (required)>'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/commands.rb:33:in `require'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/commands.rb:33:in `<module:Spring>'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/commands.rb:4:in `<top (required)>'
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/application.rb:87:in `preload'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/application.rb:157:in `serve'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/application.rb:139:in `run'
	from /home/ubuntu/kibela/vendor/bundle/ruby/2.7.0/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
	from -e:1:in `<main>'

But, actually bundler installed stringio v0.1.3 because I confirmed Installing stringio 0.1.3 with native extensions message in bundle install.


By the way, I made a Dockerfile to reproduce it.

FROM rubylang/ruby:2.7.1-bionic

WORKDIR /work
RUN echo 'source "https://rubygems.org"; gem "csv", "3.1.6"' >> /work/Gemfile

# Specify install path
RUN bundle config set path /tmp/gems

# Install stringio to the global. `bundle install` installs stringio v0.1.3 without this line.
RUN gem install stringio:0.1.3

# It should install stirngio to /tmp/gems, but actually it doesn't.
RUN bundle install

RUN ls /tmp/gems/ruby/2.7.0/gems

# it raises an error
RUN bundle exec ruby -e 'Bundler.setup'
$ docker build . --no-cache
Sending build context to Docker daemon  5.632kB

Step 1/8 : FROM rubylang/ruby:2.7.1-bionic
 ---> 694a7151c4f3
Step 2/8 : WORKDIR /work
 ---> Running in 2d0732303915
Removing intermediate container 2d0732303915
 ---> 51ef8b6acf21
Step 3/8 : RUN echo 'source "https://rubygems.org"; gem "csv", "3.1.6"' >> /work/Gemfile
 ---> Running in 43d380992242
Removing intermediate container 43d380992242
 ---> 7d6cf9dc7e8c
Step 4/8 : RUN bundle config set path /tmp/gems
 ---> Running in d11af8d35c56
Removing intermediate container d11af8d35c56
 ---> b7aa5890fc48
Step 5/8 : RUN gem install stringio:0.1.3
 ---> Running in 8987524acebb
Building native extensions. This could take a while...
Successfully installed stringio-0.1.3
1 gem installed
Removing intermediate container 8987524acebb
 ---> fde2e6fc381f
Step 6/8 : RUN bundle install
 ---> Running in 19524b6353fe
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 2.1.4
Using stringio 0.1.3
Fetching csv 3.1.6
Installing csv 3.1.6
Bundle complete! 1 Gemfile dependency, 3 gems now installed.
Bundled gems are installed into `/tmp/gems`
Removing intermediate container 19524b6353fe
 ---> c989884a652d
Step 7/8 : RUN ls /tmp/gems/ruby/2.7.0/gems
 ---> Running in 64277d2edf90
csv-3.1.6
Removing intermediate container 64277d2edf90
 ---> 773b32a3141b
Step 8/8 : RUN bundle exec ruby -e 'Bundler.setup'
 ---> Running in 088c5ee49f2b
/usr/local/lib/ruby/2.7.0/bundler/spec_set.rb:86:in `block in materialize': Could not find stringio-0.1.3 in any of the sources (Bundler::GemNotFound)
	from /usr/local/lib/ruby/2.7.0/bundler/spec_set.rb:80:in `map!'
	from /usr/local/lib/ruby/2.7.0/bundler/spec_set.rb:80:in `materialize'
	from /usr/local/lib/ruby/2.7.0/bundler/definition.rb:170:in `specs'
	from /usr/local/lib/ruby/2.7.0/bundler/definition.rb:237:in `specs_for'
	from /usr/local/lib/ruby/2.7.0/bundler/definition.rb:226:in `requested_specs'
	from /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:101:in `block in definition_method'
	from /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:20:in `setup'
	from /usr/local/lib/ruby/2.7.0/bundler.rb:149:in `setup'
	from /usr/local/lib/ruby/2.7.0/bundler/setup.rb:20:in `block in <top (required)>'
	from /usr/local/lib/ruby/2.7.0/bundler/ui/shell.rb:136:in `with_level'
	from /usr/local/lib/ruby/2.7.0/bundler/ui/shell.rb:88:in `silence'
	from /usr/local/lib/ruby/2.7.0/bundler/setup.rb:20:in `<top (required)>'
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
	from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'

It is not the same error, but I guess it is a related problem.

@deivid-rodriguez
Copy link
Member

Lazily loading stringio inside https://github.com/rubygems/rubygems/blob/14e11e0d796d3bcf390e6dca5a9ed3f44211c038/bundler/lib/bundler/compact_index_client/updater.rb does the trick for me. Will try to create a PR.

@morgoth
Copy link
Author

morgoth commented Oct 1, 2020

The change was reverted so I guess we can close it ruby/csv@e0c7074

@morgoth morgoth closed this as completed Oct 1, 2020
@deivid-rodriguez
Copy link
Member

deivid-rodriguez commented Oct 1, 2020

I'd still like to lazily load stringio to reduce the chance of the problem being reintroduced in a similar way. Let me reopen so I don't forget about it.

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

Successfully merging a pull request may close this issue.

3 participants