简体   繁体   English

错误:无法在OSX 10.9.4上构建gem本机扩展(捆绑安装)

[英]ERROR: Failed to build gem native extension (bundle install) on OSX 10.9.4

Running: OSX 10.9.4, Ruby 2.1.5, Rails 4.1.8 (but, 4.1.6 in the project subfolder) 运行:OSX 10.9.4,Ruby 2.1.5,Rails 4.1.8(但项目子文件夹中的4.1.6)

Am having a problem with installing gems within a project subfolder. 在项目子文件夹中安装gem时遇到问题。 Bundle install seems to fail at jquery-rails 3.1.2. 捆绑安装似乎在jquery-rails 3.1.2上失败。 Couldn't find a solution on Stackoverflow, so asking if anyone knows how to remedy? 在Stackoverflow上找不到解决方案,因此请问是否有人知道如何解决?

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: 而且,这是我检查Rails版本时的输出:

 Macintosh:rails-2 asanchez$ rails --version Rails 4.1.6 Macintosh:rails-2 asanchez$ cd .. Macintosh:Projects asanchez$ rails --version Rails 4.1.8 

The problem is a common one on Macs (at least in my experience). 这个问题是Mac上的常见问题(至少以我的经验)。 The long and short of it is that it cannot find the config file for the PosgreSQL install on your system. 它的长短之处在于它无法在您的系统上找到PosgreSQL安装的配置文件。

When I add the pg gem for the first time (ie, after installing an upgraded version of Ruby), I use the following: 当我第一次添加pg gem时(即,在安装了Ruby的升级版本之后),我使用以下命令:

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. 请注意,我使用Postgres Mac应用程序是因为它比手动安装或通过Homebrew安装PG容易得多。 Current versions no longer have the 93 in the app name. 当前版本的应用名称中不再包含93。

Regardless of how you installed PostgreSQL, you need to point rubygems to the right config file for PG or it will not install. 无论如何安装PostgreSQL,都需要将rubygems指向PG的正确配置文件,否则它将无法安装。

Also, do not install this one via Bundler. 另外,请勿通过Bundler安装此设备。 That has never worked for me. 那对我从来没有用过。 I've always had to use the gem install command. 我一直不得不使用gem install命令。 Then, when I run bundle xxxxx it never fails. 然后,当我运行bundle xxxxx它永远不会失败。

Hope that helps! 希望有帮助!

It looks like it's actually failing at the pg gem (postgres). 看起来它实际上在pg gem(postgres)上失败了。

You have to install postgres manually the first time, so try running gem install postgres separately. 您必须在第一次时手动安装postgres,因此请尝试单独运行gem install postgres。

Another option, if that is slowing you down, is to open your gemfile and put postgres in the production group. 如果这让您放慢了速度,那么另一个选择是打开您的gemfile并将postgres放入生产组中。 You can use sqlite 3 while you're getting used to rails, then worry about PG later. 您可以在习惯Rails的同时使用sqlite 3,然后再担心PG。 To put it in its own group, open your Gemfile and put pg in its own group: 要将其放入自己的组中,请打开您的Gemfile并将pg放入其自己的组中:

group :assets do
  gem 'pg'
end

And run "bundle install --without-production" 并运行"bundle install --without-production"

Alternatively you can run bundle install --without-pg , but note that both of these ways are kind of hacky. 另外,您也可以运行bundle install --without-pg ,但是请注意,这两种方式都是很棘手的。 Use them if you want to get a quick start, then worry about your environment later. 如果您想快速入门,请使用它们,然后再担心您的环境。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 套件安装错误:错误:无法建立gem本机扩展 - Bundle install error : ERROR: Failed to build gem native extension $ bundle install:无法构建gem原生扩展 - $ bundle install: Failed to build gem native extension 捆绑安装失败,原因是:Gem::Ext::BuildError: ERROR: Failed to build gem native extension - Bundle Install failed due to : Gem::Ext::BuildError: ERROR: Failed to build gem native extension 捆绑软件安装失败(错误:安装nokogiri时出错:错误:无法构建gem本机扩展) - bundle install failed (ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension) 捆绑安装:错误:无法构建gem原生扩展。 nio4r宝石 - Bundle install: ERROR: Failed to build gem native extension. nio4r gem 运行捆绑软件安装时“无法构建gem native扩展” - 'Failed to build gem native extension' when running bundle install gem install rails构建错误无法构建gem本机扩展 - gem install rails build error failed to build gem native extension Bundle install导致:Gem :: Ext :: BuildError:错误:无法构建gem原生扩展。 ... make install failed,退出代码2 - Bundle install results in: Gem::Ext::BuildError: ERROR: Failed to build gem native extension. … make install failed, exit code 2 为什么在运行“捆绑安装”时会出现无法构建 gem 原生扩展错误 pg (0.8.0)? - Why do I get a Failed to build gem native extension error, pg (0.8.0), while running 'bundle install'? gem install:错误:无法构建gem原生扩展 - gem install: ERROR: Failed to build gem native extension
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM