-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install only one of rvm
or rbenv
for managing ruby versions
#603
Comments
Hi 👋 Thanks for writing a detailed issue, and providing proposals and workarounds. We greatly appreciate it! ✨ What do you think of a solution as mentioned in devcontainers/images#572 (comment) ? 👇
We can decide which one to install by default, or if we should disable both. In any case, I understand that we'd need to bump up the version for the Ruby Feature (which I think is alright given the confusions it would avoid) |
@samruddhikhandale Thanks for reading and considering!
Haha, I think it's probably better than all of my proposals. 😉 But I couldn't tell if it's possible to vary On the other hand, I'm not sure how necessary the
Although I'd honestly be a little bit surprised if rvm doesn't already do this or something like this, perhaps in one of its rubygems plugins. 🤞🏻 Additionally: IMO, it really doesn't make much sense to ever support more than one version manager. So, instead of two or more boolean options, what do you think about something like And, if the default is to install none of them, then it would be nice to provide install scripts for all of them, as a convenience. When none are installed, the user could be informed of these scripts, in a |
I'm commenting here, since this is the repo that appears to accept pull requests. This is also related to microsoft/vscode-dev-containers#704 and devcontainers/images#572. Although this isn't currently causing me any issues, I do have some time and would like to try to contribute some improvements to the Ruby devcontainer ecosystem, but I'm not sure if there's any kind of agreement on what the solution would be. Installing two Ruby version managers is a problem, and there's already a system Ruby installed. From what I see, the best solution would be to add a new option for version manager selection to the Ruby feature. Using a It's out-of-scope, but I've noticed some disparities between rvm and rbenv as well, such as rvm supporting the ability to specify a list of multiple ruby versions to install. I think the incremental improvement of separating out rvm and rbenv to allow for the three use cases (system ruby users, rvm users, and rbenv users) would be a good step to allow rvm users or rbenv users to implement additional enhancements for their specific version managers. Please let me know if this solution would be acceptable. I'd like to make sure that the approach would be correct before spending time and effort on a PR, especially since I'm no longer blocked in terms of being able to use these devcontainers for my projects. |
Thank you so much @ThomasOwens for being willing to contribute this change, we definitely appreciate it and we are more than happy to accept the PR. I agree that we should decide a path before you jump on to the code changes. Let me do an analysis on the existing Ruby Feature, and discuss your proposed approach with other devcontainer maintainers. I'll respond to this issue with an update soon on the next steps. Thank you for your patience. |
We love the overall idea proposed in this issue! Thank you ✨ For the question of which ruby version manager should be installed by default, started a discussion in the #devcontainers-community slack channel. We are hoping to gather feedback from the community before we finalize it. Also, opened #757 |
Is there any benefit to installing both rvm and rbenv?
Context
rvm
does so much: it installs plugins that change the behavior of rubygems and thegem
command, it overrides and updates a bunch of environment variables, it updatesumask
, it edits theruby
binary, and it performs various other mutations on your environment whenever you load your shell or change directories.Unfortunately, if you load
rbenv
or place its shims earlier in the PATH thanrvm
, then some truly weird situations arise. E.g:which gem
reports the rbenv shim, but runninggem
uses the rvm installation. And rvm can "infect" the rbenv installation with its own gem plugins, and other similar clashes. This creates an unstable system with arcane error messages that can be incredibly difficult and frustrating to debug.Even worse, the
rvm
documentation for how to uninstallrvm
simply doesn't work inside devcontainers that use the ruby feature. After the rvm files have been removed and various/etc
files have been edited, the rbenv installation might still be broken because thedevcontainer-feature.json
sets theGEM_HOME
andGEM_PATH
environment variables to rvm directories.In situations (such as GitHub Codespaces) where the default image has both
rvm
andrbenv
installed, this can run into trouble with user's dotfiles, which are often configured to check forrbenv
and prefer it overrvm
.Workarounds
Unfortunately, setting
GEM_HOME
andGEM_PATH
to empty strings is not the same as unsetting them. And it isn't possible to simply unset Dockerfile ENV vars. (Is it possible to unsetdevcontainer.json
env vars?)We can manually override those variables to something else in our own devcontainer.json files, but that still effectively breaks
rbenv
:rbenv
uses shims to load the correct versions ofruby
orgem
, and those installed versions provide their own sensible dynamic defaults. This is especially useful when switching between branches with different ruby versions, when testing multiple ruby versions with a shell script that setsRBENV_VERSION
, when using multiple repositories, or when multiple directories in a single repository have different .ruby-version files. SettingGEM_HOME
andGEM_PATH
to a static path can break all of these scenarios.I often run into this problem on public GitHub Codespaces. My most common workaround is to simply work locally and not use a devcontainer or the Codespace. If I'm just doing a quick fix, I'll remove rbenv from my dotfiles. But when I'm using the devenv for a little bit longer, I'll workaround by first
sudo rm
ing all of the rvm dirs and then callunset GEM_HOME; unset GEM_PATH
from my shell prompt.Various proposals
The simplest approach is probably to simply not install
rbenv
inside the ruby feature. It's already broken, so removing it would stop wasting people's time with long, confusing, disappointing debugging sessions.However, both anecdotally and based on github stars and forks,
rbenv
is more popular thanrvm
. It is also simpler and easier to debug. Personally, I'd rather seerbenv
promoted as the default. Users should still be able to installrvm
and I think it should still work, more or less.rvm
breaksrbenv
butrbenv
doesn't breakrvm
. However this might not be considered backward compatible, and probably requires a major version bump.IMO, the most important thing would be to simply remove the following lines from
devcontainer-feature.json
:features/src/ruby/devcontainer-feature.json
Lines 29 to 30 in 1869e59
Then, if a user wants to disable
rvm
, all they would need to do is delete or comment out/etc/profile.d/rvm.sh
. And I think that a manually installed rvm could still work, so long as everything is able to load the environment from/etc/profile.d/rvm.sh
.There might be some reason that
rvm
is strongly preferred, e.g: installations are faster because it downloads binaries and bit-twiddles them, rather than compile them. In that case, it might be reasonable to use the "mini rvm" integration that is available forchruby
: https://rvm.io/workflow/chruby. This usesmrvm
to install ruby versions andchruby
to switch. I believe thismrvm
approach could also be made to work withrbenv
, although I've never attempted this myself.If any of these proposals sound like they might be acceptable, or if you have another better alternative in mind, I can create a draft PR for you to review.
The text was updated successfully, but these errors were encountered: