Permission denied # rb_sysopen gem install pg on Ubuntu 16.04 - ruby-on-rails

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

Related

Unable to install pg gem on MAC

I have been trying to install pg gem using, gem install pg, and its showing me an error.
Then I tried brew install postgresql, which, in the end showed error stating use/local/bin already exixts. If I am directly running bundle install in the app folder, its showing the error on installing pg 0.18.4, stating permission denied # rb_sysopen.
The errors that I am getting:
Amans-MacBook-Air:~ aman$ gem install pg
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/aman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pg-0.18.4/.gemtest
Amans-MacBook-Air:~ aman$ brew install postgresql
Warning: postgresql-9.5.3 already installed, it's just not linked
Amans-MacBook-Air:~ aman$ brew link postgresql
Linking /usr/local/Cellar/postgresql/9.5.3... Error: File exists - /usr/local/lib
What should I do, any suggestions!

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

error instatlling ruby on rails in mac

I was trying to install ruby on rails in mac.
I have Xcode and gcc compiler installed. When i tried to install git, it showed me the following error:
$:~ gem install git
$ ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Library/Ruby/Gems/1.8/gems/git-1.2.5
I changed the permissions of my 1.8 and gems directory. Still it is showing the same error. Any suggestions?
Have you tried with sudo? Try sudo gem install git.
Reference documentation: https://github.com/schacon/ruby-git#install

installing rails on ubuntu permission denied

After installing rubygems, I tried to install rails.
I entered the following command:
~$ gem install rails
and I got the following error:
Fetching: i18n-0.6.1.gem (100%)
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems
try using sudo instead.
sudo gem install rails

updating the ruby gem 1.8.5

hiii
i am trying to update my gem file. Current version of gem is 1.8.5
When i am trying to update it using command " gem install rubygems-update -v 1.8.5 " it is giving following error
**
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: Name or service not known
(http://rubygems.org/gems/rubygems-update-1.8.5.gem)
**
I am working on ubuntu 10.04
also i tried to update using command " gem update --system "
it is giving the error as below
Updating rubygems-update
**
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find a valid gem 'rubygems-update' (1.8.6) locally or in
a repository
**
i also tried the solution given on the link http://lightyearsoftware.com/2009/07/updating-rubygems-to-recent-1-3-x/
please help me to resolve the problem..
If you are under Windows 7, run the command prompt as Administrator.
Read this thread. The error reported is the same of yours.
Try to apply the Google DNS configuration to your connection.
Otherwise you can try to install locally the gem, downloading it on rubygems.org. After this, in the directory you downloaded the gem, try to install it locally with the command: gem install gem_name --local
I also had this error. I resolved it with
gem uninstall rubygems-update
(you may need to be sudo) and then reinstalled with
gem install rubygems-update
now it's working fine, hope this is helpful
Try this:
Manually uninstall the gem you want to remove: gem uninstall [gemToUinistall]
Download the gem manually from http://rubygems.org/
try to install the gem from local : gem install [gemToInstall]

Resources