I need to host different Ruby applications on a single server. Applications have mutually-incompatible ruby versions and gems. Is there a way to install RVM in system-wide mode and have gemsets which are also system-wide, and not tied to a specific user and their $HOME directory? Or is there a better approach altogether for hosting different Ruby apps on the same machine?
-
Have you read this? Might be of use. http://stackoverflow.com/questions/9771172/rbenv-surviving-without-gemsets – Beartech Jan 14 '14 at 03:58
-
Yes, there is the way to install rvm as system wide: http://stackoverflow.com/questions/21085092/rvm-how-to-change-default-path-to-home-directory/21085132#21085132 – Малъ Скрылевъ Jan 14 '14 at 06:19
2 Answers
Use mixed mode installation of RVM basically you get system installation and as every user that should have his own gemsets run:
rvm user gemsets

- 52,729
- 14
- 121
- 158
-
I tried that before even posting the question and it didn't work. The user that installed rvm in mixed mode didn't have access permissions for RVM system-wide dirs (created by RVM installation) so all RVM commands would fail. `rvmsudo` instead of `rvm` also failed with some obscure errors. The only thing that didn't return error messages was `sudo rvm`, but that created RVM directories in the *filesystem root*... (/gems, etc.). Maybe it was a RVM bug, but I'll never use RVM again for production. – Boris B. Jan 21 '14 at 12:38
-
you can not mix users for system with mixed mode users, you need to have separate user for managing(installing) rubies and separate users for applications, if you want all users to be able to install rubies then you need add those users to rvm group and all of them will be able to change all rubies and gemsets – mpapis Jan 21 '14 at 16:14
-
I'll accept your answer because it answers the question in the way I stated it. Even though that's not what I ended up doing, it will help someone who does decide to use RVM. – Boris B. Jan 22 '14 at 11:53
Because of numerous problems with RVM in system-wide mode (rvmsudo not working, directories being created in filesystem root by RVM, etc.) I've decided to go down the vendor/bundle
route.
I installed ruby 1.9.3 w/ latest patches using my distro's package manager and then ran gem install bundler --no-user-install
which installed bundler gem system wide.
I then ran in each app's directory bundle install --path vendor/bundle --without development test
which installed required production gems in app's vendor/bundle
directory. If there were any rake tasks or plain ruby files to run as part of app's setup then those were prefixed with bundle exec ...
(which uses the gem environment from vendor/bundle when running the command).
In the end all apps were directly runnable without any prior environment setup or RVM magic, and each have separate gems.

- 4,933
- 1
- 28
- 59
-
down-voted because you did not read rvm documentation and tried to do random stuff on rvm, it should be enough to add your users to rvm group – mpapis Jan 22 '14 at 21:11