安装 pg gem 失败,“mkmf.rb 找不到 ruby​​ 的头文件"(Mac OSX 10.6.5)

本文介绍了安装 pg gem 失败,“mkmf.rb 找不到 ruby​​ 的头文件"(Mac OSX 10.6.5)的处理方法,对大家解决问题具有一定的参考价值

问题描述

我刚刚升级到 Rails 3,在 MacPorts、gem 和数据库方面有些混乱需要整理.我扔掉了所有的宝石并重新安装它们.除了 pg gem 的要求外,一切似乎都很好.

I just upgraded to Rails 3 and had a bit of a mess with MacPorts, gems and databases to sort out. I threw out all the gems and installed them fresh. Everything seems to be OK except for the requirement of the pg gem.

创建一个新的 Rails 3 项目后,为 PostgreSQL 准备,服务器无法启动,抱怨缺少 pg gem.执行 bundle install,它运行了一段时间,当然,在 pg gem 上失败了.

After creating a new Rails 3 project, prepared for PostgreSQL, the server would not start, complaining about the missing pg gem. Doing bundle install, it chugged along for a while and, of course, fails on the pg gem.

Installing pg (0.10.0) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb 
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/pg-0.10.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.10.0/ext/gem_make.out
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `each'
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `build_extensions'
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:198:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `send'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/bin/bundle:13
    from /usr/bin/bundle:19:in `load'
    from /usr/bin/bundle:19

我在论坛和博客上发现的最常见的建议是(重新)安装 XCode 开发人员工具.它们已经在那里了,但我还是重新安装了它们,没有比上面更好的结果.

The most common suggestion I have found on forums and blogs is to (re)install the XCode developer tools. They were already there, but I reinstalled them anyway, with no better outcome than the above.

which ruby​​/usr/bin/rubyruby -vruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0],如果那里有任何线索的话.

which ruby says /usr/bin/ruby, and ruby -v says ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0], if there's any clue there.

欢迎指点.任何有助于解决此问题的缺失信息,我都会很乐意及时提供!

Pointers are welcome. Any missing information that would help figuring this out, I'll gladly and promptly provide!

我下载了 XCode,因为据说 DVD 版本已经坏了,而且有一段时间事情变得更好了.bundle install 开始谈论archflags",所以我这样做了:

I downloaded XCode since the DVD version is said to be broken and things went better for a while. bundle install started talking about "archflags" instead, so I did:

sudo env ARCHFLAGS="-arch i386" bundle install

一切似乎都很顺利,直到启动 Rails 时,他说:

and things seemed to go fine, until starting Rails barfed, saying:

/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle, 9): no suitable image found.  Did find: (LoadError)
    /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle

为了解决任何问题,我尝试了 bundle install,并将 archflags 设置为 -arch x86_64,但效果不佳:

Grappling for anything, I tried bundle install with archflags set to -arch x86_64, but it didn't go well:

*** Your PostgreSQL installation doesn't seem to have an architecture in common with the running ruby interpreter ([] vs. ["x86_64"])
I'll continue anyway, but if it fails, try setting ARCHFLAGS.
[...]
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***

libpq 是我现在必须通过一些标志提供路径的东西吗?还是我完全出去吃午饭了?

Is libpq something I now have to supply a path to via some flags? Or am I completely out to lunch?

推荐答案

一般来说,Postgres 的 gem 包想知道 pg_config 隐藏在哪里,以便询问 Postgres 的安装.

Generally the gem bundles for Postgres want to know where pg_config is hiding so they can ask about the Postgres installation.

使用 locate pg_config 查看您的 Mac 是否知道它的隐藏位置.

Use locate pg_config to see if your Mac knows where it's hiding.

我使用 mappstack 安装了 Postgres 的副本,所以我的 Mac 说在以下位置有一个副本:

I installed a copy of Postgres using mappstack, so my Mac says there's a copy at:

/Applications/mappstack-1.2-3/postgresql/bin/pg_config

另一个在:

