Any commands that use sudo
don't seem to work with RBenv.
I'm trying to install ActiveRecord and it says I don't have write permission, so when I try this:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1 directory.
It says:
sudo: gem: command not found
How can I get around this?
While the versatility of RVM can be resourceful, when it comes to Ruby version management, it can be overkill. Using rbenv allows you to keep things simple and let other tools handle other aspects of the process. rbenv's primary focus on Ruby versioning leads to a more dev-friendly setup and configuration.
In rbenv you need to add this to your profile to load the rbenv command-line function. Once you've restarted your shell you now have access to RVM/rbenv. It is important to note that RVM and rbenv cannot be installed at the same time because of the way RVM handles the 'gem' command.
rbenv provides support for specifying application-specific versions of Ruby, lets you change the global Ruby for each user, and allows you to use an environment variable to override the Ruby version. In this tutorial, you will use rbenv to install and set up Ruby on Rails on your local macOS machine.
The idea behind tools like rbenv and RVM is that you don't need to use sudo
, because your entire Ruby environment exists inside your own workspace as a sandbox.
RVM allows multi-user configurations though it was originally designed for single users.
As far as I've ever seen or read, rbenv is single-user only. At no time should you need to use sudo
to manipulate or change your Ruby environment when using rbenv. If you do, something is wrong. If you try to use sudo
, you'll screw things up. You might not find out immediately but eventually something will pop up and you'll need to change the ownership of the files back to you.
On Linux and Mac OS you can do that pretty easily using:
sudo chown -R <your_user_name>:<your_group> ~/.rbenv
You have to run that as sudo
because only the super-user can change ownership of files owned by root. sudo
escalates your privileges to allow you to change those things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With