Fail to build pg gem - postgresql

I have:
Ubuntu 11.10
Postgres 8.4
libpq-dev, build-essential installed
ruby 1.9.2 and rails 3.2.1 install via rvm
However, pg gem fails to build, saying that:
checking for pg_config... yes
Using config values from /usr/lib/postgresql/8.4/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)
*** extconf.rb failed ***
I understant that this problem was asked dozen of times, but I googled like 2 days, and tried all the solutions I encoutered, and still this gem fails to build.
Any ideas?

Today I encountered a very similar problem on an Ubuntu 10.04.
After trying to get the pg installed for half a day, I decided to just install a more recent version of postgresql manually - which solved the problem for me.
Here is what I did:
1) Obtain the postgresql sources from their website. Since I deploy my rails applications to heroku and they say that they use version 9.0 of postgresql atm, I downloaded
http://ftp.postgresql.org/pub/source/v9.0.6/postgresql-9.0.6.tar.gz
2) Unpack, then follow the instructions in the INSTALL file. Note that 'su' is to be replaced by 'sudo su' in Ubuntu. After that, you have a postgresql server installed at /usr/local/pgsql/.
3) If you already had a system user named 'postgres', you might want to change its home directory to the new postgres installation. And you might want to add /usr/local/pgsql/bin to your PATH. Maybe uninstalling the postgresql-8.4 through apt-get before installing the 9.0 version from sources would be a good idea, I did not try that.
hth

Related

Installing MySQL Client 5.6 on Ubuntu 18.04

I have a legacy project that I'm trying to modernize, and part of that involves setting up a more efficient system of automated backups using mysqldump.
The app's database is using MySQL 5.6, and is hosted via an RDS instance. To get mysqldump up and running, I believe I need to install a version of mysql-client that corresponds to 5.6.
However, running apt-get install mysql-client installs 8.0 by default. However, I can't find any version-specific versions of mysql-client available. Running sudo apt-get install mysql-client-5.7 returns a notice that there's no installation candidate available.
Is it still possible to install older versions of mysql-client? If not, is there another way to get ahold of the mysqldump functionality?
Edit: As #exussum noted below, 8.0 is backwards compatible with 5.6 and 5.7. I was hitting errors when running mysqldump, which I'd assumed indicated incompatibility, but were actually related to my app specifically.
They are backwards compatible, so you can use mysql-client 8 to dump mysql-server 5.5
to get a specific version docker is great
(sudo apt install docker) to install
docker run mysql:5.6 mysqldump
will run mysqldump though docker, and you can choose your version there easily enough

How do I get PHP 7.1 to talk to PostgreSQL on RHEL 7?

Running a Laravel installation on a RedHat Enterprise Linux 7 server using PHP 7.1. I can see php-pgsql.x86_64 listed in the available yum packages, but it doesn't appear to be compatible with PHP 7.1 (and indeed is listed as version 5.4.16-43.el7_4.1).
On a lark, I tried installing it anyway and physically moved the pgsql.ini and pdo_pgsql.ini files from /etc/php.d into the relevant PHP 7.1 folder /etc/opt/rh/rh-php71/php.d/ (and did the same with the .so files they reference), but that returns an error indicating that the package couldn't be read (undefined symbol: file_globals_id in Unknown on line 0).
Has anyone managed to get PHP 7.1 talking to PostgreSQL on RHEL 7?
The sysadmin who originally created the server for me set me straight. The problem was I was looking in the wrong repository for the packages I needed for my particular PHP installation. Running the following two commands did the trick:
sudo yum install --disablerepo=* --enablerepo=rhui-REGION-rhel-server-rhscl rh-php71-php-odbc
sudo yum install --disablerepo=* --enablerepo=rhui-REGION-rhel-server-rhscl rh-php71-php-pgsql
We then added those two packages to the Ansible playbook so future generations would not suffer needlessly.

how to upgrade PostgreSQL 9.2.15 to 9.2.18 on a rhel6 linux server