/Library/PostgreSQL/9.0/bin/pg_config

我不记得在 /Library/PostgreSQL/9.0 安装过,所以可能是 Snow Leopard 预装的,或者是我工作量太大时安装的,可能使用 EnterpriseDB 中的 Postgres 安装程序.

I don't remember installing the one at /Library/PostgreSQL/9.0, so it might have been preinstalled by Snow Leopard, or I did it when under the influence of too much work, possibly using the Postgres installer from EnterpriseDB.

找到 pg_config 的位置后,尝试将该目录添加到 PATH 的开头,然后重新运行 gem 安装.或使用:

Once you've found the location of pg_config try adding that directory to the start of your PATH and then rerun the gem install. Or use:

export SQL_PATH=/Library/PostgreSQL/9.0
gem install pg -- --with-pg-config=$SQL_PATH/bin/pg_config

并尝试安装.如果其中任何一项工作都完成了.否则……

and try installing. If either of those work you're done. Otherwise...

安装程序可能想要的下一件事是访问 Postgres 标头,因此您查看 bin 目录的父目录,看看是否可以找到 include目录.

The next thing the installers might want are access to the Postgres headers, so you look in the parent of the bin directories, and see if you can find an include directory.

之后,在该目录中查找 lib 目录.一旦您知道了这些位置,您应该拥有设置环境变量以完成安装程序所需的一切.您需要阅读安装程序的 READMEINSTALL 文件并查看需要设置的内容.您将进行配置:

After that, look in that directory for a lib directory. Once you know those locations you should have all you need to set your environment variables to let the installer complete. You'll need to read the README or INSTALL file of the installer and see what needs to be set up. You'll be configuring:

export include_dir=$SQL_PATH/include/
export     lib_dir=$SQL_PATH/lib/
gem install pg -- --with-pgsql-include-dir=$include_dir --with-pgsql-lib-dir=$lib_dir

希望这会有所帮助.我的 Rails 3 和我的 Postgres 运行良好,使用了 mappstack Postgres 和 EnterpriseDB 版本,所以上面的信息应该能让你到达那里.

Hopefully that'll all help. I have Rails 3 and my Postgres running fine, using the mappstack Postgres and the EnterpriseDB versions, so the above info should get you there.

这篇关于安装 pg gem 失败,“mkmf.rb 找不到 ruby​​ 的头文件"(Mac OSX 10.6.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2

在SketchUp中需要rubygems

我一直试图在网上搜索如何在SketchUp中使用rubygems,但一直没有找到具体的方法。下面是我在C:programfilesgoogle SketchUp 8中的插件插件宝石.rb:$: (eval):14C:/Ruby186/lib/ruby/1.8/thread.rb:5C:/Ruby186/lib/ruby/site_ruby/1.8/rubygems.rb:11:in require\"C:/Ruby186/lib/ruby/site_ruby/1.8/rubygems.rb:11(eval)...

日期:2021-06-29 00:00:03 浏览:759

用rubyapi计算Sketchup中阴影面积的问题

有人能帮我吗?现在我正在Sketchup中开发一个关于构建模拟的插件。可以显示阴影,但如何使用ruby API计算其面积。阴影通常描述不完整的照明(半阴影),如曲面侧面的阴影渐变。如果要测量一个区域,可能需要完整的阴影。阴影不是SketchUp实体或绘图元素。它们正在渲染输出,不能(直接)通过API访问。请参阅此处的解决方案50,将阴影绘制为面(但是会修改用户模型),然后对这些面的面积求和。请记住,嵌套组件可以按比例缩小/变换(或向上),因此面区域看起来比实际大小更大(更小)。在这种情况下,使用第二个参数来...

日期:2021-08-19 22:00:05 浏览:830

如何在rubyonrails应用程序中集成谷歌SketchUp

