Install pg gem on CentOS 6 - ruby-on-rails

I'm trying to setup my VPS (CentOS 6.4) with ruby on rails and postgres.
I installed ruby (2.1.0p0), rails (4.1.0), and postgresql (9.3.4) with no problem.
When I try create new rails app (rails new new_app -d postgresql) it stops when installing the pg gem. I've looked into all SO posts about this error and tried pretty much everything I could find. The most suggested was to run "yum install postgresql-devel" and still didn't work.
Below you can find the ssh output and the mkmf.log. Let me know if need more information...
Output
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/deploy/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.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.
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/deploy/.rvm/rubies/ruby-2.1.0/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
/home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:1119:in `find_header'
from extconf.rb:48:in `'
extconf failed, exit code 1
mkmf.log
"gcc -o conftest -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0/x86_64-linux -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0/ruby/backward -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0 -I. -I/usr/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/deploy/.rvm/rubies/ruby-2.1.0/lib -Wl,-R/home/deploy/.rvm/rubies/ruby-2.1.0/lib -L/usr/lib64 -Wl,-R/usr/lib64 -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,'/../lib' -Wl,-R -Wl,'/../lib' -L'/../lib' -lruby -lpthread -lrt -ldl -lcrypt -lm -lc"
gcc: error trying to exec 'as': execvp: Permission denied
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */

Before:
For Centos 6: Right install Postgres 9.* with this guide.
After:
yum install postgresql-libs postgresql-devel
Helpful instruction:
How to setup RoR with Postgres

As you are not using the outdated PostgreSQL version that comes with CentOS 6 (PostgreSQL 8.4), you need to install the -devel package matching your version (PostgreSQL 9.X).
The easiest way is to use the official PostgreSQL yum repository.
As the latest version is 9.5 and it is compatible with all 9.X versions I will write the instructions for that one. In the future you can refer to the official instructions for the updated commands.
yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
yum install postgresql95-devel
Then install the gem with the -with-pg-config option:
gem install pg -- --with-pg-config=/usr/pgsql-9.5/bin/pg_config

This was easier for me:
ln -s /usr/pgsql-9.5/bin/pg_config /usr/local/bin/

Try something like this;
before "bundle:install" do
run "ls -l #{fetch(:latest_release)}/Gemfile"
#run "bundle config --local --gemfile=#{fetch(:latest_release)}/Gemfile build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config"
run "cd #{fetch(:latest_release)} && bundle config build.pg --with-pg-config=/usr/pgsql-9.3/bin/pg_config"
end

You could try installing the pg gem with the postres pg_config file path option:
gem install pg -- --with-pg-config=/usr/pgsql-9.2/bin/pg_config
Please update the path according to your system
Regards

I had this problem on my mac and it was a bash / RVM issue. I had to add this to my bash:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm” . Given that it's finding the config file I would look into this.

Related

ruby:2.5.1-slim or ruby-2.5.1-alpine fails on nokogiri gem

