Unable to install pg gem on MAC - ruby-on-rails

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!

Related

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

bundler error and having issues to reinstall after delete RVM

I deleted RVM, because I already had RBENV install. Now I cannot get bundler to work. This caused major issues. When I installed bundler again to run bundle i on my code, it gives me an error and it's looking for RVM.
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # dir_s_mkdir - /usr/local/rvm

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

ERROR: While executing gem ... (Errno::EISDIR) gem install rails

I'm trying to install Ruby on rails, so first I installed RVM rvm install 1.9.2. After that install this gem install rails. It shows this error
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.8 directory.
Then I used this sudo chmod 0777 /var/lib/gems/1.8/
After that when I install, its showing this error:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems/1.8/cache/railties-3.2.2.gem
Then I run sudo chmod 0777 /var/lib/gems/1.8/cache/railties-3.2.2.gem
After that I install gem install rails. Again its showing this error
ERROR: While executing gem ... (Errno::EISDIR)
Is a directory - /var/lib/gems/1.8/cache/railties-3.2.2.gem
You're still using the system ruby install (1.8). To use the Ruby you've just installed with rvm, do rvm use 1.9.2. Then try gem install rails again. The Rails gem should be installed under your home directory, you shouldn't need root permissions.
To make the rvm Ruby the default, so you always start with it when you open a new terminal, do rvm --default use 1.9.2 (note that's two dashes).
manually install gem-ctags, then retry installing your failing gem
gem install gem-ctags
gem install backports -v '3.3.3'
bundle install

heroku db:pull cant connect to my DB in ubuntu

So I recently updated ubuntu to 11.04 and then downgraded back to 11.04 because I hated unity. Anyway, after I reinstalled 11.40 I had to clone all my old heroku apps and tried to run heroku db:pull to pull the DB and have it imported into my mysql db but I keep getting this error:
Failed to connect to database:
Sequel::AdapterNotFound -> LoadError: no such file to load -- mysql2
my gem file has gem 'mysql2', '< 0.3' and I gem installed taps already via RVM. I never had this issue when I ran db:pull before so I dont know what the problem is.
Im running ruby 1.9.2 with rails 3.0
run :
gem install mysql2 than heroku db:pull again ...
if you get this error with the previous "gem install mysql2" :
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
probably libmysqlclient-dev package should be installed :
sudo apt-get install mysql-server mysql-server-5.1 libmysqlclient-dev mysql-client-5.1 mysql-common
than
gem install mysql2
... or eventually run
locate mysql_config
then replace the resulting path, with in the following command path :
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
You may have mysql2 in your Gemfile but have you done a bundle install - i.e. do you have the mysql2 gem installed ?
run :
gem install taps then heroku db:pull again
It may be work?

Resources