We are using PostgreSQL 9.2.15 on our rhel6 linux server, and I want to upgrade to PostgreSQL 9.2.18.
Please let me know steps to upgrade minor versions in PostgreSQL.
I don't think that is possible.
Your best bet is probably to take the source RPM, replace 9.2.24 with 9.2.18 in the spec file, drop in the 9.2.18 source archive (which is available), and build your own RPM.
But, as has been mentioned in the comments, you should upgrade both databases to 9.2.24. Actually, you should upgrade to version 10.1 or 9.6.6.
Ignoring for now all the reasons why doing this is a bad idea
it's absolutely possible to upgrade to versions other than the latest, but first you will need a copy of the version you want to install
then you use your low-level package manager rpm -i packagefile or dpkg -i packagefile etc as apropriate...

How to fix pg_dump version mismatch errors?

When trying to get local data to Heroku, I am encountering a version mismatch between two different versions of pg_dump.
Specifically, I am getting this message:
pg_dump: server version: 9.2.2; pg_dump version: 9.1.4
pg_dump: aborting because of server version mismatch
I have found others with this problem, but do not know enough to implement the proposed solutions. (I am new to Ruby on Rails, PostgreSQL, Heroku, and the Mac! Very much at the stage of playing around the picking things up as I go.)
I was thinking I might simplify my life if I uninstalled all PostgreSQL on my local machine and started again with a clean install of PostgreSQL 9.2.2 from http://postgresapp.com/, but I don't know how to go about doing the uninstall.
I'm running Mac OS X Mountain Lion 10.8.2.
OS X 10.8 comes with pg_dump version 9.1.4 in the /usr/bin directory, along with psql and other programs that are client-side PostgreSQL tools. It does not mean that PostgreSQL as a server is installed (unless you have OS X Server Edition).
So you don't have to uninstall PostgreSQL because it's not installed and it's better not to remove these postgres client tools in /usr/bin because they belong to the system as shipped by Apple. They just need to be side-stepped.
The package provided by postgres.app comprises both the PostgreSQL server and the client-side tools of the same version as this server. These tools get installed in /Applications/Postgres.app/Contents/MacOS/bin
To use these instead of the 9.1 ones from Apple when you work in a Terminal, postgres.app documentation says to do:
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
and put it in your .profile file.
Once you have done that and you run pg_dump, you should no longer get the error that's it's the wrong version, because it would be the one that ships with postgres.app (currently 9.2.2).
I have this setup and it works OK for me.
If you only need to upgrade your pg_dump to the latest version and you have homebrew and mac, if the app has the latest version and your local pg doesn't:
brew upgrade postgresql
If you're using postgresapp 9.3.x, the path is different. The following worked for me (courtesy of http://sigmyers.com/blog/2013/3/12/postgres-pgdump-version-mismatch-error-postgresapp-postgresappcom)
export PG_BIN_PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin/"
PATH=$PG_BIN_PATH:$PATH
Check here for the latest path: http://postgresapp.com/documentation/cli-tools.html
I'm running Mountain Lion Server. My PostgeSQL server is at version 9.2.1 and the default tools are at 9.1.5.
I had to use:
PATH="/Applications/Server.app/Contents/ServerRoot/usr/bin:$PATH"
to make it work.
Yep, sometimes if you run Postgres.app this may happen after upgrade. Make sure you restart your Postgres.app - it will update your PATH.
In my case I have postgresql installed via homebrew and the executables are here: /usr/local/opt/postgresql#9.6/bin
Or you copy the dump and restore executions to the /Applications/Postgres.app/Contents/SharedSupport folder
or in PdAgmin you point the PG bin Path (in properties -> binary Path) to the path of the executables of your postgre

Can't install Jekyll on Mac - trying to set up Github Blog

