rbenv rehash gives me Permission denied # rb_sysopen - ruby-on-rails

After upgrading to Rails 4.0.4 and Ruby 2.1.1, i have permission problems with rbenv rehash. I tried bundler install to 1.5.3. Ok. But still no. bashrc (Ubuntu 13.04) is fine, that is, as before. ruby -v shows the proper versions of global and local Ruby, as does rails -v. Only 'rehash' seems to be the problem.
.rbenv/plugins/bundler/etc/rbenv.d/bundler/rehash.rb:187:in `initialize': Permission denied # rb_sysopen

Try running the server as a root.
sudo -s
rails s

Change the owner of the dependency files:
sudo chown -R USERNAME /.rvm/
And then change owner of the project file:
sudo chown -R USERNAME /var/www/PROJECTFILE

Related

Unable to install rails. error: You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory

I installed ruby 2.6.3 using RVM. later when i try to install rails i am getting following error.
$ gem install rails -v 6.0.2.1
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory.
$ sudo gem install rails -v 6.0.2.1
sudo: unable to execute /usr/bin/gem: No such file or directory
That's because at some point you used sudo to install your rvm. So, the system will require sudo permission to install later gems
When you use command $ sudo gem install rails -v 6.0.2.1, you tell system to use normal directly installed ruby, not via rvm, so it warns you No such /user/bin/gem error
The solution for this is to change ownership of all files in the ~/.rvm directory to current account, as if you're using root account by following command
sudo chown -R $USER ~/.rvm

Upgrade rails version permission denied rvm folder /bin/rails

I try to install rails 3.2.20 with ruby2.2.0.
So with rvm I make
rvm install 2.2.0
After I make
gem install rails -v 3.2.20
After rvm use default ruby-2.2.2
But when I try rails -v, I have the error
-bash: /home/xxx/.rvm/gems/ruby-2.2.0/bin/rails: Permission denied
Why? I try also chmod -R 777 on .rvm but nothing change
If I try
which ruby I have
/usr/local/rvm/rubies/ruby-2.2.0/bin/ruby
If I try whch rails I have nothing
check if you are logged in as the correct user
check if the permissions of the user’s home directory are correct, e.g. /home/xxx/
remove the ruby under /usr/local/bin
reinstall rvm if all fails

Permission Error When Trying To Install Rails (OSX)

I am new to programming and am trying to get rails installed on my terminal. I have been following instructions from a friend, installing the xcode command line tools, homebrew, git, rbenv, ruby-build, ruby gems, ruby, and postgres. But whenever, I try $gem install rails, I get the following:
Russell-Silvers-MacBook-Pro:~ Russell_Silver$ gem install rails
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-4.2.0/README.md
This is especially frustrating because when I run $gem list, it says I have rails 3.2.18. Which is peculiar, because when I run $rails v$, it tells me I have Rails 4.2.0.
When I try to use rails rails my new_app
Errno::EACCES: Permission denied # rb_sysopen - /Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-4.2.0/README.md
An error occurred while installing rails (4.2.0), and Bundler cannot continue.
Make sure that `gem install rails -v '4.2.0'` succeeds before bundling.
run bundle exec spring binstub --all
/Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/shared_helpers.rb:83: warning: Insecure world writable dir /Users/Russell_Silver in PATH, mode 040707
bundler: command not found: spring
Install missing gem executables with `bundle install`
Russell-Silvers-MacBook-Pro:~ Russell_Silver$ bundle install
/Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/vendor/thor/shell/basic.rb:355: warning: Insecure world writable dir /Users/Russell_Silver in PATH, mode 040707
Could not locate Gemfile or .bundle/ directory
This is really frustrating, especially for someone new to programming such as myself, so I am seeking help from anybody who might know what is wrong.
Your rbenv installation was incorrectly installed as it had elevated privileges which caused your user account to not have write access to ~/.rbenv.
Issue the following command in order to take of ownership of the directory:
sudo chown -R Russell_Silver ~/.rbenv
Note that some users may have a different rbenv directory, e.g. /usr/local/var/rbenv. This would take the place of ~/.rbenv in the above command.

Error during Installing Rails in Ubuntu 10.04

First I installed rvm for multi-user using script
\curl -L https://get.rvm.io | sudo bash -s stable
and I added users to rvm group.
and rvm seems worked fine. so I installed ruby 1.9.3 and set 1.9.3 as default
and now I tried to install rails with command
gem install rails
It seems worked fine, but when fetching json-1.7.6.gem and an error occurs.
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby extconf.rb
creating Makefile
make
sh: make: Permission denied
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p374/gems/json-1.7.6 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p374/gems/json-1.7.6/ext/json/ext/generator/gem_make.out
So I thought it would be related with permission, so I tried
sudo gem install rails
but then this error occurs.
sudo: gem: command not found
What should I do?
use sudo as follows..
sudo gem install rails
Updated Answer:
our $PATH variable needs to include the exact path to your Ruby's bin directory. Adding a directory to the PATH does not include it's subfolders. Try adding the bin directory via:
export PATH=$PATH:/home/adam/.gem/ruby/1.8/bin
or if you installed the gem using sudo:
export PATH=$PATH:/usr/lib/ruby/gems/1.8/bin
You might want to add this to your .bashrc file, so that you don't have to set this manually every time your open up a new bash.
you can use rvmsudo to run sudo commands. But you should really be using Gemfiles to install gems using Bundler.

rvm install 1.9.2 Permission denied

Installing RVM on Ubuntu 11.04.
Followed the instructions here: http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you
When it comes time to install Ruby, I get a permission denied exception.
kevinwmerritt#ubuntu:~$ rvm install 1.8.7
bash: /home/kevinwmerritt/.rvm/scripts/manage: Permission denied
The .rvm folder appears in my home directory and the bash scripts initialize rvm successfully.
Using sudo yields the following:
sudo rvm install 1.8.7
sudo: rvm: command not found
I am new to Ubuntu.
If you did a single-user install of RVM do not use:
sudo rvm install 1.8.7
RVM creates its own sandbox in ~/.rvm which does not need root privileges ever. At NO time do you need to use sudo before rvm. sudo will only screw up everything.
Use an unadorned rvm install 1.8.7 or rvm install 1.9.2 or any other version of Ruby known to RVM. You can see the list it knows about using rvm list.
I am running into the same exact problem. I compared it against another installation of rvm on a different box that is working and noticed the permission for "manage" is different.
The box that is working:
-rwxr-xr-x 1 deployer deployer 59002 2011-05-19 22:56 manage
The box that is not working:
-rw-r--r-- 1 deployer deployer 59076 2011-05-22 22:12 manage
I did a chmod 755 manage and that seems to have fixed it. I installed rvm the same way on both boxes, not sure why there's a difference.
You can try
chmod 755 /home/kevinwmerritt/.rvm/scripts/manage and see if that resolves it

Resources