Is a system-wide install of RVM a bad idea?
You could install RVM as a regular user, although I don't see the point. Bundler is per-application and doesn't need sudo privileges since it can install your gems into a bundle directory that the bundle install user can access with, for instance:
bundle install --deployment
which will put them in vendor/bundle
by default.
I think of RVM as a development tool for managing multiple ruby versions. On deployment machines I tend to either use system Ruby or install from source.
With a system wide install of RVM, which user do you run bundle install as?
bundler's doc explicitly says don't do it as root:
http://gembundler.com/man/bundle-install.1.html
Quoted:
You should never use
sudo bundle
. This is because several other
install
steps in bundle install must be
performed as the current user:1) Updating your Gemfile.lock
2) Updating
your vendor/cache, if necessary
3) Checking out private git repositories
using your user's SSH keys
Especially true with RVM:
http://rvm.beginrescueend.com/rubies/rubygems/
Quoted:
DO NOT use sudo...
to work with RVM gems. When you do
sudo you are running commands as root,
another user in another shell and
hence all of the setup that RVM has
done for you is ignored while the
command runs under sudo (such things
as GEM_HOME, etc...). So to reiterate,
as soon as you 'sudo' you are running
as the root system user which will
clear out your environment as well as
any files it creates are not able to
be modified by your user and will
result in strange things happening.
(You will start to think that someone
has a voodoo doll of your
application...)
With a system wide install of RVM, which user do you run bundle install as?
bundler's doc explicitly says don't do it as root:
http://gembundler.com/man/bundle-install.1.html
Quoted:
You should never use
sudo bundle
. This is because several other
install
steps in bundle install must be
performed as the current user:1) Updating your Gemfile.lock
2) Updating
your vendor/cache, if necessary
3) Checking out private git repositories
using your user's SSH keys
Especially true with RVM:
http://rvm.beginrescueend.com/rubies/rubygems/
Quoted:
DO NOT use sudo...
to work with RVM gems. When you do
sudo you are running commands as root,
another user in another shell and
hence all of the setup that RVM has
done for you is ignored while the
command runs under sudo (such things
as GEM_HOME, etc...). So to reiterate,
as soon as you 'sudo' you are running
as the root system user which will
clear out your environment as well as
any files it creates are not able to
be modified by your user and will
result in strange things happening.
(You will start to think that someone
has a voodoo doll of your
application...)
Why RVM System Wide?
I always do a kind of hybrid for deployments:
- I install RVM system wide (but its avaiable only for users in rvm group)
- I create a dedicated user which is part of various groups: rvm, db (mysql, postgres, or whatever you use), nginx, etc...
this way you can:
- do all the web-related administration tasks without using sudo or root
- use capistrano without worries about privileges or ruby commands to run
- keep control on privileges and use ruby from whatever place
- use bundler flawlessly
if you install RVM under a specific user, then you can't use ruby outside that user.
rails `bundle install` trying to install system wide
Update the global rubygems with :
sudo gem update --system --no-user-install.
Or try this:
bundle install --path ~/.gem
Other option is just uninstall bundler and install it again.
Which would work for a multi-user Ruby setup? RVM or RBenv?
Umm, RVM is definitely built for multiple users AS WELL AS per user installations. Please see the installation page for more information.
Also, please see the integration section and Passenger page in that section for using multiple gemsets with Passenger, however, Passenger is limited to a single Ruby.
For the ability to use any Ruby and any gemset within that Ruby's space, you want to set up Unicorn for that. You can easily use Apache and Unicorn or NGinx and Unicorn to accomplish all you want.
RVM installed by Ruby not working?
RVM requires a minor addition to your ~/.bashrc
or ~/.bash_profile
to initialize it when you log-in. It is specified in the installation docs in the Post Install section. Did you do that?
Per your rvm info
output, it looks like you haven't completed your installation. All the entries in the output should have corresponding values. So, I suspect you haven't added:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
to your ~/.bashrc
or ~/.bash_profile
and then started a new session.
If you are doing a "Multi-User" installation then you'll need to do a lot more. Have you modified /etc/profile
, or, if you are using Bash as your shell, have you modified /etc/bash.bashrc
to include:
# Load RVM if it is installed,
# first try to load user install
# then try to load root install, if user install is not there.
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
. "$HOME/.rvm/scripts/rvm"
elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then
. "/usr/local/rvm/scripts/rvm"
fi
and started a new shell?
Personally I don't like the multi-user install as much as the single-user install, and don't recommend it but your mileage might vary.
As a FYI: In a discussion with the RVM maintainers on IRC last year, they told me they do not recommend the system-wide installation, and instead recommend the local "single-user" installation, even for servers.
Related Topics
Mongo - Ruby Connection Problem
Ruby Greed Koan - How to Improve My If/Then Soup
Preferred Way to Private Messages Modeling in Rails 3
Is It Idiomatic Ruby to Add an Assert( ) Method to Ruby's Kernel Class
How to Convert an Array of Strings into a Comma-Separated String
What Is the Meaning of "H" in "<%=H [ ...] %>"
Check If a Hash's Keys Include All of a Set of Keys
Guidelines for Where to Put Classes in Rails Apps That Don't Fit Anywhere
How to Call a Super Class Method
Combinatory Method Like Tap, But Able to Return a Different Value
Difference Between Map and Each
Rails: Modifying a Model Generated by Scaffolding
Is 'Yield Self' the Same as Instance_Eval
Rails: Convert Utc Datetime to Another Time Zone
Stop Rails Console from Printing Out the Object at the End of a Loop
How to Define a 'Before_Save' Callback in a Module
Rails 3/Ruby: Activerecord Find Method in Condition Array to Parameters Single Quote Issue