I sucessfully installed Ruby, version 1.8.7 and have been trying to install Jekyll in the Terminal using sudo gem install jekyll. Here's the error I get:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory. unknown68a86d3f981e:~ srb_1974$ sudo gem install jekyll
Building native extensions. This could take a while... ERROR: Error
installing jekyll: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb mkmf.rb can't find header files for ruby at
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in
/Library/Ruby/Gems/1.8/gems/fast-stemmer-1.0.1 for inspection. Results
logged to
/Library/Ruby/Gems/1.8/gems/fast-stemmer-1.0.1/ext/gem_make.out
I've read a bunch of topics, but can't get anything to work. Many topics say I have to have XCode first, but it won't even download, much less install. I read that in Lion you have to set up another administrator and install it under that profile, so I did that, but the install package doesn't exist. It won't even download. I think this may be because I'm not a registered Apple Developer?
Another recommendation was that I install Ruby RVM - this also won't install. Here's the command I used: bash < <( curl https://rvm.beginrescueend.com/releases/rvm-install-head )
And here's the error I get:
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:--
--:--:-- 0 curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More
details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a
"bundle" of Certificate Authority (CA) public keys (CA certs). If the
default bundle file isn't adequate, you can specify an alternate file
using the --cacert option. If this HTTPS server uses a certificate
signed by a CA represented in the bundle, the certificate
verification probably failed due to a problem with the certificate
(it might be expired, or the name might not match the domain name in
the URL). If you'd like to turn off curl's verification of the
certificate, use the -k (or --insecure) option. unknown68a86d3f981e:~
srb_1974$
I only care about Ruby RVM and XCode to the extent that I need them to install Jekyll. I'm just trying to get my Github blog going and I can't seem to do it. I've read and read and read documentation and there's something I'm missing. I'm pretty sure it's knowledge everyone's assuming I have - I don't. I'm a beginner programmer. Any help would be much appreciated.
Ok, here's how I got it to work. It was kind of a random experimentation process until something worked.
I installed XCode and Ruby RVM per others' suggestions and the latter led to my resolution. One of the suggestions on this page said to run "rvm requirements" and read the text. It basically tells you what you need to run & upgrade rubies. This documentation was quite helpful. It explained that what I needed to install Jekyll wasn't really XCode - it was GCC. Evidently, older versions of XCode came with GCC, but newer versions do not, which is why installing XCode didn't solve my problem. It also directed me to where I could download & install GCC, warning me that installing GCC over a newer version of XCode is known to cause problems. So, I uninstalled XCode & headed over here to install GCC.
It was that simple - I installed GCC and Jekyll installed in seconds.
ERROR: Error installing jekyll: ERROR: Failed to build gem native extension.
So the error is "Failed to build gem native extension." when you run sudo gem install jekyll command. You'll find a tip in Jekyll Wiki's Install section:
If you encounter errors like Failed to build gem native extension on Windows you may ...
On OSX, you may need to update RubyGems:
$ sudo gem update --system
So, try to update your RubyGems and run sudo gem install jekyll after that. And I think you don't need to install ruby rvm if you're not a ruby developer.
Btw, I think Ruby v1.9.1 is a recommended version.
And for your Xcode related question, you can download it from App Store though you're not a registered Apple developer. It's free.
Xcode is useful when you need to build some libs with gcc (gcc will be installed together after you've installed the Xcode). But I've no idea whether you'll need it when you install the jekyll.
I tried all the solutions above and did not work. I posted my answer here originally:
RVM requirements error
but for brevity, this is what I posted:
It seems that on OSX 10.9 and XCode5 moved some libs around on us. So I had to install XCode5-DP6 (Dev Preview 6), opened up DP6 and in the settings, you have to tell the command line tools to use the new DP6 build and not the Standard XCode from the marketplace.
First, I had to install homebrew. Nothing liked to play with macports. I am on my first mac as of only a month ago, so macports was just what solved apache for me at the time. I then had to run 'brew install autoconf'
Once I did that I then ran rvm requirements, everything installed without issue. then sudo gem install jekyll from there and it all works like a charm now.
I'm sure once Mavericks is actually released this will get ironed out. We are using early releases after all...
Same issue encountered! After reading this article and random experimentation like following,
xcode install
curl -sSL https://get.rvm.io | bash
sudo gem install jekyll
fixed the issue and could successfully install jekyll