0

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?

Theopap
  • 715
  • 1
  • 10
  • 33

1 Answers1

0

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
Jeffrey Harrington
  • 1,797
  • 1
  • 15
  • 24
  • Thanks for the reply @Jeffrey Harrington... I have already installed `postgresql` with `brew install postgresql`. But tried to reinstall it and I got this: `Warning: postgresql 10.1 is already installed` – Theopap Jan 14 '18 at 18:15
  • @Theopap Interesting. I just recreated your problem (High Sierra, Ruby 2.4, Rails 5, PG 10.1) and the problem was resolved by installing PG from Homebrew. Perhaps check that your Homebrew install directory (/usr/local/bin) is in your $PATH properly with `export PATH="/usr/local/bin:$PATH"` – Jeffrey Harrington Jan 14 '18 at 20:27
  • Thanks for the reply @Jeffrey Harrington, I solved this I had to update rubymine and then `bundler install`. I don't know why, but it works that way. – Theopap Jan 16 '18 at 14:23