Open jdelStrother opened 1 year ago
I run into this same situation on every update as well. I keep uninstalling and reinstalling gems with native extensions which gets very tedious indeed, there are a lot :-) Would be great to find a definitive solution for this together.
I've been mitigating it by overriding GEM_HOME to include nix's derivation hash, so my gems get installed to, eg,
~/.gem/ruby/ppaf93qzk1dx2zal81js8m91snfz48z8-ruby-3.1.4/
-
let gemHome = "$HOME/.gem/ruby/${builtins.baseNameOf ruby}"; in {
# ...
shellHook = ''
export GEM_HOME="${gemHome}";
export GEM_PATH="${gemHome}";
'';
}
greetings ! @jdelStrother your solution is actually pretty neat !
The underlying issue is itself is pretty obvious, as non nix build systems have certain expectations about paths which don't hold true in nix
if you use gems from nix ( either via nixpkgs or bundix) you are not going to have those issues
here is example of using gems via bundix https://nixos.org/manual/nixpkgs/stable/#developing-with-ruby
Describe the bug
Nix's ruby seems quite brittle - if I install a gem with C extensions and then switch to a different nix ruby version (even with just a patch-level version difference), it fails to load the gem with
incompatible library version
. This can makegem
entirely unusable if, say, thestringio
gem is installed in GEM_PATH:It's not possible to run
gem uninstall stringio
orgem pristine stringio
at this point - the only fix seems to be manuallyrm -rf
ing the gem directory.The same isn't true for ruby from docker or rvm - I can update patch versions and still expect to load existing gems. Gems aren't compatible across minor/major version updates, but that's usually handled by GEM_PATH being scoped to the minor version (eg
~/.gem/ruby/3.1.0/
,~/.gem/ruby/3.2.0/
, etc).Steps To Reproduce
Steps to reproduce the behavior:
gem install foo
would be installing to the default location of~/.gem/ruby/3.1.0/gems
, but as a self-contained one-liner:gem
:Expected behavior
It successfully loads gems with c-extensions following patch-level upgrades.
Additional context
I think I've seen this even if the ruby patch level doesn't change after upgrading my nixpkgs channel, but haven't managed to narrow down a commit where that happens.
You can see this working better in docker with something like:
I'm not sure what's special about the nix version of ruby that makes it so intolerant of patch-level updates.
Notify maintainers
@vrthra @manveru @marsam
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.