Rubygems: Fails with stringio gem

Created on 28 Jul 2020  路  4Comments  路  Source: rubygems/rubygems

Recently I updated csv gem in my project, that contains adding stringio gem https://github.com/ruby/csv/commit/09dd9f27717f2159a5c4a4949a50f91d05fb640f

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

Bundler

Most helpful comment

All 4 comments

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.

The change was reverted so I guess we can close it https://github.com/ruby/csv/commit/e0c7074a82559ca5c798471679a77a9605ba0dd5

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.

Was this page helpful?
0 / 5 - 0 ratings