How to install ruby system-wide using rbenv
rbenv is simply not designed to do support this, you can see the discussion surrounding this within this Github Issue. There are many technical considerations to take into account like permissions if you do this. I found another blog post outlining the process - System Wide Install With rbenv. Going to copy it into this answer incase the blog post goes away.
However, in the long run, you may find that it's simply easier to create or use Ruby packages, such as the BrightBox PPA ones.
Installing rbenv
Instead of the usual location of
~/.rbenv
for single installs we'll
be installing to/usr/local
. You can use a different path if you
want, but this is what I prefer.cd /usr/local
git clone git://github.com/sstephenson/rbenv.git rbenv
chgrp -R staff rbenv
chmod -R g+rwxXs rbenv
Make sure the users that will use rbenv are part of the group you
associated with the rbenv folder.Now we want to add the following code into each users
~/.profile
,
~/.bash_profile
, or~/.zshenv
depending on the environment. You
can also add it in/etc/skel/.profile
or/etc/skel/.bash_profile
template files that are copied when new users are created.export RBENV_ROOT=/usr/local/rbenv
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
Installing ruby-build (optional)
Optionally, you can install the ruby-build plugin to save yourself
from building it yourself.cd /usr/local/rbenv
mkdir plugins
cd plugins
git clone git://github.com/sstephenson/ruby-build.git
chgrp -R staff ruby-build
chmod -R g+rwxs ruby-build
Notes
Now you should have rbenv and optionally ruby-build setup so you can
get started installing and using Ruby. This install is the same as the
single user install with two exceptions. The global setting applies to
all users and single user rbenv installs can "override" the system
wide install.If you have permission issues make sure all the files in the rbenv
folder belong to the proper group and that the users trying to use
rbenv are also members of the group.
Should rbenv be installed system-wide, or at a user level?
About two years ago, a discussion happened in github about shared installs, which appears to answer the question.
Synopsis: sstephenson (rbenv author) specifically doesn't like encouraging system-wide installs because of complexities with permissions, write access, etc. He believes adding robust support would make rbenv more complex, and simplicity is the goal.
EDIT
I've since come across fnichol's chef-rbenv cookbook, which, if you actually want to install a system-wide rbenv, gives a right and proper method, and you can automate it with Chef (I recommend knife solo).
It installs this to /etc/profile.d/
so it will run for all users, putting the proper ruby into the PATH
.
How to install gems with system wide rbenv by using chef
You need to use the rbenv_gem
resource.
Install ruby for all users on ubuntu
I'm assuming you are installing Ruby using Rbenv method from the GoRails guide. Take a look at This Q/A.
I also wanted to use system-wide ruby for different user and used the above method(despite the warning that Rbenv is not suitable for system-wide configs), and it worked in some way, but I had problems using it for other projects with different users.
So the workaround I use is to install Rbenv each for a different user. It takes some disk space, but things will work smoothly. Also, DO NOT install it as a root
user or in the /root
folder as this will break things when you work with rails with different users.
install a private gem systemwide by using chef-rbenv
Ruby's gem
can't install gems from a git location. This is a feature of bundler. The chef cookbook you're using, implements a wrapper of rubygems' gem
command, not bundler.
You need to clone the private repo to a directory and build/install the gem yourslef OR pre-build a .gem
file (see github's release hosting feature for a nice file hosting functionality that sticks to your private github access management).
Or just call bundler on the Gemfile you're mentioning.
rbenv command line gems setup with system install
I'm new to rbenv from rvm where it just seemed to work. It looks like in rbenv you have to run :
bundle exec gemxx
Or generate binstubs:
https://github.com/sstephenson/rbenv/wiki/Understanding-binstubs
Related Topics
How to Use String Methods on Utf-8 Characters
Mechanize and Ntlm Authentication
How to Push a Custom Gem to Heroku Master
No Such File or Directory @ Rb_Sysopen for External Url/Rails 6.11/Ruby 3
How to Get the Nth Element of an Enumerable in Ruby
Ruby on Rails Workflow Engine (Like Ibm Workflow)
How to Get the Real File from S3 Using Carrierwave
Obfuscating Rails App on Mri Ruby/Jruby for a Enterprise Customer
Ruby Console Input Halting at 1024 Characters
Rails Search Query Associated Model
How to Convert Character Code to What I Want
Iterate JSON with Ruby and Get a Key,Value in an Array
Why Does Ruby Use Its Own Syntax for Safe Navigation Operator
Assign to an Array and Replace Emerged Nil Values
What Does "String Literal in Condition" Mean