2014-10-09 3 views
0

Я в последнем уроке моего первого урока RoR, и я направлен, чтобы открыть терминал и ввести install bundleОшибки при установке обоего PG и Bundle

Результат:

tonys-mbp:crumblr Tony-MBP$ bundle install 
Fetching gem metadata from https://rubygems.org/.......... 
Resolving dependencies... 
Using rake 10.3.2 
Using i18n 0.6.11 
Using json 1.8.1 
Using minitest 5.4.2 
Using thread_safe 0.3.4 
Using tzinfo 1.2.2 
Using activesupport 4.1.6 
Using builder 3.2.2 
Using erubis 2.7.0 
Using actionview 4.1.6 
Using rack 1.5.2 
Using rack-test 0.6.2 
Using actionpack 4.1.6 
Using mime-types 2.4.1 
Using mail 2.6.1 
Using actionmailer 4.1.6 
Using activemodel 4.1.6 
Using arel 5.0.1.20140414130214 
Using activerecord 4.1.6 
Using bundler 1.7.3 
Using coffee-script-source 1.8.0 
Using execjs 2.2.1 
Using coffee-script 2.3.0 
Using thor 0.19.1 
Using railties 4.1.6 
Using coffee-rails 4.0.1 
Using hike 1.2.3 
Using multi_json 1.10.1 
Using jbuilder 2.2.2 
Using jquery-rails 3.1.2 
/Users/Tony-MBP/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.3/lib/bundler.rb:302: warning: Insecure world writable dir /usr/local in PATH, mode 040777 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    /Users/Tony-MBP/.rvm/rubies/ruby-2.1.3/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 
    --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/Tony-MBP/.rvm/rubies/ruby-2.1.3/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/Tony-MBP/.rvm/gems/ruby-2.1.3/gems/pg-0.17.1 for inspection. 
Results logged to /Users/Tony-MBP/.rvm/gems/ruby-2.1.3/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. 

Поэтому я попытался установить pg, чтобы продолжить работу с Bundler; Однако, я получаю эту ошибку, когда я вход: gem install pg -v '0.17.1':

Результат:

tonys-mbp:crumblr Tony-MBP$ gem install pg 
Building native extensions. This could take a while... 
/Users/Tony-MBP/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/ext/builder.rb:73: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
ERROR: Error installing pg: 
    ERROR: Failed to build gem native extension. 

    /Users/Tony-MBP/.rvm/rubies/ruby-2.1.3/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 
    --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/Tony-MBP/.rvm/rubies/ruby-2.1.3/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/Tony-MBP/.rvm/gems/ruby-2.1.3/gems/pg-0.17.1 for inspection. 
Results logged to /Users/Tony-MBP/.rvm/gems/ruby-2.1.3/extensions/x86_64-darwin-13/2.1.0/pg-0.17.1/gem_make.out 

Может кто-нибудь, пожалуйста, помогите определить, почему оба они терпят неудачу? Благодарим за помощь в создании нового новичка в его детстве разработчика.

Edit:

После попытки предложенный код из @Lidan, это то, что я получаю:

Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config' 
    This could take a while... 
    /Users/Tony-MBP/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/ext/builder.rb:73: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
    ERROR: Error installing pg: 
     ERROR: Failed to build gem native extension. 

ответ

0

После дальнейших исследований OS X Mavericks не играла красиво с драгоценными камнями pg или bundle.

Четыре шага исправить, что работает для меня:

brew update 
brew install postgresql 
gem install pg 
bundle install 
1

Это сообщение об ошибке указывает, что pg_config отсутствует, и вы должны пройти в путь к файлу pg_config , большую часть времени этот файл будет находиться в папке установки Postgres.

Однако, если вы используете Postgres.app для запуска локального сервера Postgres при выполнении работ по разработке, этот файл будет отсутствовать, поскольку postgres.app - автономное приложение. попробуйте переустановить камень с помощью:

$ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config 

Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config' 
This could take a while... 
Successfully installed pg-0.17.1 
1 gem installed 

Я рекомендую использовать Postgres.app, потому что при установке Postgres через brew install postgresql, сервис Postgres работает в фоновом режиме и использует память, даже если вы не развиваетесь или с помощью базы данных. По моему опыту, Postgres.app более эффективен для сред разработки OSX.

Смежные вопросы