Reputation: 1
Running: OSX 10.9.4, Ruby 2.1.5, Rails 4.1.8 (but, 4.1.6 in the project subfolder)
Am having a problem with installing gems within a project subfolder. Bundle install seems to fail at jquery-rails 3.1.2. Couldn't find a solution on Stackoverflow, so asking if anyone knows how to remedy?
Here's the output:
Macintosh:~ asanchez$ cd Projects
Macintosh:Projects asanchez$ ls
rails-2
Macintosh:Projects asanchez$ cd rails-2
Macintosh:rails-2 asanchez$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Installing rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.3
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Installing activesupport 4.1.6
Using builder 3.2.2
Using erubis 2.7.0
Installing actionview 4.1.6
Using rack 1.5.2
Using rack-test 0.6.2
Installing actionpack 4.1.6
Using mime-types 2.4.3
Using mail 2.6.3
Installing actionmailer 4.1.6
Installing activemodel 4.1.6
Using arel 5.0.1.20140414130214
Installing activerecord 4.1.6
Installing sass 3.2.19
Installing bootstrap-sass 3.3.1.0
Installing coffee-script-source 1.8.0
Installing execjs 2.2.2
Installing coffee-script 2.3.0
Using thor 0.19.1
Installing railties 4.1.6
Installing coffee-rails 4.0.1
Installing font-awesome-sass 4.2.2
Using hike 1.2.3
Using multi_json 1.10.1
Installing jbuilder 2.2.5
Installing jquery-rails 3.1.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/asanchez/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20141202-33892-1jyqcz2.rb 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
--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/asanchez/.rvm/rubies/ruby-2.1.5/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
extconf failed, exit code 1
Gem files will remain installed in /Users/asanchez/.rvm/gems/ruby-2.1.5/gems/pg-0.17.1 for inspection.
Results logged to /Users/asanchez/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
And, here's the output when I check for Rails versions:
Macintosh:rails-2 asanchez$ rails --version
Rails 4.1.6
Macintosh:rails-2 asanchez$ cd ..
Macintosh:Projects asanchez$ rails --version
Rails 4.1.8
Upvotes: 0
Views: 485
Reputation: 63
It looks like it's actually failing at the pg gem (postgres).
You have to install postgres manually the first time, so try running gem install postgres separately.
Another option, if that is slowing you down, is to open your gemfile and put postgres in the production group. You can use sqlite 3 while you're getting used to rails, then worry about PG later. To put it in its own group, open your Gemfile and put pg in its own group:
group :assets do
gem 'pg'
end
And run "bundle install --without-production"
Alternatively you can run bundle install --without-pg
, but note that both of these ways are kind of hacky. Use them if you want to get a quick start, then worry about your environment later.
Upvotes: 1
Reputation: 5598
The problem is a common one on Macs (at least in my experience). The long and short of it is that it cannot find the config file for the PosgreSQL install on your system.
When I add the pg
gem for the first time (i.e., after installing an upgraded version of Ruby), I use the following:
gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
Note that I use the Postgres Mac app as I find it far easier than installing PG manually or via Homebrew. Current versions no longer have the 93 in the app name.
Regardless of how you installed PostgreSQL, you need to point rubygems to the right config file for PG or it will not install.
Also, do not install this one via Bundler. That has never worked for me. I've always had to use the gem install
command. Then, when I run bundle xxxxx
it never fails.
Hope that helps!
Upvotes: 1