Mac Ports Uninstall nightmare with gem 'pg" - ruby-on-rails

I have tried everything from source installations, homebrew, and manually restoring the pg_config file as sudo user. I am out of ideas on this... here is what I get:
gem install pg -v '0.12.1'
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/pg-0.12.1/.gemtest
any help would be appreciated :).

Probably you ran sudo gem install pg to install pg, so the installed gem still has root permission. Run sudo chown -R Toran1 /Users/Toran1/.rvm to fix up the permission first. Then you should be able to run gem install pg

Manual gem installations like this can be installed with sudo.
sudo gem install pg -v '0.12.1'
Hope this helps!
EDIT:
As per the comments below, I noticed you are using rvm. Don't use sudo when using rvm. Check the paths and make sure that you do indeed have the correct permissions set!

use this:
RVMSUDO gem install pg

Related

Rails - Gem Error while installing pg (1.1.3), and Bundler cannot continue

I am still fairly new to Rails. I am trying to push to Heroku and I am getting errors.
The first error is when I run a Bundle Install I get this error message:
"An error occurred while installing pg (1.1.3), and Bundler cannot continue.
Make sure that gem install pg -v '1.1.3' succeeds before bundling."
I have tried to run this command
gem install pg -v '1.1.3'
But it fails and gives me this error message:
"ERROR: Error installing pg:
ERROR: Failed to build gem native extension."
Does anyone have a solution to this?
I had the exact same problem, and solved it by running sudo apt install postgresql-contrib libpq-dev. Then bundle worked just fine.
if you're using OSX, you could try running
brew install postgresql
and then installing the gem
TL;DR; If you installed the Postgres using the PostgresAPP instead of BREW then the problem might be that you don't have the postgres bin folder in the $APTH
The solution is to find the Posgres app installation folder an in it the /bin folder.
In my case if I run which postgres doesn't work which means I don't have it in my $PATH, so what I did is I navigated to: cd /Applications/Posgres.app then to Contents and then to Versions until I found the latest folder:
/Applications/Postgres.app/Contents/Versions/latest/bin
Now, with this I can install the PG GEM by providing the path to the bin folder of my Postgres app installation
Finally, in the terminal in the root of my Rails project I ran where I provide the postgres config file path to the GEM installer:
gem install pg -v '1.2.3' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
I encountered the same problem. I am using Ubuntu. I installed Postgres using this Ubuntu guide. After installing Postgres, I ran this code sudo apt install postgresql-contrib libpq-dev then bundle install.
The accepted answer is not correct. If you installed postgresql-contrib and libpq-dev as mentioned in Cesar Faria answer, and you still getting the same error, most probable you missed the list of packages which are considered essential for building Debian packages. All that packages included in build-essential package. So, all you need to do to get rid of the error is the command below.
sudo apt install libpq-dev build-essential
try instaling with pg-config like this:
gem install pg -v 1.1.3 -- --with-pg-config=/usr/pgsql-9.X/bin/pg_config.
In pg-config path mention the posgtres version installed in you're system.
Postgresql needs to be in local in order to install gem pg. Try this
brew install postgresql
and the re-install bundle
bundle install
or
If you are using yum. Try this
sudo yum install postgresql-devel
The following is only for your local environment:
Note: Update the command below to match your version postgresql/13.2/...
> brew install postgres
> sudo gem install pg -v '1.1.4' --source 'https://rubygems.org/' -- --with-pg-config=/usr/local/Cellar/postgresql/13.2/bin/pg_config
Also, make sure to start your server > pg_ctl -D /usr/local/var/postgres start

Error with Bundle Install (Linux)

Upon trying to start a new Rails App on Linux, I am receiving this error:
I am a newbie to this software. Please help!
Thanks :)
My Error
UPDATE: I ran 'sudo gem install bundler', and it worked but now received this error!
'/usr/bin/ruby2.3: No such file or directory -- /usr/bin/bundle (LoadError)'
My new error
It seems like you dont have bundler gem installed.
Try:
gem install bundler
Bundler is missing.
Try the below commands.
[sudo] gem install bundler
bundle install
Try stop using sudo in your commands. According to your new capture, you are using sudo with gem install bundler, and maybe that is conflicting with your configuration.
Take this link for reference for sudo usage with gem
https://stackoverflow.com/a/2119413/4870465

