Search code examples
rubyruntimeasdf-vm

asdf-vm: Can I use global packages associated with the latest installed version of a runtime when working on a project that uses an older runtime?


I will try to explain my question with an example. The contents of my ~./default-gems are:

gem-ctags
dip
bundler
gem-browse
pry
pry-byebug
pry-doc
pry-theme
rubocop
rubocop-performance
rubocop-rake
rubygems-update
ruby-debug-ide
ruby_parser
seeing_is_believing
solargraph
sqlint

This setup is working fine for me but I was wondering if there is a way to use the gems associated with my latest runtime (currently ruby 3.2.0-dev) when working with older runtimes and/or if it would pose compatibility issues.

If not for all global gems, at least for some of them, would it be safe to uninstall those associated with older runtimes?

Thank you


Solution

  • It seems that it is safe to remove global packages associated with older runtimes as long as I keep those installed with the lastest runtime. Then I can configure a project as usual, remembering to add the latest runtime at the end.

    asdf local <plugin> <project version> <latest installed version> creates a .tool-versions file declaring that. For example, for a Ruby project I am testing, the .tool-versions contents are:

    ruby 2.6.6 3.2.0-dev