Closed
Description
While preparing to upgrade our ruby version, we've found that when updating to a 2.5.x version of rubygems, one can do no more than one additional up-/downgrade - all further up/downgrade attempts fail with no implicit conversion of nil into String
.
To reproduce:
# gem --version
2.0.14
gem update -N --system 2.5.2
Updating rubygems-update
Fetching: rubygems-update-2.5.2.gem (100%)
Successfully installed rubygems-update-2.5.2
Installing RubyGems 2.5.2
RubyGems 2.5.2 installed
(snip changelog)
RubyGems installed the following executables:
/opt/rubies/ruby-2.0.0-p645/bin/gem
RubyGems system software updated
# gem --version
2.5.2
Now change to another version (2.5.0 shown here, verified with 2.4.8 as well)
# gem update -N --system 2.5.0
Updating rubygems-update
Fetching: rubygems-update-2.5.0.gem (100%)
Successfully installed rubygems-update-2.5.0
Installing RubyGems 2.5.0
RubyGems 2.5.0 installed
RubyGems installed the following executables:
/opt/rubies/ruby-2.0.0-p645/bin/gem
RubyGems system software updated
# gem --version
2.5.0
Subsequent attempts fail:
# gem update -N --system 2.5.1
Updating rubygems-update
Fetching: rubygems-update-2.5.1.gem (100%)
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
# gem update -N --system 2.4.0
Updating rubygems-update
Fetching: rubygems-update-2.4.0.gem (100%)
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
# gem --version
2.5.0
One can work around the issue by manually removing the newly installed version within site_ruby
, downgrading to the version bundled with ruby.
We're encountering the issue on both MRI 2.0 and MRI 2.1.
#1557 is likely related.
This issue is related to:
- The command line
gem
Environment details:
- Ruby 2.0
- Ruby 2.1
- CentOS 6.7
- x86_64
- chruby
Activity
segiddins commentedon Mar 22, 2016
This has been fixed in RubyGems 2.6.2, I believe -- could you try upgrading to that? Thanks!
(presuming that the issue is the one fixed by #1469)
roeme commentedon Mar 22, 2016
Here you go @segiddins :
Upgrade to 2.6.2 from bundled:
Now roll back to randomly chosen 2.4.0
And at last, try to go forward to 2.4.8:
Rather weird error, and now it seems to me it's not confined to 2.5.x.
For kicks, I tried to do a
2.0.14 → 2.6.2 → 2.6.1 (→ 2.6.0)
. As I got tired of recompiling ruby all the time, I manually cleaned out the newer rubygems version. Follow along the by no means scientific throubleshooting below:Throw out old rubygems:
(not sure about the significance of removing
update_rubygems
)Update to 2.6.2:
Downgrade to 2.6.1:
Onwards to 2.6.0 fails:
Note that I've just checked
2.0.14 → 2.4.8→ 2.4.7 → 2.4.6 → 2.4.5 → 2.4.8
which works flawlessly.At this point, it looks to me like something in
>= 2.5.0
breaks the second to next update (Don't have enough insight into rubygems to determine wether that's even possible).segiddins commentedon Mar 22, 2016
(Might also be related to #1561)
duckinator commentedon Mar 30, 2016
I ran into this issue before but assumed I'd broken things with unrelated shenanigans.
djberg96 commentedon Apr 9, 2016
Similar issue. Am at 2.5.1, did an update, then downgraded, then tried to update again. Here's the backtrace in all its glory:
segiddins commentedon Apr 9, 2016
Yes, this broke a few times but we confirmed that 2.6.3 will fix things for the future.
duckinator commentedon Apr 12, 2016
@segiddins so this is resolved for future builds, then? And presumably there isn't a way to fix it for previous releases?
segiddins commentedon Apr 12, 2016
Basically. The fix (for some old versions) is to explicitly specify the version to
--system=
duckinator commentedon Apr 12, 2016
Alright, in that case I'm closing this issue.
ujifgc commentedon Sep 7, 2016
On Debian stretch I succeeded to upgrade stock
rubygems
2.5.1
to2.6.6
only after runningrm /usr/local/bin/update_rubygems
wjordan commentedon Feb 10, 2018
I looked at this issue in depth today, here's my detailed analysis of what causes this error and on exactly which version combinations:
Rubygems uses a very fragile string-matching regex to parse the spec name from an existing binstub:
< 2.5.2
([Installer] Change binstub to handle when a newer version is missing … #1407), the regex Rubygems uses to match binstubs checks forgem '[name]',
only.>= 2.5.2
([Installer] Change binstub to handle when a newer version is missing … #1407) through< 2.7.0
([Installer] Generate backwards-compatible binstubs #1904), Rubygems generated binstubs withoutgem '#{spec.name}',
contents.A bug (#1560) causes
no implicit conversion of nil into String
error to be thrown when the binstub didn't match its regex. This bug affected versions <2.6.3
(fixed in #1561).Consistent repro is to update from a version
>= 2.5.2
and< 2.7.0
, to a version< 2.5.2
, and then attempt another update to any version:Minimal fix is to add
--force
, which will bypassing the faulty regex-check logic entirely:duckinator commentedon Feb 10, 2018
@wjordan thanks for the thorough investigation of it! 🙂
fulldecent commentedon Apr 15, 2018
Solution on macOS 10.13.4: