I am trying to run one project on my local machine. I installed Ruby and Rails on my Mac OS system. It is working properly. I can create a new project and can run it properly without any error, but when I try to run the existing project it says that we have to bundle install. When I run that command I get the following error:
"An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling."
When I run gem install rmagick -v '2.13.2' it gives me the following error:
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rmagick-2.13.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
I have searched and did not find an answer anywhere.
For Ubuntu, I used the ff. based on this link:
$ sudo apt-get install libmagick++-dev
On a mac (the below code works on OSX Mavericks):
brew install imagemagick
gem install rmagick
On Mac you can try this:
$ brew unlink imagemagick
$ brew install imagemagick#6 && brew link imagemagick#6 --force
$ gem install rmagick
I have solved this problem by installing imagemagic:
sudo apt-get install imagemagick
and then install libmagick package:
sudo apt-get install libmagick++-dev
For Linux Fedora, I got same error and fixed with below two commands:
yum install ImageMagick
gem install rmagick
For Centos install ImageMagick-devel package. using below commands:
yum install ImageMagick-devel
gem install rmagick
First, make sure you've installed Imagemagick :
$ sudo apt-get install imagemagick
Now, it can build the gem native extension.
Then, install the Rmagick gem :
$ sudo gem install rmagick
here's what i did on 16.04,
sudo apt-get install libmagickwand-dev
sudo apt-get install graphicsmagick-imagemagick-compat
and then install gem like that
PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH" gem install rmagick -v '2.13.2'
May be you are installing ImageMagick version 7.x.x which will generate different folder names in your usr/lib/local/include/ImageMagick7.x.x folder.
E.g.
In ImageMagick6.x.x version we have magick, wand named folders, where in ImageMagick7.x.x version have named this MagickCore , MagickWand . So this updation is causing the problem in some gem installation like here. Which is using
magick/some_header.h or wand/some_header.h (Means they are not updated with the new 7.x.x ImageMagick version).That's why we are getting this error :
```
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
....
checking for wand/MagickWand.h... no
```
and in log file something like this :
error: 'MagickCore/method-attribute.h' file not found
#include "MagickCore/method-attribute.h"
^
Solution
Install the ImageMagick6.x.x version in your system from the official site : https://www.imagemagick.org/download/ and install it using this commands(after extract zip/tar) :
./configure
make
make install
Then do
gem install rmagick
It will work.
As per the error log it looks like "Magick-config" is missing.
You need to install ImageMagik or GraphicsMagick. These are the commands you should follow which is taken from RMagik Documentation:
1) Go to http://www.imagemagick.org or http://www.graphicsmagick.org and download the latest version of the software to a temporary directory. the extract them :
- tar xvzf ImageMagick.tar.gz
- cd ImageMagick-x.x.x
- ./configure --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8
- make
- sudo make install
- sudo gem install rmagick
Solution for Ubuntu:
sudo apt-get install imagemagick
ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config
first run this:
sudo apt-get install imagemagick
then: sudo apt-get install libmagick++-dev
now install rmagick: gem install rmagick
Just run these command
• $ sudo apt-get install imagemagick
• $ sudo apt-get install libmagick++-dev
• $ sudo gem install rmagick
• $ bundle install
I had this same issue when setting up a Rails 6 application in Ubuntu 20.04.
Here's how I solved it
RMagick is an interface between the Ruby programming language and the ImageMagick image processing library. So we first need to install development libraries for ImageMagick:
Step 1:
On Ubuntu, you can run:
sudo apt-get install libmagickwand-dev
On Centos, you can run:
sudo yum install gcc ImageMagick-devel make which
On Arch Linux, you can run:
pacman -Syy pkg-config imagemagick
On Alpine Linux, you can run:
apk add pkgconfig imagemagick imagemagick-dev imagemagick-libs
or you can run if you would like to use ImageMagick 6:
apk add pkgconfig imagemagick6 imagemagick6-dev imagemagick6-libs
On macOS, you can run:
brew install pkg-config imagemagick
or you can run if you would like to use ImageMagick 6:
brew install pkg-config imagemagick#6
On Windows:
Install the latest Ruby+Devkit package which you can get from RubyInstaller for Windows.
You might need to configure PATH environment variable to where the compiler is located.
(Ex: set PATH=C:\Ruby27-x64\msys64\usr\bin;C:\Ruby27-x64\msys64\mingw64\bin;%PATH%)
Download ImageMagick-7.XXXX-Q16-x64-dll.exe (not, ImageMagick-7.XXXX-Q16-x64-static.exe) binary from Windows Binary Release, or you can download ImageMagick 6 from Windows Binary Release.
Install ImageMagick. You need to turn on checkboxes Add application directory to your system path and Install development headers and librarries for C and C++ in an installer for RMagick.
Step 2:
Install the RMagick ruby gem:
gem install rmagick
Step 3:
Now you can add the RMagick ruby gem to your Gemfile:
gem 'rmagick', '~> 4.1'
Note: As of this writing the latest version is 4.1
Step 4:
Finally, you can run bundle install to install the gem to your application.
Resources: rmagick/rmagick GitHub page
That's all.
I hope this helps
Just install ImageMagick-devel package and everything should be fine :)
For Ubuntu Server, I installed it by doing this:
sudo apt-get install imagemagick
sudo apt-get install libmagick++-dev
sudo gem install rmagick -v '2.15.4'
All here wrong for me :(
this helped:
sudo apt-get install libmagickwand-dev
according to rmagick github page
then bundle install went with no errors
If you are using openSUSE, then first check if the ImageMagick installed or not. If it is installed, then do install it development header file.
[arup#sztukajedzenia]$ sudo zypper se imagemagic
root\'s password:
Loading repository data...
Reading installed packages...
S | Name | Summary | Type
--+-------------------+-------------------------------------------------------+-----------
i | ImageMagick | Viewer and Converter for Images | package
| ImageMagick | Viewer and Converter for Images | srcpackage
| ImageMagick-devel | Include Files and Libraries Mandatory for Development | package
| ImageMagick-doc | Document Files for ImageMagick Library | package
| ImageMagick-extra | Viewer and Converter for Images - extra codecs | package
[arup#sztukajedzenia]$ sudo zypper in ImageMagick-devel
root\'s password:
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 2 NEW packages are going to be installed:
ImageMagick-devel libbz2-devel
........
You need to run both the command for ubuntu
sudo apt-get install libmagick++-dev
sudo apt-get install imagemagick
Then try to install
gem install rmagick
For mac users, install imagemagick 6 since the newest version 7 isn't compatible.
brew install imagemagick#6
gem install rmagick
The above should work after you uninstall what you already have.
For Fedora 27 I resolved this problem:
sudo dnf install ImageMagick-devel ImageMagick
gem install rmagick
Related
I 'm on Ubuntu 16.04 ,
in gemfile I have gem "rmagick" and when I bundle it says
An error occurred while installing rmagick (2.16.0), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.16.0'` succeeds before bundling.
as suggested above when I try gem install rmagick -v '2.16.0' it says
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
current directory: /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick
/home/faisal/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160926-26223-16sn0dg.rb extconf.rb
checking for gcc... yes
checking for Magick-config... no
checking for pkg-config... yes
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
checking for outdated ImageMagick version (<= 6.4.9)... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/faisal/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/rmagick-2.16.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0 for inspection.
Results logged to /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/rmagick-2.16.0/gem_make.out
I have tried dozen of different ways provided in different questions but none of the work.
In MacOS, you can do this:
brew unlink imagemagick
brew install imagemagick#6 && brew link imagemagick#6 --force
Try this, You need to run the following commands for ubuntu
sudo apt-get install libmagick++-dev
sudo apt-get install imagemagick
Then try to install
gem install rmagick
On Ubuntu you should first install this
sudo apt-get install libmagickwand-dev
Then install gem install rmagick
On mac/osx, make sure you brew install imagemagick#6 (NOT 7)
On Mac High Sierra - 10.13.4 - https://www.imagemagick.org/script/download.php
sudo port install ImageMagick
sudo gem install rmagick
the only thing that worked for me was
brew unlink pkgconfig
bundle install
brew link pkgconfig
On Fedora (when I installed Redmine) that worked for me:
sudo dnf install ImageMagick-devel
bundle install
You are missing dependencies from Imagemagick which are required for rmagick gem to work
sudo apt-get update
sudo apt-get install imagemagick
Once done, bundle should execute successfully and install the gems.
try this
$ sudo apt-get install libmagick++-dev
and then
bundle install
and install Imagemagick
$ sudo apt-get install imagemagick
Then, install the rmagick gem :
$ sudo gem install rmagick
Type in the following commands on the console -
sudo apt-get install libmagick9-dev
sudo apt-get install graphicsmagick-libmagick-dev-compat
sudo apt-get install libmagickwand-dev
sudo apt-get install libmagickcore-dev
sudo apt-get install libmagick++-dev
Let me know if it solves the issue
On Mac OSX 10.12.3, I have also tried many methods to install rmagick and finally I solved my problem.
brew doctor says
............
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run brew link on these:
imagemagick
Warning: Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
brew link <formula> will cause other formulae to detect them during
the ./configure step. This may cause problems when compiling those
other formulae.
Binaries provided by keg-only formulae may override system binaries
with other strange results.
You may wish to brew unlink these brews:
imagemagick#6
I did
>brew unlink imagemagick#6
Unlinking /usr/local/Cellar/imagemagick#6/6.9.7-9... 60 symlinks removed
>brew link imagemagick
Linking /usr/local/Cellar/imagemagick/6.9.7-3... 75 symlinks created
then
>gem install rmagick
works for me
My advice: Try to install correct version of imagemagick and listen brew doctors advice.
A little late to the game but the following worked for me on Ubuntu 16.04:
Probably overkill a bit but first you'll want to enable all deb-src lines in your sources.list:
sudo vi /etc/apt/sources.list
Then do an apt update:
sudo apt update
Now you should be able to install all the required packages:
sudo apt install libfreetype6-dev libfontconfig1-dev libpng-dev libwmf-dev libpango1.0-dev librsvg2-dev libmagickcore-dev libmagickwand-dev imagemagick
(personally I installed libmagickcore-dev, libmagickwand-dev, imagemagick one at a time during my debugging but you should be able to install them all at once)
Hope this helps
For Centos 6 for the and above
yum install ImageMagick-devel
bundle install
I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg gem. It gives me the following error:
$ gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/u/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/u/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /home/u/.rvm/gems/ruby-1.9.2-p0/gems/pg-0.11.0 for inspection.
Results logged to /home/u/.rvm/gems/ruby-1.9.2-p0/gems/pg-0.11.0/ext/gem_make.out
How do I solve this problem?
It looks like in Ubuntu that header is part of the libpq-dev package (at least in the following Ubuntu versions:
11.04 (Natty Narwhal), 10.04 (Lucid Lynx), 11.10 (Oneiric Ocelot), 12.04 (Precise Pangolin), 14.04 (Trusty Tahr) and 18.04 (Bionic Beaver)):
...
/usr/include/postgresql/libpq-fe.h
...
So try installing libpq-dev or its equivalent for your OS:
For Ubuntu/Debian systems: sudo apt-get install libpq-dev
On Red Hat Linux (RHEL) systems: yum install postgresql-devel
For Mac Homebrew: brew install postgresql
For Mac MacPorts PostgreSQL: gem install pg -- --with-pg-config=/opt/local/lib/postgresql[version number]/bin/pg_config
For OpenSuse: zypper in postgresql-devel
For ArchLinux: pacman -S postgresql-libs
On macOS (previously Mac OS X and OS X), use Homebrew to install the proper headers:
brew install postgresql
and then running
gem install pg
should work.
Alternatively, instead of installing the whole postgresql, you can brew install libpq and export the correct PATH and PKG_CONFIG_PATH as explained in the 'Caveats' section
I had also tried doing gem install libpq-dev, but I received this error:
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
However I found that installing with sudo apt-get (which I try to avoid using with Ruby on Rails) worked, i.e.
sudo apt-get install libpq-dev
# or
apt-get install postgres-server-dev-{pg.version}
# for postgresql 9.4 on Ubuntu 14.04
then I was able to do
gem install pg
without issues.
I could solve this in another way. I didn't find the library on my system. Thus I installed it using an app from PostgreSQL main website. In my case (OS X) I found the file under /Library/PostgreSQL/9.1/include/ once the installation was over. You may also have the file somewhere else depending on your system if you already have PostgreSQL installed.
Thanks to this link on how to add an additional path for gem installation, I could point the gem to the lib with this command:
export CONFIGURE_ARGS="with-pg-include=/Library/PostgreSQL/9.1/include/"
gem install pg
After that, it works, because it now knows where to find the missing library. Just replace the path with the right location for your libpq-fe.h
Can't find the libpq-fe.h header
i had success on CentOS 7.0.1406 running the following commands:
~ % psql --version # => psql (PostgreSQL) 9.4.1
yum install libpqxx-devel
gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config
Alternatively, you can configure bundler to always install pg with these options (helpful for running bundler in deploy environments),
bundle config build.pg --with-pg-config=/usr/pgsql-9.4/bin/pg_config
For CentOS 6.4,
yum install postgresql-devel
gem install pg
worked well!
Just for the record:
Ruby on Rails 4 application in OS X with PostgresApp (in this case 0.17.1 version needed - kind of an old project):
gem install pg -v '0.17.1' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
It is only issue of missing libpq-fe.h
On ubuntu we just need to run:
sudo apt-get install libpq-dev
Above command will install a NEW package libpq-dev and after that you can again execute bundle install to resume your bundle installation.
On Mac OS X run like this:
gem install pg -- --with-pg-config=***/path/to/pg_config***
***/path/to/pg_config*** is path to pg_config
In my case it was package postgresql-server-dev-8.4 (I am on Ubuntu 11.04 (Natty Narwhal), 64 bits).
For MacOS without installing PostgreSQL server:
brew install libpq
gem install pg -- --with-pg-config="/usr/local/Cellar/libpq/9.6.6/bin/pg_config"
The right answer for Mac users with Postgres.app is to build against the libpq provided with that package. For example, with the 9.4 release (current as of this writing), all you need is:
export CONFIGURE_ARGS="with-pg-include=/Applications/Postgres.app/Contents/Versions/9.4/include"
gem install pg
This will keep your pg gem in sync with exactly the version of PostgreSQL you have installed. Installing something from Homebrew is a waste in this case.
I had the same issue on Amazon Linux. I could find the header libpq-fe.h, but somehow it didn't work.
It came from the different versions of the packages that were installed through the different users on the machine. PostgreSQL 9.2 and PostgreSQL 9.3 were installed. So, make sure of your PostgreSQL version before including the libraries.
For me, the magic command line was:
sudo yum install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel
Source: An almost idiot's guide to install PostgreSQL 9.3, PostGIS 2.1 and pgRouting with Yum
My solution for Fedora 30:
sudo dnf install /usr/include/libpq-fe.h
A more general answer for any Debian-based distribution (which includes Ubuntu) is the following. First, install the apt-file package running as root:
apt-get install apt-file
This allows you to search for packages containing a file. Then, update its database using
apt-file update
(this can be run as normal user). Then, look for the missing header using:
apt-file search libpq-fe.h
On my machine, this gives:
libpq-dev: /usr/include/postgresql/libpq-fe.h
postgres-xc-server-dev: /usr/include/postgres-xc/server/gtm/libpq-fe.h
There you go !
On Ubuntu, install the "libpq-dev" to get rid of this issue.
sudo apt-get install libpq-dev
On Fedora 32, I managed to solve this same issue by installing libpq5-devel specifically.
If you install postgresql from the official repository, you will have several versions that won't fix the problem, so it's really a matter of trying out which one it needs.
I had the same problem on Mac OS, but I installed the PostgreSQL gem easily by using the following in a terminal:
ARCHFLAGS="-arch x86_64" gem install pg
(I installed PostgreSQL first with brew install postgresql.)
I found this answer, and it was the only one that worked for me (Mac OS) - after researching for about two days:
$ sudo su
$ env ARCHFLAGS="-arch x86_64" gem install pg
Building native extensions. This could take a while...
Successfully installed pg-0.11.0
1 gem installed
Installing ri documentation for pg-0.11.0...
Installing RDoc documentation for pg-0.11.0...
See Stack Overflow question Can't find the PostgreSQL client library (libpq).
I recently upgraded to Mac OS X v10.10 (Yosemite) and was having difficulty building the pg gem.
The error reported was the typical:
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... *** extconf.rb failed ***
My solution was to gem uninstall pg and then bundle update pg to replace the gem with the latest. I did run brew update; brew upgrade after the Yosemite install to get the latest versions of packages I had installed previously.
On a Mac, I solved it using this code:
gem install pg -v '0.18.4' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
I had this issue with Postgresql 9.6. I was able to fix it by doing:
brew upgrade postgresql#9.6
brew link postgresql#9.6 --force
gem install pg
I am running Postgres.app on a Mac and I had to
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
first. Then
bundle install
worked for me.
I encountered the same error with postgres installed through asdf. The pg-config solutions didn't work for me. Instead I had to locate the postgres include folder which contains the file and run the command with the --with-pg-include flag
gem install pg -- --with-pg-include=/<path>/.asdf/installs/postgres/<version>/include
On CentOS,I installed libpq-dev package using below command
yum install postgresql-devel
Executing gem install pg returned the same error as "No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config".
Installing the gem as below solved my problem
gem install pg -- --with-pg-config=/usr/pgsql-x.x/bin/pg_config
On Ubuntu 20.04, I already had libpq5:amd64 version 13.2-1.pgdg20.04+1. Now when I tried to install libpq-dev from apt repository, I was receiving
The following packages have unmet dependencies:
libpq-dev : Depends: libpq5 (= 12.6-0ubuntu0.20.04.1) but 13.2-1.pgdg20.04+1 is to be installed
I grabbed the deb from http://ftp.us.debian.org/debian/pool/main/p/postgresql-13/libpq-dev_13.2-1_amd64.deb and did the following:
mkdir -p /tmp/libpq-dev
dpkg-deb -R libpq-dev_13.2-1_amd64.deb /tmp/libpq-dev
sed -i 's|= 13.2-1|= 13.2-1.pgdg20.04+1|' /tmp/libpq-dev/DEBIAN/control
dpkg-deb -b /tmp/libpq-dev /tmp/libpq-dev-new.deb
sudo dpkg -i /tmp/libpq-dev-new.deb
I have been using the gem happily after that. No additional installs or anything.
For alpine, please use below to fix the error
apk add --no-cache postgresql-dev
On debian bullseye, none of the existing answers solved the issue for me.
In case it helps someone with the same configuration as mine:
Use PostgreSQL's apt repository: https://wiki.postgresql.org/wiki/Apt
sudo apt-get update && sudo apt-get dist-upgrade (upgrade PostgreSQL from v13 to v14)
sudo apt-get install libpq-dev
gem install pg or bundle install
On FreeBSD (9.1) the necessary package is /usr/ports/database/postgresql-server* which when installed will also install the required header file that makes the gem install of "pg" fail. This answer here helped me find the solution but the difference in package names required a bit of searching.
Hopefully this helps someone avoid a bit of head scratching when searching for the "-dev" package on a FreeBSD system!
On Debian 7.0, 64-bit (Wheezy), just run:
sudo apt-get install libpq-dev
After you successfully installed libpq-dev, run:
bundle install
Any suggestions on how to fix?
gem install capybara-webkit -v '0.11.0'
Building native extensions. This could take a while...
ERROR: Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
/home/durrantm/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
sh: qmake: not found
Gem files will remain installed in /home/durrantm/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.11.0 for inspection.
Results logged to /home/durrantm/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.11.0/./gem_make.out
If you are in Ubuntu do
sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui
If you are on Mac
brew install qt
and then
gem install capybara-webkit -v '0.11.0'
For Ubuntu 16.04
sudo apt-get install qt-sdk
Followed by
gem install capybara-webkit -v '1.11.0'
or replace with whatever version you want to install.
You are probably missing the qt libraries. See the capybara-webkit wiki for instructions on installing them for your platform.
brew install qt will only install (as of August 4, 2015) 4.8.6, which gives you this message.
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.6.
Instead, if you do
brew install qt5
brew link --force qt5
you won't get that error.
On El Capitan or Yosemite, you may need to do
brew install qt55
according to the doc here.
For Ubuntu 20.04 you can install qt5-default package
sudo apt-get install g++ qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
Then install the gem with the required version:
gem install capybara-webkit -v '1.11.0'
On fedora is a bit more complicated. I did the next which takes a while:
$ sudo dnf install make gcc-c++ gdb qt5*-devel qt-creator
$ export QMAKE=/usr/bin/qmake-qt5
$ gem install capybara-webkit
Then it worked!
See more info on capybara-webkit wiki
I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg gem. It gives me the following error:
$ gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/u/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/u/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /home/u/.rvm/gems/ruby-1.9.2-p0/gems/pg-0.11.0 for inspection.
Results logged to /home/u/.rvm/gems/ruby-1.9.2-p0/gems/pg-0.11.0/ext/gem_make.out
How do I solve this problem?
It looks like in Ubuntu that header is part of the libpq-dev package (at least in the following Ubuntu versions:
11.04 (Natty Narwhal), 10.04 (Lucid Lynx), 11.10 (Oneiric Ocelot), 12.04 (Precise Pangolin), 14.04 (Trusty Tahr) and 18.04 (Bionic Beaver)):
...
/usr/include/postgresql/libpq-fe.h
...
So try installing libpq-dev or its equivalent for your OS:
For Ubuntu/Debian systems: sudo apt-get install libpq-dev
On Red Hat Linux (RHEL) systems: yum install postgresql-devel
For Mac Homebrew: brew install postgresql
For Mac MacPorts PostgreSQL: gem install pg -- --with-pg-config=/opt/local/lib/postgresql[version number]/bin/pg_config
For OpenSuse: zypper in postgresql-devel
For ArchLinux: pacman -S postgresql-libs
On macOS (previously Mac OS X and OS X), use Homebrew to install the proper headers:
brew install postgresql
and then running
gem install pg
should work.
Alternatively, instead of installing the whole postgresql, you can brew install libpq and export the correct PATH and PKG_CONFIG_PATH as explained in the 'Caveats' section
I had also tried doing gem install libpq-dev, but I received this error:
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
However I found that installing with sudo apt-get (which I try to avoid using with Ruby on Rails) worked, i.e.
sudo apt-get install libpq-dev
# or
apt-get install postgres-server-dev-{pg.version}
# for postgresql 9.4 on Ubuntu 14.04
then I was able to do
gem install pg
without issues.
I could solve this in another way. I didn't find the library on my system. Thus I installed it using an app from PostgreSQL main website. In my case (OS X) I found the file under /Library/PostgreSQL/9.1/include/ once the installation was over. You may also have the file somewhere else depending on your system if you already have PostgreSQL installed.
Thanks to this link on how to add an additional path for gem installation, I could point the gem to the lib with this command:
export CONFIGURE_ARGS="with-pg-include=/Library/PostgreSQL/9.1/include/"
gem install pg
After that, it works, because it now knows where to find the missing library. Just replace the path with the right location for your libpq-fe.h
Can't find the libpq-fe.h header
i had success on CentOS 7.0.1406 running the following commands:
~ % psql --version # => psql (PostgreSQL) 9.4.1
yum install libpqxx-devel
gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config
Alternatively, you can configure bundler to always install pg with these options (helpful for running bundler in deploy environments),
bundle config build.pg --with-pg-config=/usr/pgsql-9.4/bin/pg_config
For CentOS 6.4,
yum install postgresql-devel
gem install pg
worked well!
Just for the record:
Ruby on Rails 4 application in OS X with PostgresApp (in this case 0.17.1 version needed - kind of an old project):
gem install pg -v '0.17.1' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
It is only issue of missing libpq-fe.h
On ubuntu we just need to run:
sudo apt-get install libpq-dev
Above command will install a NEW package libpq-dev and after that you can again execute bundle install to resume your bundle installation.
On Mac OS X run like this:
gem install pg -- --with-pg-config=***/path/to/pg_config***
***/path/to/pg_config*** is path to pg_config
In my case it was package postgresql-server-dev-8.4 (I am on Ubuntu 11.04 (Natty Narwhal), 64 bits).
For MacOS without installing PostgreSQL server:
brew install libpq
gem install pg -- --with-pg-config="/usr/local/Cellar/libpq/9.6.6/bin/pg_config"
The right answer for Mac users with Postgres.app is to build against the libpq provided with that package. For example, with the 9.4 release (current as of this writing), all you need is:
export CONFIGURE_ARGS="with-pg-include=/Applications/Postgres.app/Contents/Versions/9.4/include"
gem install pg
This will keep your pg gem in sync with exactly the version of PostgreSQL you have installed. Installing something from Homebrew is a waste in this case.
I had the same issue on Amazon Linux. I could find the header libpq-fe.h, but somehow it didn't work.
It came from the different versions of the packages that were installed through the different users on the machine. PostgreSQL 9.2 and PostgreSQL 9.3 were installed. So, make sure of your PostgreSQL version before including the libraries.
For me, the magic command line was:
sudo yum install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel
Source: An almost idiot's guide to install PostgreSQL 9.3, PostGIS 2.1 and pgRouting with Yum
My solution for Fedora 30:
sudo dnf install /usr/include/libpq-fe.h
A more general answer for any Debian-based distribution (which includes Ubuntu) is the following. First, install the apt-file package running as root:
apt-get install apt-file
This allows you to search for packages containing a file. Then, update its database using
apt-file update
(this can be run as normal user). Then, look for the missing header using:
apt-file search libpq-fe.h
On my machine, this gives:
libpq-dev: /usr/include/postgresql/libpq-fe.h
postgres-xc-server-dev: /usr/include/postgres-xc/server/gtm/libpq-fe.h
There you go !
On Ubuntu, install the "libpq-dev" to get rid of this issue.
sudo apt-get install libpq-dev
On Fedora 32, I managed to solve this same issue by installing libpq5-devel specifically.
If you install postgresql from the official repository, you will have several versions that won't fix the problem, so it's really a matter of trying out which one it needs.
I had the same problem on Mac OS, but I installed the PostgreSQL gem easily by using the following in a terminal:
ARCHFLAGS="-arch x86_64" gem install pg
(I installed PostgreSQL first with brew install postgresql.)
I found this answer, and it was the only one that worked for me (Mac OS) - after researching for about two days:
$ sudo su
$ env ARCHFLAGS="-arch x86_64" gem install pg
Building native extensions. This could take a while...
Successfully installed pg-0.11.0
1 gem installed
Installing ri documentation for pg-0.11.0...
Installing RDoc documentation for pg-0.11.0...
See Stack Overflow question Can't find the PostgreSQL client library (libpq).
I recently upgraded to Mac OS X v10.10 (Yosemite) and was having difficulty building the pg gem.
The error reported was the typical:
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... *** extconf.rb failed ***
My solution was to gem uninstall pg and then bundle update pg to replace the gem with the latest. I did run brew update; brew upgrade after the Yosemite install to get the latest versions of packages I had installed previously.
On a Mac, I solved it using this code:
gem install pg -v '0.18.4' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
I had this issue with Postgresql 9.6. I was able to fix it by doing:
brew upgrade postgresql#9.6
brew link postgresql#9.6 --force
gem install pg
I am running Postgres.app on a Mac and I had to
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
first. Then
bundle install
worked for me.
I encountered the same error with postgres installed through asdf. The pg-config solutions didn't work for me. Instead I had to locate the postgres include folder which contains the file and run the command with the --with-pg-include flag
gem install pg -- --with-pg-include=/<path>/.asdf/installs/postgres/<version>/include
On CentOS,I installed libpq-dev package using below command
yum install postgresql-devel
Executing gem install pg returned the same error as "No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config".
Installing the gem as below solved my problem
gem install pg -- --with-pg-config=/usr/pgsql-x.x/bin/pg_config
On Ubuntu 20.04, I already had libpq5:amd64 version 13.2-1.pgdg20.04+1. Now when I tried to install libpq-dev from apt repository, I was receiving
The following packages have unmet dependencies:
libpq-dev : Depends: libpq5 (= 12.6-0ubuntu0.20.04.1) but 13.2-1.pgdg20.04+1 is to be installed
I grabbed the deb from http://ftp.us.debian.org/debian/pool/main/p/postgresql-13/libpq-dev_13.2-1_amd64.deb and did the following:
mkdir -p /tmp/libpq-dev
dpkg-deb -R libpq-dev_13.2-1_amd64.deb /tmp/libpq-dev
sed -i 's|= 13.2-1|= 13.2-1.pgdg20.04+1|' /tmp/libpq-dev/DEBIAN/control
dpkg-deb -b /tmp/libpq-dev /tmp/libpq-dev-new.deb
sudo dpkg -i /tmp/libpq-dev-new.deb
I have been using the gem happily after that. No additional installs or anything.
For alpine, please use below to fix the error
apk add --no-cache postgresql-dev
On debian bullseye, none of the existing answers solved the issue for me.
In case it helps someone with the same configuration as mine:
Use PostgreSQL's apt repository: https://wiki.postgresql.org/wiki/Apt
sudo apt-get update && sudo apt-get dist-upgrade (upgrade PostgreSQL from v13 to v14)
sudo apt-get install libpq-dev
gem install pg or bundle install
On FreeBSD (9.1) the necessary package is /usr/ports/database/postgresql-server* which when installed will also install the required header file that makes the gem install of "pg" fail. This answer here helped me find the solution but the difference in package names required a bit of searching.
Hopefully this helps someone avoid a bit of head scratching when searching for the "-dev" package on a FreeBSD system!
On Debian 7.0, 64-bit (Wheezy), just run:
sudo apt-get install libpq-dev
After you successfully installed libpq-dev, run:
bundle install
I used a script to install ImageMagick http://github.com/masterkain/ImageMagick-sl
After a while, I got ImageMagick installed.
Then I ran sudo gem install rmagick and got
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in...
I'm working in OSX Snow Leopard with Ruby 1.9.2 and Rails 3. Any ideas?
I was getting the same error and it got resolved after installing the libmagick9-dev library on ubuntu 11.
Update (Thanks to the commenters - Dec. 2012)
$ sudo apt-get install libmagickwand-dev or $ sudo apt-get install graphicsmagick-libmagick-dev-compat for ubuntu 12
$ sudo apt-get install libmagickwand-dev or $ sudo apt-get install libmagick9-dev for ubuntu 11 or below.
$ yum install ImageMagick-devel for centos
$ brew install imagemagick for Mac OS (using Homebrew)
you need the imagemagick libraries under ubuntu
$ sudo apt-get install libmagickwand-dev
it contains all missing libraires
then run bundle install command
I believe you need the Imagemagick libraries.
If you are using Homebrew (which I'd highly recommend), simply do
$ brew install imagemagick
Then rerun bundle install
Mac OS Mountain Loin (using Homebrew)
download and install http://xquartz.macosforge.org/trac/wiki/X112.7.2
brew install imagemagick
gem install rmagick
sudo apt-get install libmagickwand-dev
works well for Ubuntu 12.10
This is assuming you have installed all other dependencies viz.
sudo apt-get install imagemagick ruby ruby-dev gem`
On CentOS 5.7, I got it to work by first specifying PKG_CONFIG_PATH:
export PKG_CONFIG_PATH=/usr/local/src/ImageMagick-6.7.5-10/magick/
gem install rmagick
For those who got
InitializeMagick() in -lMagickCore... no; -lMagick... no; -lMagick++... no;
this worked for me in OS X 10.8: https://github.com/maddox/magick-installer
From here: RVM + Ruby 1.9.2 + Rmagick + Lion = System Works, RVM Doesn't
Initially, I came around to installing rmagick because it seemed to be a dependency when I tried installing libgtk2.0-dev. I was trying to install that package, because the RGtk2.0 is a requirement for using R package called rattle.
Anyway, none of the above solutions worked for me in installing in my Ubuntu 12.04. Even running sudo apt-get update first didn't seem to help, nor this related posting: Installing rmagick on Ubuntu
I eventually found what works is to troubleshoot using sudo aptitude rather than apt-get.
https://askubuntu.com/questions/223237/unable-to-correct-problems-you-have-held-broken-packages
I recommend the technique of using aptitude to work through the package installation issue.
On Mac Os X, check if /opt/local/bin is in your PATH. If not:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
sudo gem install rmagick
This worked for me!
I had an issue installing Rmagick gem version 2.13.2 on Debian Jessie. After fighting with the packages in the other answers, I upgraded the version of the Rmagick gem from 2.13.2 to the latest (2.16.0 at time of writing). This installed successfully.
bundle update rmagick
If you tried all solutions, of all posts of whole Internet, have installed and reinstalled many times all indicated packages in all Linux or Mac distributions/versions (even in Windows) and it still not working, close your terminal and open it again. Some times, even if your reload all shell environment, only after I reopen the terminal the bundle install was successfully completed.
After several days of searching, my problema was related to some missing libraries, and the one that get the gem installed was this one:
brew install pkg-config
after this I did my bundle install again and it worked.