FROM ruby:2.5.1-slim or ruby-2.5.1-alpine throws the following error, how I do use a smaller footprint for ruby as it doesn't seem to be using any of the above options which I would prefer to use. This error happens while running the bundle install command
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/nokogiri-1.8.4/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20180828-6-l5tj3e.rb extconf.rb
checking if the C compiler accepts ... *** 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/bin/$(RUBY_BASE_NAME)
--help
--clean
/usr/local/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to
generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:410:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.8.4 for
inspection.
Results logged to
/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/gem_make.out
An error occurred while installing nokogiri (1.8.4), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.8.4' --source 'http://rubygems.org/'`
succeeds before bundling.
In Gemfile:
rails was resolved to 5.2.1, which depends on
actioncable was resolved to 5.2.1, which depends on
actionpack was resolved to 5.2.1, which depends on
actionview was resolved to 5.2.1, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
The command '/bin/sh -c bundle install --without development test' returned a non-zero code: 5
First of all, try to run gem install nokogiri manually and check the log as suggested in the output above:
...
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/mkmf.log
...
I recently had a problem while installing the nokogiri gem too. So I opened my mkmf.log file and found the reason of the problem there (the stdio.h library was missing out of the distribution):
"gcc -o conftest -I/usr/local/include/ruby-2.5.0/x86_64-linux-musl -I/usr/local/include/ruby-2.5.0/ruby/backward -I/usr/local/include/ruby-2.5.0 -I. -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wduplicated-cond -Wno-maybe-uninitialized -fPIC conftest.c -L. -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lruby -lpthread -ldl -lcrypt -lm -lc "
In file included from /usr/local/include/ruby-2.5.0/ruby/ruby.h:29:0,
from /usr/local/include/ruby-2.5.0/ruby.h:33,
from conftest.c:1:
/usr/local/include/ruby-2.5.0/ruby/defines.h:112:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
The problem was solved by installing the libc-dev package for me.
So. To solve your problem you should iteratively run gem install nokogiri command, check mkmf.log file after each failure and fix missing dependencies until the package is installed.
BTW here's my final list of dependencies which was enough to install Rails in Alpine:
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk update \
&& apk add --update-cache postgresql-client nodejs \
libffi-dev readline sqlite build-base postgresql-dev \
libc-dev linux-headers libxml2-dev libxslt-dev readline-dev gcc libc-dev \
&& rm -rf /var/cache/apk/*
try this:
run sudo gem install nokogiri. It will install the latest version of nokogiri.
Then update the version of nokogiri in your Gemfile.lock file to the latest version of nokogiri you juste installed.
And finally run bundle install. Maybe it'll help. Worked for me.

Can't install Jekyll on Mint

I installed ruby and ruby gems, updated both of them, tried to install jekyll using the command
sudo gem install jekyll bundler
it gave me this
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.14/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20161209-4826-wdshax.rb extconf.rb
checking for ffi.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.
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/bin/$(RUBY_BASE_NAME)2.3
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
from /usr/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
from /usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from /usr/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
from extconf.rb:16:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.14/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/ffi-1.9.14 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.14/gem_make.out
Successfully installed bundler-1.13.6
Parsing documentation for bundler-1.13.6
Done installing documentation for bundler after 7 seconds
1 gem installed
Here is what it says in the log file:
package configuration for libffi is not found
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm -lc"
In file included from /usr/include/ruby-2.3.0/ruby/ruby.h:36:0,
from /usr/include/ruby-2.3.0/ruby.h:33,
from conftest.c:1:
/usr/include/ruby-2.3.0/ruby/defines.h:26:19: fatal error: stdio.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
I'm running Linux Mint, and I can't find anything to help this problem. One gem of jekyll is installed and I'm able to create jekyll projects, but only partially and I can't run it on my local host and edit it.
Any more questions let me know and I'll try my best to help provide the details.
I had the same problem on Linux Mint 18. Installing build-essential solved it:
sudo apt-get install build-essential
I've been there. Some linux need custom treatment till get done to do something.
You can try to
bundle exec jekyll serve --trace
If you pass, you will find url like this: http://127.0.0.1:4000/

'gem install ffi' failed on Mac OS X Yosemite 10.10.5

I'm trying to set up a RoR environment under RVM on Mac OS X Yosemite 10.10.5 on my macbook pro.
The ruby version that I need to install is 1.9.3-p194 because it's required for my software development project.
So far, I have the following software installed on my Macbook:
RVM
ruby 1.9.3-p194
xcode v6.4 and the respective version of command line tools
Mac OS X version: 10.10.5 Yosemite
It seems I'm running into a problem that the ffi gem (an independency of my project) cannot be built successfully.
I get the following error whenever I try to install the gem via the command "gem install ffi -v '1.9.3'"
MacBook-Pro:demo-project apple$ gem install ffi -v '1.9.3'
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
/Users/apple/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -r ./siteconf20160428-1898-idt325.rb extconf.rb
checking for ffi_call() in -lffi... *** 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
--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=/Users/apple/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
--with-ffilib
--without-ffilib
/Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
from extconf.rb:20:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/apple/.rvm/gems/ruby-1.9.3-p194/gems/ffi-1.9.3 for inspection.
Results logged to /Users/apple/.rvm/gems/ruby-1.9.3-p194/extensions/x86_64-darwin-14/1.9.1/ffi-1.9.3/gem_make.out
I said I have the xcode command line tools installed, but notice from the given error below that it gave me a hint "You have to install development tools first".
Didn't I have it installed already? I was asking myself out of curiousity.
Then I googled and found out the way how to check if I have xcode command line tools installed. Then I launched the terminal and issued that command as illustrated below, and the result did confirm that the piece of software was already installed.
MacBook-Pro:demo-project apple$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
Here is also my gcc version:
MacBook-Pro:demo-project apple$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
I have searched all over the web and tried many solutions, but, unfortunately, without success.
Any advice would be very much appreciated to get this to work.
Updated:
My mkmf.log
package configuration for libffi
cflags: -I/usr/local/Cellar/libffi/3.0.13/lib/libffi-3.0.13/include
ldflags: -L/usr/local/Cellar/libffi/3.0.13/lib
libs: -lffi
"/usr/local/bin/gcc-4.9 -o conftest -I/Users/apple/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/x86_64-darwin14.5.0 -I/Users/apple/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/apple/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1 -I. -I/usr/local/opt/libyaml/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -fno-common -pipe -I/usr/local/Cellar/libffi/3.0.13/lib/libffi-3.0.13/include conftest.c -L. -L/Users/apple/.rvm/rubies/ruby-1.9.3-p194/lib -L/usr/local/opt/libyaml/lib -L. -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L/usr/local/Cellar/libffi/3.0.13/lib -lffi -lruby.1.9.1 -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */

error on installing passenger nginx module on ubuntu with ruby 2.0.0 via rvm

I'm using ubuntu 12.04 LTS, ruby 2.0 with RVM
during installation. this error occurs.
checking for alloca.h... *** /home/pastelcorp/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10/ext/ruby/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=/home/pastelcorp/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10/ext/ruby
--curdir
--ruby=/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:430:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:561:in `try_cpp'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:1040:in `block in have_header'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:891:in `block in checking_for'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:336:in `block (2 levels) in postpone'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:306:in `open'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:336:in `block in postpone'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:306:in `open'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:332:in `postpone'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:890:in `checking_for'
from /home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:1039:in `have_header'
from /home/pastelcorp/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10/ext/ruby/extconf.rb:37:in `<main>'
rake aborted!
Command failed with status (1): [cd 'buildout/ruby/ruby-2.0.0-x86_64-linux/...]
/home/pastelcorp/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10/build/ruby_extension.rb:55:in `block in <top (required)>'
/home/pastelcorp/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/home/pastelcorp/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => nginx => buildout/ruby/ruby-2.0.0-x86_64-linux//passenger_native_support.so => buildout/ruby/ruby-2.0.0-x86_64-linux//Makefile
(See full trace by running task with --trace)
It's saying that I must install development tools first.
but I already have done sudo apt-get install build-essential
and Here's my mkmf.log file(which I didn't understand at all)
" -o conftest -I/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-linux -I/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I/home/pastelcorp/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10/ext/ruby -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC -g conftest.c -L. -L/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib -Wl,-R/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic '-Wl,-rpath,/../lib' -Wl,-R -Wl,/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib -L/home/pastelcorp/.rvm/rubies/ruby-2.0.0-p247/lib -lruby -lpthread"
sh: 1: -o: not found
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
Any ideas about this?
Problem solved.
in RVM, I installed ruby2.0.0 with binary, not compiling source.
so I did
rvm remove 2.0.0 and rvm install 2.0.0 ----disable-binary
so ruby 2.0.0 has been compiled from source and passenger compiling works fine.
You have to install development tools first.
Most likely you're missing some libraries just like the error is indicating. I ran into the same thing a couple weeks back. Here is a nice tutorial similar to the one that helped me out.
http://alexpearce.me/2012/06/setting-up-a-vps/
With a little bit of luck, I believe that this line will solve your current issues, but be sure to look over the whole document.
sudo apt-get -y install curl git-core python-software-properties build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev libcurl4-openssl-dev
Also: I've also always had troubles when using rvm and have found that rbenv works with less hiccups, which is actually mentioned in this tutorial.
For databases, if you aren't using postgres then you should be able to just swap out the bits on database for the mysql equivalent libraries.

pg gem install error - lion osx, bundler, and rvm

I have spent way too many hours trying to fix this.
I reformatted my computer - clean snow leopard, than immediate upgrade to lion.
Xcode 4.2.1 installed
RVM installed
As I setup my environment I finally got to bundle install, and it failed trying to create the PG gem.
I had installed postgresql using macports (wasn't aware its preinstalled in lion). Following instructions here:http://benscheirman.com/2010/06/installing-postgresql-for-rails-on-mac-os-x And ran into more errors trying to install the pg gem:
Installing pg (0.12.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/me/.rvm/rubies/ruby-1.8.7-p357/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/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=/Users/sling31/.rvm/rubies/ruby-1.8.7-p357/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 /Users/me/.rvm/gems/ruby-1.8.7-p357/gems/pg-0.12.0 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-1.8.7-p357/gems/pg-0.12.0/ext/gem_make.out
An error occured while installing pg (0.12.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.0'` succeeds before bundling.
I've searched stackoverflow nonstop, and pretty much tried everything.
I removed the macports version, and then decided to try installing with homebrew:
"brew install postgresql"
pg_config gives me:
BINDIR = /usr/local/Cellar/postgresql/9.1.2/bin
DOCDIR = /usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql
HTMLDIR = /usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql
INCLUDEDIR = /usr/local/Cellar/postgresql/9.1.2/include
PKGINCLUDEDIR = /usr/local/Cellar/postgresql/9.1.2/include
INCLUDEDIR-SERVER = /usr/local/Cellar/postgresql/9.1.2/include/server
LIBDIR = /usr/local/Cellar/postgresql/9.1.2/lib
PKGLIBDIR = /usr/local/Cellar/postgresql/9.1.2/lib
LOCALEDIR = /usr/local/Cellar/postgresql/9.1.2/share/locale
MANDIR = /usr/local/Cellar/postgresql/9.1.2/share/man
SHAREDIR = /usr/local/Cellar/postgresql/9.1.2/share/postgresql
SYSCONFDIR = /usr/local/Cellar/postgresql/9.1.2/etc
PGXS = /usr/local/Cellar/postgresql/9.1.2/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--disable-debug' '--prefix=/usr/local/Cellar/postgresql/9.1.2' '--enable-thread-safety' '--with-bonjour' '--with-gssapi' '--with-krb5' '--with-openssl' '--with-libxml' '--with-libxslt' '--with-python' '--with-perl' '--with-ossp-uuid' '--datadir=/usr/local/Cellar/postgresql/9.1.2/share/postgresql' '--docdir=/usr/local/Cellar/postgresql/9.1.2/share/doc/postgresql' 'ARCHFLAGS='''-arch x86_64'''' 'CC=/usr/bin/llvm-gcc' 'CFLAGS=-O3 -w -pipe -march=core2 -msse4.1 -I/opt/local/include/ossp' 'LDFLAGS=-L/usr/local/Cellar/readline/6.2.2/lib -L/opt/local/lib' 'LIBS=-luuid' 'CPPFLAGS=-I/usr/local/Cellar/readline/6.2.2/include -I/usr/include/libxml2'
CC = /usr/bin/llvm-gcc
CPPFLAGS = -I/usr/local/Cellar/readline/6.2.2/include -I/usr/include/libxml2 -I/opt/local/include/libxml2
CFLAGS = -O3 -w -pipe -march=core2 -msse4.1 -I/opt/local/include/ossp -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv
CFLAGS_SL =
LDFLAGS = -L/usr/local/Cellar/readline/6.2.2/lib -L/opt/local/lib -L/opt/local/lib -Wl,-dead_strip_dylibs
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgport -lxslt -lxml2 -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lm -luuid
VERSION = PostgreSQL 9.1.2
I tried all of the export rvm_archflags="-arch x86_64" type solutions, but none seemed to make any difference.
Any ideas where I should begin?
I'm not familiar with Brew, but it looks like the pg_config you're invoking is not the one used to configure pg.
So, please try include /usr/local/Cellar/postgresql/9.1.2/bin (expect to have pg_config there) to the path and retry.
Actually, the output says "Using config values from /usr/local/bin/pg_config"
it should be the pg_config in the Brew's path. I guess it's in /usr/local/Cellar/postgresql/9.1.2/bin .
This might help: https://plus.google.com/104769575749979987265/posts/CVdrNMZYU9R
It does for Linux anyways.

Resources