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
Related
I am new to Ruby on Rails and I'm trying to create a website using the same. I have added a few gems to my gem file and trying to bundle them, but encounter this error.
An error occurred while installing eventmachine (1.2.7), and Bundler cannot continue.
Make sure that gem install eventmachine -v '1.2.7' --source 'https://rubygems.org/' succeeds before bundling.
I have tried doing gem install eventmachine -v '1.2.7' but get this error:
ERROR: Failed to build gem native extension.
current directory: /.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7/ext
make "DESTDIR=" clean
current directory: /.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7/ext
make "DESTDIR=" compiling binder.cpp In file included from
binder.cpp:20: ./project.h:119:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
^~~~~~~~~~~~~~~ 1 error generated. make: *** [binder.o] Error 1
Can someone please help?
#include <openssl/ssl.h>
You seem to be missing the c++ development source necessary for ruby to install openssl.
Install libssl-dev and try the gem installation again. You may be missing other development libraries as well.
I am using Windows, and I just installed Ruby on Rails, ruby is version 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32], rails is version 6.0.0.
When running rails new blog (following this tutorial) bundle install runs.
I have tried reinstalling Ruby, changing its version, and even removing bootsnap and running something else, but even when trying to install the puma gem I get the same error.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r
./siteconf20191028-6188-1rw29js.rb extconf.rb
creating Makefile
current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR=" clean
current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR="
generating bootsnap-x64-mingw32.def
compiling bootsnap.c
linking shared-object bootsnap/bootsnap.so
C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
bootsnap.o:bootsnap.c:(.text+0x557): undefined reference to `__strcat_chk'
C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
bootsnap.o:bootsnap.c:(.text+0xa07): undefined reference to `__chk_fail'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:261: bootsnap.so] Error 1
make failed, exit code 2
Gem files will remain installed in
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5 for inspection.
Results logged to
C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/bootsnap-1.4.5/gem_make.out
An error occurred while installing bootsnap (1.4.5), and Bundler cannot
continue.
Make sure that `gem install bootsnap -v '1.4.5' --source
'https://rubygems.org/'` succeeds before bundling.
Actually, Bootsnap won't work on Windows anyway, so I'd recommend just removing it from Gemfile. If you want to leave it for production environment, perhaps you should include it conditionally with something like:
gem 'bootsnap' unless (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
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
Mac OS El Capitan
Bundle install fails with:
compiling pg_connection.c
pg_connection.c:2394:3: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]
gettimeofday(&currtime, NULL);
^
1 warning generated.
compiling pg_copy_coder.c
compiling pg_errors.c
compiling pg_result.c
compiling pg_text_decoder.c
compiling pg_text_encoder.c
compiling pg_type_map.c
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/jmintz/Documents/LaunchAngels/radar/vendor/bundle/gems/pg-0.18.4 for inspection.
Results logged to /Users/jmintz/Documents/LaunchAngels/radar/vendor/bundle/extensions/x86_64-darwin-15/2.2.0-static/pg-0.18.4/gem_make.out
...
...
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.
Running 'gem install pg -v '0.18.4' results in:
Building native extensions. This could take a while...
Successfully installed pg-0.18.4
Parsing documentation for pg-0.18.4
Done installing documentation for pg after 4 seconds
1 gem installed
Yet running 'bundle install' again fails. Any suggestions? I've tried uninstalling and reinstalling postgresql with homebrew with no luck
I have got a similar error now on macOS Catalina, but I was not able to successfully run
gem install pg -v '0.18.4'
I found this issue in the puma gem (I know this is another gem) that helped me solve the issue: https://github.com/puma/puma/issues/2304.
There, I found this:
Clang now enables -Werror=implicit-function-declaration by default:
Clang now reports an error when you use a function without an explicit
declaration when building C or Objective-C code for macOS
(-Werror=implicit-function-declaration flag is on). This additional
error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit
targets for this diagnostic. (49917738)
And this:
gem install puma:4.3.5 -- --with-cflags="-Wno-error=implicit-function-declaration"
So, I was able to build pg with:
gem install pg -v '0.18.1' -- --with-cflags="-Wno-error=implicit-function-declaration"
The same issue has been faced with all the gems that rely on native extensions such as pg, puma, ffi, etc
I have solved them by passing -- --with-cflags="-Wno-error=implicit-function-declaration"
ex:
gem install pg -v '0.18.4' -- --with-cflags="-Wno-error=implicit-function-declaration"
gem install ffi -v '1.12.2' -- --with-cflags="-Wno-error=implicit-function-declaration"
gem install puma -v '4.3.1' -- --with-cflags="-Wno-error=implicit-function-declaration"
I had to combine Benito's answer and jasonm's answer like below before running bundle (credit to Unixmonkey):
bundle config build.pg '-- --with-cflags="-Wno-error=implicit-function-declaration"'
This isn't an an answer, as such, but it may point you in the right direction... If indeed gem pg has successfully compiled, as you have indicated... Then it maybe that your Ruby project isn't referring to the correct gemset, somehow. As it appears it is attempting to install it again when you bundle install, this should not happen if pg has been compiled and installed in your current gemset. Are you using RVM on your system? Can you also provide more output?
Answer was installing Postgress.app and running
bundle config build.pg --with-pg-config=[Path to pg_config] before bundling
this worked for me on sierra:
gem install pg -v '0.18.3' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
I'm trying to run "bundle install", the only database gem I have in my Gemfile is pg, so I'm getting the following errors.
bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
...
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
checking for libpq-fe.h... yes
...
creating extconf.h
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
compiling pg_connection.c
compiling pg_errors.c
compiling pg_result.c
linking shared-object pg_ext.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [pg_ext.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/marklalich/.bundler/tmp/14076/gems/pg-0.17.1 for inspection.
Results logged to /Users/marklalich/.bundler/tmp/14076/extensions/universal-darwin-13/2.0.0/pg-0.17.1/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 can't find anything online, please someone help!
Thanks!!
I had the same problem and the fix for me was setting the bundle config settings first:
bundle config build.pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Don't get hung up on the pg gem. Doing the bundle install after doing this bundle config fixed the "make failed" problem for me.
For reference, This was the answer that helped https://stackoverflow.com/a/9235107/3546680 but it was user944938's answer that gave me the correct path to put in. Thanks and hope it helps someone else too!
How did you install postgres. You can install postgres using postgres app from postgresapp.com. Place it into application directory and configure the path of pg gem. gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config