Installing rails fails - permission denied - ruby-on-rails

I am trying to set up a ruby on rails project in a Ubuntu vagrant, and I'm encountering the following problem:
Running:
gem install rails
Gives me
Fetching: rack-1.6.4.gem (100%)
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /usr/local/rvm/gems/ruby-2.3.0/cache/rack-1.6.4.gem
Ok so it's a permissions issue.
As suggested on some other similar topics I ran
sudo chmod -R 1777 tmp/
But this doesn't seem to help me, I'm just getting the same message again.
I know this question has been asked before, but the fixes don't work for me.

Related

Permission Denied installing boring_generators in ruby on rails 6

I'd like to install boring_generators gem in my ruby on rails 6 project in windows 10 os. But I couldn't install it, I got errors like below. I would be grateful if anyone gives me the idea to fix it.
gem install boring_generators
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_file_s_symlink - (../acorn/bin/acorn, C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/boring_generators-0.11.0/tmp/templates/app_template/node_modules/.bin/acorn)

Permission denied # rb_sysopen gem install pg on Ubuntu 16.04

I have installed postgresql, libpq-dev and build-essential. When I ran gem install pg, I got a
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
I tried every solution I found in stackoverflow, but none of them worked. However, now I ran gem install pg, I got a new error
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /home/woyuxuxu123/.rvm/gems/ruby-2.3.3/gems/pg-0.21.0/.gemtest
Could anyone help me on this? I have been stuck on this for a whole afternoon.
Use sudo before installing the gem or update in your system as like this:
sudo apt update
gem install pg

Permission denied , installing rails

I am trying to install rails , in order to install cocoapods but I am having some trouble with permissions.
I tried $ $sudo chown -R username /usr/ but operation is now allowed.
Username-MacBook-Pro:~ username$ $sudo gem install rails
Building native extensions. This could take a while...
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # dir_s_mkdir - /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14
Username-MacBook-Pro:~ username$
You should not install rails with the sudo command for two reasons:
I made this mistake in the past and then I had issues when installing and using other gems because of inconsistencies with permissions. It might very likely cause you the same trouble.
The concern of whether or not to install rails with the sudo command is addressed and well explained in a different post: 'sudo gem install' or 'gem install' and gem locations
The reason why installing gems with sudo is worse than just gem install is because it installs the gems for ALL USERS as root. This might be fine if you're the only person using the machine, but if you're not it can cause weirdness.
I recommend that you install rvm first and then rails. Here is a great tutorial that walks you through the process: http://railsapps.github.io/installrubyonrails-mac.html

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.

Linux] Setting Permission for Admin Group

I'm trying to set up my VPS to deploy my Rails app, and I constantly face these permission denied errors. I think the main problem is that I'm running as "deployer," who's in an admin group, and somehow "deployer" is not getting its rights properly. But this guess could be wrong.
deployer#max:~$ gem install bundler --no-ri --no-rdoc
Fetching: bundler-1.2.3.gem (100%)
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems
You need to prefix the gem command with sudo because /var/lib/gems is owned by root. You could also take a look at RVM which allows really easy installation and management of gems and Ruby versions.
Just used "sudo" command to solve this issue...

Resources