Using rbenv doesn't work with sudo?
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.
rbenv and passenger - cannot install from not root user account(sudo group)
As I wrote in my comment, you have to run the passenger-install-nginx-module
as root with the full path, because it is not in the $PATH
var of your bash. To find out the path, run which passenger-install-nginx-module
rbenv not changing ruby version
Check that PATH contains $HOME/.rbenv/shims
and $HOME/.rbenv/bin
$ env | grep PATH
Also check that you have the following in your ~/.bash_profile if using bash or ~/.zshenv if using zsh
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
NOTE:
Make sure it's the last setting in your ~/.bash_profile . I ran into an issue where I installed a program that updated my .bash_profile and reset PATH.
Finally, make sure your $HOME
folder doesn't have a .ruby-version
file that you may have created by accident if you were to have done $ rbenv local <ruby-version>
in your $HOME
folder. Doing $ rbenv global <ruby-version>
modifies the $HOME/.rbenv/version
file, and the existence of a .ruby-version
file in the $HOME
folder would override the version set by $HOME/.rbenv/version
.
From the docs:
Choosing the Ruby Version
When you execute a shim, rbenv determines which Ruby version to use by reading it from the following sources, in this order:
The RBENV_VERSION environment variable, if specified. You can use the rbenv shell command to set this environment variable in your current shell session.
The first .ruby-version file found by searching the directory of the script you are executing and each of its parent directories until reaching the root of your filesystem.
The first .ruby-version file found by searching the current working directory and each of its parent directories until reaching the root of your filesystem. You can modify the .ruby-version file in the current working directory with the rbenv local command.
The global ~/.rbenv/version file. You can modify this file using the rbenv global command. If the global version file is not present, rbenv assumes you want to use the "system" Ruby—i.e. whatever version would be run if rbenv weren't in your path.
Bundle not working with rbenv
Your installation is caught in a loop.
Change to a directory that is not your app, and that doesn't have a Gemfile.
Then do the usual gem install bundle
(and use sudo
if you need it)
Then change to your app directory, and do the usual bundle install
.
Does that solve your issue?
If you need more help, can run these commands then paste the results in your question?
$ command -v ruby
$ command -v bundle
$ ruby -v
$ bundle -v
Look for any mismatch between the results and what you expect. This will help you track down what's happening. You may need to update your Gemfile Ruby version.
(Also, you may want to consider changing from rbenv
to chruby
because it's better IMHO with these kinds of path issues)
rbenv Permission denied with Assetic on Ubuntu
I do not have experience with the said components but assuming that the user who is executing the file is www-data it might be an issue with the permissions of the /root/.rbend/shims/ruby file.
Run the command sudo chmod o+x /root/.rbenv/shims/ruby
wich will give execute permissions to the owner of the file, presumably www-data since you ran the chown command.
If it still doesn't work run the command ls -l /root/.rbenv/shims/ruby
, the 4th character of the first column should be x
, indicating the owner has execution permissions.
For more info on linux file permissions check "Understanding and Using File Permissions".
Ruby version differs from the rbenv one in server
when you run ruby -v, it's considering your ruby installed by apt install ruby
.
You must remove ruby-build
with apt remove ruby-build
and clone the ruby-build
to inside rbenv
directory and then install and set as global with rbenv.
I want to recommend you to read and follow this tutorial after remove local ruby-build.
Related Topics
Notices for Sequence After Running Migration in Rails on Postgresql Application
How to Write Rake Task to Import Data to Rails App
What Is the Best Practice When It Comes to Testing "Infinite Loops"
How to Test 'Rand()' with Rspec
Convert (Decode) Hexadecimal String to Binary String
Why Is Rails Outputting My Array
Changing Every Value in a Hash in Ruby
Ruby Cannot Load Such File - Active_Support/Core_Ext/Object/Blank
Combine Array of Array into All Possible Combinations, Forward Only, in Ruby
How to Format This International Phone Number in Rails
Nested Forms in Rails - Accessing Attribute in Has_Many Relation
How to Change Column Type in Heroku
Using $ Sudo Bundle Exec ... Raises 'Bundle: Command Not Found' Error