An error occurred while installing pg (1.4.1), and Bundler cannot continue - Ruby on rails - ruby-on-rails

When I run 'bundle install' I get this error: "An error occurred while installing pg (1.4.1), and Bundler cannot
continue."
I then run "gem install pg" and get this: "ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/name/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/pg-1.4.5/.appveyor.yml"
I thought it was a permission is so I ran : "sudo gem install pg" then I got this:
"ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pg_ext.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/name/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/pg-1.4.5 for inspection.
Results logged to /Users/name/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-22/2.7.0/pg-1.4.5/gem_make.out"
gcc is installed and up to date.
Postgres 14.7
I followed most of the solutions on here and got nowhere. Does anyone know how to fix this?
I am on a M1 with MacOS Ventura

Related

Rails 5: trying to bundle install end getting error with pg gem

I'm using rails 5 and Rubymineand when I try to bundler install I get the following error:
compiling pg_type_map_all_strings.c
compiling pg_type_map_by_class.c
compiling pg_type_map_by_column.c
compiling pg_type_map_by_mri_type.c
compiling pg_type_map_by_oid.c
compiling pg_type_map_in_ruby.c
compiling util.c
linking shared-object pg_ext.bundle
ld: file not found: dynamic_lookup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pg_ext.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in
/Users/theopap/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pg-1.0.0 for
inspection.
Results logged to
/Users/theopap/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_6
4-darwin-16/2.4.0-static/pg-1.0.0/gem_make.out
An error occurred while installing pg (1.0.0), and Bundler cannot continue.
Make sure that `gem install pg -v '1.0.0'` succeeds before bundling.
In Gemfile:
pg
I tried uninstalling the pg gem and installing a fresh one according to this answer from #Neeraj Gupta , but still this error appears after bundler install.
Any ideas why this is happening?
You are probably missing the Postgres Development headers/libraries (libpq-dev).
How did you install Postgres?
If you are on MacOS, you can install Postgres via Homebrew and it will include the necessary development headers for you:
brew install postgresql

Error installing rails 4 in mac

I am trying to set up rails in my mac(Yosemite) machine. But when I do
gem install rails
I get the following error. Please help.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/Paa/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
creating Makefile
make clean
make
compiling generator.c
make: /usr/local/opt/gcc46/bin/gcc-4.6: No such file or directory
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/Paa/.rvm/gems/ruby-1.9.3-p547/gems/json-1.8.2 for inspection.
Results logged to /Users/Paa/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/json-1.8.2/gem_make.out
What am I missing here.??
I think rvm might be trying to use gcc 4.6, which doesn't work properly with rvm. I believe you can:
Uninstall gcc 4.6 (brew rm gcc46)
Pull the latest rvm (rvm get stable)
Retry gem install rails

Error installing gem

I typed 'gem install middleman' in my terminal and got the following error message:
Building native extensions. This could take a while...
ERROR: Error installing middleman:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
creating Makefile
make
compiling hitimes.c
make: gcc-4.2: No such file or directory
make: *** [hitimes.o] Error 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p429/gems/hitimes-1.2.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p429/gems/hitimes-1.2.2/ext/hitimes/c/gem_make.out
Looks like you're missing gcc-4.2
Do you have any GCC installed (if you're on a Mac, you need to install Xcode)?
which gcc
If you already have a version of gcc, you can simply symlink to it
ln -s /usr/bin/gcc /usr/bin/gcc-4.2

Could not bundle install because of 'pg'

I'm learning R o R. Then, I want to make a website by using postgresql.
But, this error makes me crazy.
Please, help me !
$ sudo bundle install
creating Makefile
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
compiling pg_connection.c
pg_connection.c:2323:3: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]
gettimeofday(&currtime, NULL);
^
1 warning generated.
compiling pg_errors.c
compiling pg_result.c
linking shared-object pg_ext.bundle
ld: file not found: dynamic_lookup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pg_ext.bundle] Error 1
Gem files will remain installed in /Users/Sean/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/pg-0.17.1 for inspection.
Results logged to /Users/Sean/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/pg-0.17.1/ext/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
I tried all ways I could.
For example, I tried to change pass of pg.
But, I couldn't.
Then, I tried
$ brew update
$ brew uninstall postgresql
$ brew install postgresql
$ gem install pg
$ bundle install
But, it didn't work.
How can I do for this error !?
You might require libpq-dev, which is the library that always gets me when trying to install the pg gem on a new machine.
I struck the same problem when running the pg gem 0.17 with Ruby 2.2.1
I just did a bundle update pg and it upgraded to 0.18 and it no longer had this compile issue

Errors installing Capybara-webkit

I am trying to install the capybara-webkit gem and get the following error in OSX 10.9.4:
➜ hours git:(development) gem install capybara-webkit -v '1.2.0'
Building native extensions. This could take a while...
ERROR: Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
/Users/macbook/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
Command 'qmake -spec macx-g++ ' not available
Makefile not found
Gem files will remain installed in /Users/macbook/.rvm/gems/ruby-2.1.2/gems/capybara-webkit-1.2.0 for inspection.
Results logged to /Users/macbook/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/capybara-webkit-1.2.0/gem_make.out
So, researching that problem it seems like the solution is to run "brew install qt". When I run that I get the following:
➜ hours git:(development) brew install qt
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Downloading http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-open
curl: (22) The requested URL returned error: 404 Not Found
Error: Download failed: http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.tar.gz
I have checked and cannot find MacPorts or Fink anywhere on my Imac.
What am I missing here?
Homebrew has carried qt 4.8.6 since April. Please brew update && brew upgrade and try brew install qt again.

Resources