ruby-on-rails - 无法运行命令——rake :install

标签 ruby-on-rails ruby rubygems rake pg

当我运行命令rake:install时,我收到以下错误消息:

WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
    at /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
  Successfully built RubyGem
  Name: mysql2psql
  Version: 0.1.0
  File: mysql2psql-0.1.0.gem
Executing "ruby -S gem install ./pkg/mysql2psql-0.1.0.gem":
ruby -S gem install ./pkg/mysql2psql-0.1.0.gem
Building native extensions.  This could take a while...
ERROR:  Error installing ./pkg/mysql2psql-0.1.0.gem:
    ERROR: Failed to build gem native extension.

        /Users/adam/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for pg_config... no

  ===========   WARNING   ===========

  You are building this extension on OS X without setting the 
  ARCHFLAGS environment variable, and pg_config wasn't found in 
  your PATH. If you are seeing this message, that means that the 
  build will probably fail.

  If it does, you can correct this by either including the path 
  to 'pg_config' in your PATH or setting the environment variable 
  ARCHFLAGS to '-arch <arch>' before building.

  For example:
  (in bash) $ export PATH=/opt/local/lib/postgresql84/bin:$PATH                  
            $ export ARCHFLAGS='-arch x86_64'
  (in tcsh) % set path = ( /opt/local/lib/postgresql84/bin $PATH )
            % setenv ARCHFLAGS '-arch x86_64'

  Then try building again.

  ===================================

MacOS X build: fixing architecture flags:
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/radek/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
    --with-pg
    --without-pg
    --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
    --enable-static-build
    --disable-static-build


Gem files will remain installed in /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.9.0 for inspection.
Results logged to /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.9.0/ext/gem_make.out
rake aborted!
Command failed with status (1): [ruby -S gem install ./pkg/mysql2psql-0.1.0...]

Tasks: TOP => install
(See full trace by running task with --trace)

显然是 pg gem 中的问题,但是当我检查应用程序中已安装的 gem 列表时,发现有 * pg (0.13.2)

那么我还缺少什么?

最佳答案

上述问题的解决方案:

 1. export PATH=/Library/PostgreSQL/9.1/bin:$PATH
 2. export ARCHFLAGS='-arch x86_64'
 3. rake install

关于ruby-on-rails - 无法运行命令——rake :install,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9757813/

相关文章:

ruby - 用每个可能的值填充散列中的通配符值

windows - Gem Charlock_holmes 在 Windows XP 上安装错误

ruby-on-rails - rails : Creating new Ruby on Rails app in existing directory

ruby-on-rails - Rails,后部署到 Heroku : unable to run console, db:migrate

javascript - UI Bootstrap 破坏 angularjs post 请求

jquery - 找不到 'jquery-ui' Rails 3.2

ruby-on-rails - Ruby 使用 FbGraph gem::获取 friend 的电子邮件地址

ruby-on-rails - 使用触发器进行 Rails 测试

ruby - 如何前置类方法

ruby-on-rails - 如何在 Rails 的 json_response 中显示所有关联项