嗨,我是一个RubyonRails应用程序,我想在我的应用程序中集成sketchup。如果可能,请分享这些步骤或一些文档链接。不完全可能。谷歌SketchUp(Google SketchUp)在2012已不复存在,不再受支持。(谷歌把它卖给Trimble Navigation,Inc.)SketchUp、SketchUp Make和SketchUp Pro(由@Last、谷歌和Trimble发布)的所有版本都是桌面应用程序。这些版本的EULA 1禁止在服务器环境中使用,并明确禁止将SketchUp转授给其他...

日期:2021-08-28 11:00:05 浏览:983

保存从Sketchup模型中的非内置ruby类创建的实例

我正在尝试为室内设计师和家具制造商编写一个插件来维护橱柜数据库。所有关于橱柜的信息都将存储在MySql数据库中。在将它们插入模型之前,将根据我编写的适当类在Ruby中创建它们的实例。其思想是:要在Ruby中创建文件柜的实例,在那里处理它们,并且只在Sketchup中绘制为类:Sketchup::Group。当然,我需要Ruby中的实例和Sketchup中的绘图之间的链接。我的问题是:如何/在哪里存储用Ruby创建的实例,以便在重新加载模型后可用和创建。您做过类似的事情吗??在Ruby中创建的实例已经存储在模...

日期:2021-09-17 13:00:03 浏览:580

如何在sketchup中使用ruby知道两个组件相互接触?

如果任何两个组件相互接触,那么我可以使用哪个功能来检查它??对于API没有精确的冲突检测方法。这在过去被要求……- Ruby API类别搜索:\"冲突检测\"请参阅这些找到的主题以讨论解决方法。qwertyuiop:相互接触可能您还应该指定更确切地说,哪一个意思是\"触摸\"?图像603×545 12.1 KB...

日期:2021-09-19 19:00:05 浏览:662

如何使用 selenium-webdriver (ruby) 使用相同的浏览器窗口进行自动化测试?

本文介绍了如何使用 selenium-webdriver (ruby) 使用相同的浏览器窗口进行自动化测试?的处理方法,对大家解决问题具有一定的参考价值 问题描述 我正在使用 ruby​​ 中的 selenium-webdriver 和 cucumber 为网站自动化测试用例.我需要每个功能以特定的顺序运行并使用相同的浏览...

日期:2022-06-28 02:00:31 浏览:575

使用 ruby​​ 生成格式为/etc/shadow 的 SHA512 crypt-style hashes?

本文介绍了使用 ruby​​ 生成格式为/etc/shadow 的 SHA512 crypt-style hashes?的处理方法,对大家解决问题具有一定的参考价值 问题描述 I want to generate SHA512 hashed passwords for inclusion directly into a /...

日期:2022-07-11 04:00:26 浏览:571

therubyracer 安装错误

本文介绍了therubyracer 安装错误的处理方法,对大家解决问题具有一定的参考价值 问题描述 如下所示,libv8 可以正常安装,但 ruby​​racer 不能.我使用的是 Mac 10.7.4.As you can see below, libv8 installs fine, but therubyracer ...

日期:2022-07-19 06:00:35 浏览:791

“在任何存储库中都找不到有效的 gem"(rubygame 等)

本文介绍了“在任何存储库中都找不到有效的 gem"(rubygame 等)的处理方法,对大家解决问题具有一定的参考价值 问题描述 我一直在尝试安装这个rubygame"gem,但每当我使用命令时I've been trying to install this 'rubygame' gem for some time, bu...

日期:2022-07-25 11:00:26 浏览:718

安装 pg gem 失败,“mkmf.rb 找不到 ruby​​ 的头文件"(Mac OSX 10.6.5)

本文介绍了安装 pg gem 失败,“mkmf.rb 找不到 ruby​​ 的头文件"(Mac OSX 10.6.5)的处理方法,对大家解决问题具有一定的参考价值 问题描述 我刚刚升级到 Rails 3,在 MacPorts、gem 和数据库方面有些混乱需要整理.我扔掉了所有的宝石并重新安装它们.除了 pg gem 的要求...

日期:2022-08-12 21:00:35 浏览:827