I git cloned a repo and I cannot run it on localhost because missing gem and cannot bundle install

I git cloned a repo. I cannot run it on localhost with rails server because terminal says
Could not find activesupport-4.2.5 in any of the sources Run bundle
install to install missing gems.
When I run bundle install, I get
An error occurred while installing pg (0.18.4), and Bundler cannot
continue. Make sure that gem install pg -v '0.18.4' succeeds before
bundling.
I have rails 4.2.3, and the repo's Gemfile has gem 'rails', '4.2.5'. I don't know if this matter
Gem pg is Postgres driver, it only can be installed, if corresponding headers and libraries are present and can be accessed.
Most probably just installing postgres will fix it. If you're on a Mac with homebrew - brew install postgresql
Install postgresql.
Remove Gemfile.lock
Add gem 'pg' in your gemfile
execute bundle install
1: Remove Gemfile.lock if Gemgile.lock present in your project
2: add gem 'pg' # in Gemfile
3: Run bundle install
Hope this help you !!!
Run
sudo env ARCHFLAGS="-arch x86_64" gem install pg -v '1.18.4'
Now try running bundle install again.
I used a combination of #Chakreshwar Sharma and #Vinay's answers to get this working for the metasploit-framework.
Remove Gemfile.lock
Add gem 'pg' in your gemfile
Run apt-cache search postgresql-server-dev
apt-get update && apt-get install postgresql-server-dev-9.5 # Check your version
bundle install --no-deployment
To be honest, I think you could just run:
apt-cache search postgresql-server-dev
apt-cache search postgresql-server-dev-9.5
bundle install
...and you can avoid messing with the Gemfile, but I didn't get to verify it since mine started working after I made the adjustments.

Installing Heroku gem to my root directory

How do I install the Heroku gem to my root directory? I tried sudo gem install heroku, but this doesn't seem to work. Any other suggestions? I am working with OSX.
I would not recommend installing gems in locations other than where RVM or gem wants to install the files, but you can override the install location like this:
sudo gem install heroku --install-dir /path/to/install/into
Where /path/to/install/into is where you want to install the gem.

Installing Rails ERROR: could not find rails locally or in a repository

I've been poking around the internet looking for a solution on this one... with no luck..
I'm new to rails... If anyone has an idea, I'd love to hear it. Much appreciated!
I enter:
LW:src liamwright$ sudo gem install rails --include-dependencies
And Get:
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: could not find rails locally or in a repository
I am running:
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
Mac OS X 10.5.8
I also tried:
gem sources -r gems.rubyonrails.org
And Get:
source gems.rubyonrails.org not present in cache
Just to check...
...try doing a sudo gem update --system before installing Rails to make sure you have the latest RubyGems installed?
EDIT: Actually, if your RubyGems install is really old, you might need to follow the alternate directions on Gemcutter.
Might want to make sure you have the newest rubygems:
sudo gem install rubygems-update
sudo gem update --system
Then:
sudo gem install rails
I came across this solution on Albertux' blox. Running this script will fix it (It worked perfectly for me on an Ubuntu 9.10 machine):
#!/bin/bash
#(download the latest on http://rubyforge.org/frs/?group_id=126)
wget http://rubyforge.org/frs/download.php/43984/rubygems-update-1.3.0.gem
sudo gem install rubygems-update-1.3.0.gem
sudo update_rubygems
# now this work:
sudo gem update --system
echo "done."
I've just had the same problem trying to upgrade rubygems from 1.2.0 to 1.3.7.
Setp-1)
So I just downloaded rubygems-update-1.3.7.gem from http://rubyforge.org/frs/?group_id=126
Setp-2)
gem install rubygems-update-1.3.7.gem
Setp-3)
update_rubygems
and it work for me.

Resources