Open dabroz opened 5 months ago
Could you provide a way to reproduce this?
I am also seeing the same thing on my Rails project:
.../.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/strscan-3.1.0/lib/strscan.bundle: warning: already initialized constant StringScanner::Version
.../.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/strscan-3.1.0/lib/strscan.bundle: warning: already initialized constant StringScanner::Id
I get this when I run my test suite - rspec.
In my Rails project, strscan
is used by rexml
which is used by rubocop
.
I've created a minified version of the project here: https://github.com/dabroz/strscantest
To see this behaviour, clone the repo, then run bundle; rspec test.rb
There is also a Dockerfile you can test wit h./dockme
But the strangest thing is that there have to be very specific circumstances to observe this problem:
rspec
via shim (when running bundle exec rspec
it works fine)Thanks for preparing a minified project.
Why do you want to use rspec
not bundle exec rspec
?
In general, you should use bundle exec ...
when you use Gemfile
to manage your dependency.
Overall sure, but this happens even on a clean rbenv install, where only gems are the ones installed from the Gemfile.
Could you show gem list
output on the reproduced environment?
Bingo!
strscan (3.1.0, default: 3.0.7)
After pinning it:
gem 'strscan', '3.0.7'
it doesn't show the warning anymore. I had to pin rubocop to an earlier version (1.63.0
) as the latest requires the latest strscan:
rubocop was resolved to 1.64.0, which depends on
rexml (>= 3.2.5, < 4.0) was resolved to 3.2.8, which depends on
strscan (>= 3.0.9)
So can we do anything if a newer version of a default gem is needed?
The next REXML version that includes https://github.com/ruby/rexml/issues/132 will change the situation. It relaxes required strscan version.
(But bundle exec rspec
is still preferred.)
Got the same message when running only rspec without bundle exec. The message appeared after going from ruby 3.1.6 to ruby 3.2.0. Im using strscan (3.1.0)
If gem list | grep strscan
has multiple versions, you must use bundle exec
to choose only one strscan.
When using this gem with ruby 3.3.1 I'm getting