Not able to install pg gem on Ubuntu 12.10 - ruby

I am using Ubuntu 12.10 64-bit and I have following packages installed :
dpkg --get-selections | grep postgre
output:
postgresql
postgresql-9.1
postgresql-client
postgresql-client-9.1
postgresql-client-common
postgresql-common
postgresql-contrib
postgresql-contrib-9.1
postgresql-server-dev-9.1
postgresql-server-dev-all
libpq-dev
libpq5
rvm 1.17.9
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]
I am not able to install pg gem I am getting following error :
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/vedarthk/.rvm/rubies/ruby-1.9.3-p362/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
I have also tried following commands but the output is same as above :
gem install pg -- --with-pg-include=/usr/include/postgresql/libpq --with-pg-lib=/usr/lib/postgresql/9.1/lib
gem install pg -- --with-pg-include=/usr/include/postgresql --with-pg-lib=/usr/lib/postgresql/9.1/lib

Try installing PostgreSQL development headers:
sudo apt-get install libpq-dev

Try -
$ sudo apt-get install ruby-dev
sudo gem install pg won't work has that solution and it worked for me.

I had a similar problem on RHEL 6.4, the following worked for me:
gem install /opt/redmine/vendor/cache/pg-0.18.4.gem --local -- --with-pg-dir=/usr/pgsql-9.4/
I setup PostgreSQL from their own repos.

Related

Ruby application: bundle install error due to can't find postgresql client library?

Hello I'm very new with Ruby but I've been tasked to start a deprecated ruby application
I installed the dependencies
- Ruby version
`rbenv install 2.3.1`
`gem install bundle`
`bundle install`
- System dependencies
`brew install postgresql#9.6`
`brew services start postgresql#9.6`
`brew link postgresql#9.6 --force`
Since 9.6 is disabled I'm using 9.5 for postgresql
When I run sudo bundle install (since permisson error)
I run into this error
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
I have libpq and postgresql installed by brew..
What am I missing?
Before getting to an answer, it's SUPER important to never run sudo with bundle. This will install the gems with sudo power, meaning they can affect your machine with sudo power. Definitely a very bad thing to give other people's code full sudo access to your machine.
Next, you need to install [libpq-dev][1] before running bundle. This installs necessary binaries and headers needed to create postgresql apps.
On Linux (Ubuntu) run the following:
sudo apt-get install libpq-dev
If you're on Mac you just need to run:
brew install postgresql
and that will install the needed headers for you automatically.
[1]: https://pypi.org/project/libpq-dev/

Can't install RMagick 2.15.4. Can't find MagickWand.h

While I'm trying to install rmagic, it shows following error
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/***/.rvm/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20170814-
44982-1i5w4mc.rb extconf.rb
checking for gcc... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no
Can't install RMagick 2.15.4. Can't find MagickWand.h.
*** 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.
I'm using MacOS sierra, ruby version 2.2.3
I had this issue a while back. You need to install imagemagick. Per the github repo for the rmagic gem
Pre-reqs:
ImageMagick Version 6.4.9 or later. You can get ImageMagick from www.imagemagick.org.
I believe you can also install it with brew
$ brew install imagemagick#6
$ brew link imagemagick#6 --force
$ gem install rmagick
brew unlink pkgconfig
bundle install
brew link pkgconfig
did the trick for me

Can't find wand/MagickWand.h

I have update my system to Ubuntu 15.04 and now Rmagick can't be installed...
It gives me the following error:
$ gem install rmagick -v '2.13.2'
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/home/maria/.rvm/rubies/ruby-2.1.1/bin/ruby -r ./siteconf20150428-16155-3f5duq.rb extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no
Can't install RMagick 2.13.2. Can't find MagickWand.h.
*** 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.
I install all the packages needed (imagemagick libmagickwand-dev, etc, I have tried all the packages described in other questions)
Does someone had the same problem? Any clue?
Everything was working fine before updating to 15.04
EDIT
I managed to make it work purging imagemagick and installing from source http://www.imagemagick.org/script/install-source.php?ImageMagick=9s6tlikqbn5eb0u0spg5o38sa4#unix
Now gives me this error: This installation of RMagick was configured with ImageMagick 6.9.1 but ImageMagick 6.8.9-9 is in use.
I had the same problem and I fixed it up updating rmagick. What I did was:
sudo apt-get install libmagickwand-dev imagemagick
bundle update rmagick
And now bundle works correctly.
I am on ubuntu 15.04 and was able to get it by specifying version of rmagick
gem 'rmagick', '2.15.0'
I ran into same problem on clean Ubuntu 15.4 installation. Upgrade rmagick from 2.13.2 to 2.15.0 helped.
Things I tried, that did not help:
manually symlink in /usr/include/wand MagickWand.h ⇒ magick_wand.h;
rolling back to libmagickcore-dev.
Hope it helps.
If you are on Debian/Ubuntu I was able to fix it by doing the following:
sudo apt-get install libmagickwand-dev
sudo apt-get install graphicsmagick-imagemagick-compat
PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH" gem install rmagick -v '2.13.2'
your lib versions may be different so check the version in /usr/lib/x86...
I got this from this discussion: https://github.com/ttscoff/Slogger/issues/344

some readline lib missing for ruby on ubuntu 12.04 with rvm

We are installing readline on ubuntu 12.04 for ruby 1.9.3. Some files are missing when running extconf:
$ ruby extconf.rb -- --with-readline-dir="$HOME/.rvm/usr"
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
How do we install the last 3 files missed before running make install? Thanks so much.
Try to download libreadline5-dev package for your architecture, for example, from here and install install it manually.
sudo dpkg -i downloaded_package.deb
It should help you.

Issue installing the Nokogiri gem in Mac OS X 10.5.8

I'm trying to install the Nokogiri gem under an RVM managed Ruby 1.8.7 installation in OS X Leopard (10.5.8).
I'm getting the following error:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... no
-----
The function 'xmlHasFeature' is missing from your installation of libxml2. Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well. To get around this problem, please upgrade your installation of libxml2.
Please visit http://nokogiri.org/tutorials/installing_nokogiri.html for more help!
*** extconf.rb failed ***
I have the latest libxml2 installed via homebrew (brew install libxml2), so I don't know what else to try.
Update:
I tried the instructions from the Nokogiri website and I can't get the Nokogiri gem installation to recognize libxml2.
Per the instructions
I installed and linked libxml2 and libxslt via homebrew:
brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri
The error message has changed, but the Nokogiri installation complains that libxml2 is missing:
...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies
The installed libxml2 version is 2.7.8.
Update update:
I tried installing the iconv library from homebrew to see if I could solve the error checking for iconv_open() in iconv.h... no, so I ran the commands:
brew install libiconv
brew link libiconv
And after finishing the installation, I tried to install the nokogiri gem again, to get this error message, where the installer now complains that libiconv is missing
hecking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
I'm clueless.
Per the directions at: http://nokogiri.org/tutorials/installing_nokogiri.html you needed to use:
brew install libxml2 libxslt
brew link libxml2 libxslt
then
gem install nokogiri
Did you use those or only brew install libxml2?
Make sure there is no Nokogiri version available:
use gem uninstall nokogiri
First install the command-line tool for Xcode. Refer to "How to use/install gcc on Mac OS X 10.8 / Xcode 4.4".
Then run the following commands:
brew install libxml2
gem install nokogiri
Now it works well, I tried it.
brew install libxml2 libxslt
gem install nokogiri -- \
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.x/lib \
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.xx \
--with-iconv-lib=/usr/lib \
--with-iconv-include=/usr/local/include

Resources