synchronysing dependencies between system and application
Asked Answered
C

5

7

The following error

You have already activated strscan 3.0.1, but your Gemfile requires strscan 3.0.3.  
Since strscan is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports strscan as a default gem. (Gem::LoadError)

where bundle -v Bundler version 2.3.13

regards a dependency which is not directly invoked in the Gemfile. The Gemfile.lock does state strscan (3.0.3) strscan is invoked by net-imap (0.2.3)

gem update --system
gem update bundler
touch tmp/restart.txt

does not solve the issue.

How can this versioning matter be ironed out? Be it via explicit verisoning or removal of dependency

Cartel answered 14/5, 2022 at 16:17 Comment(5)
Your best bet is to separate your system Ruby from your app Ruby with a Ruby version manager (rvm, rbenv, asdf, ...)Theory
rbenv is installed rbenv 1.1.2-20-g143b2c9Cartel
Are you using gemsets?Theory
no gemsets are in useCartel
Thats a strange dependency. StringScanner has been a part of the Ruby STDlib since forever.Voltmeter
A
8

Just use this command on your SSH server

gem update strscan

to check current strscan version use

gem list | grep strscan

Aftereffect answered 17/5, 2022 at 13:52 Comment(0)
N
3

Pin strscan gem version to 3.0.1.

In your Gemfile:

gem "strscan", "3.0.1"

Then bundle update to update your Gemfile.lock.

That should fix the issue.

Based on this, I believe this will be fixed in Ruby 3.1.3+ and you should be able to remove this line from your Gemfile but I'm not sure.

What's tricky about this is we only ran into the issue in Production and Staging environments, not Development or Test environments.

Another good reason to deploy everything to Staging first, test and then deploy to Production.

Night answered 14/9, 2022 at 17:8 Comment(2)
We got hit with this again after upgrading from ruby 3.3.1 to 3.3.2: You have already activated strscan 3.0.7, but your Gemfile requires strscan 3.1.0. Since strscan is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports strscan as a default gem. Night
As a follow-up, pinning 3.0.7 worked but is not a long-term solution. See my other answer for my long term solution for us.Night
A
1

I stumbled upon similar issue after upgrading to Rails v7.1.3. We got the following error on our CI:

/opt/hostedtoolcache/Ruby/3.2.2/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.12/lib/bundler/runtime.rb:309:in `check_for_activated_spec!': You have already activated mutex_m 0.1.2, but your Gemfile requires mutex_m 0.2.0. Since mutex_m is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports mutex_m as a default gem. (Gem::LoadError)

The culprit was spring, I've added DISABLE_SPRING env variable into our CI config and the error went away.

Related spring issue: https://github.com/rails/spring/issues/697

Abuse answered 21/2 at 14:52 Comment(0)
N
1

Manually install an updated version of strscan in the global gem space.

FYI, we were receiving the following error:

Error: The application encountered the following error: You have already activated strscan 3.0.7, but your Gemfile requires strscan 3.1.0. Since strscan is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports strscan as a default gem. (Gem::LoadError)

What worked was manually installing strscan at 3.1.0 in the global gem space:

sudo gem install strscan:3.1.0

This ensures that 3.1.0 used instead of the default 3.0.7:

gem list strscan

*** LOCAL GEMS ***

strscan (3.1.0, default: 3.0.7)

I tried other methods before doing this that I saw elsewhere, including:

  1. Upgrading rubygems via gem update --system 3.5.11.
  2. Setting this NGINX config: passenger_env_var RUBYOPT '-r bundler/setup';

Neither worked.

I did get it working by pinning my version of strscan to 3.0.7 in our Gemfile but that wasn't a long term solution because we needed to upgrade rexml due to a security risk and 3.0.7 depended on an older version of rexml, so we needed to upgrade strscan.

Hope that helps others.

Night answered 5/6 at 13:51 Comment(0)
H
0

Pretty much have to monkey patch the gemfile.lock to use 3.0.0 instead! https://openbuildservice.org/2022/05/11/post-mortem/

Hilltop answered 21/5, 2022 at 10:31 Comment(1)
Note - for some reason i actually had to edit it to use 3.0.1 (even though i got 3.0.0 installed :s)Hilltop

© 2022 - 2024 — McMap. All rights reserved.