The ABI version of dev builds of CRuby does not correspond to the ABI
In fact, in even conflicts with the next release's ABI version:
$ ruby -ve 'p RbConfig::CONFIG["ruby_version"]' ruby 3.1.0dev (2021-10-11T10:13:16Z master 0c3ac87345) [x86_64-linux] "3.1.0"
This mismatch can very easily result in segfaults, memory corruption, etc when using dev versions of CRuby,
or when using a dev version and then later the release.
- Include the git commit sha in the ABI. Pros: always correct and simple. Cons: changing more then necessary.
- Track the ABI explicitly, and bump it whenever the ABI changes. Pros: changes only when needed. Cons: easy to forget bumping it, and if checked in CI already too late.
FWIW TruffleRuby actually tracks the ABI of dev versions through this file which means it is possible to sensibly cache compiled gems even for dev versions details.
Also it stores the ABI version in .so/.bundle files and checks them when loading, so it can be sure the ABI used to compile and runtime ABI match (if not, an exception is raised).
ruby/setup-ruby has no choice for CRuby dev but to use the commit as the ABI version.
This issue is made worse by Ruby switchers like RVM & chruby setting GEM_HOME (so the ABI is effectively ignored by RubyGems in those cases, and those directories need to be cleaned manually).
When GEM_HOME is not set, it would be enough to rebuild CRuby dev and remove the directory before installing (which includes both CRuby & gems), but Ruby installers don't do that yet.
Bundler always includes the ABI version when setting the bundler path (
bundle config --local path), but if the ABI version is incorrect like for CRuby dev it's of no use.