有没有人尝试安装 ruby & Ubuntu(最好是 Ubuntu 9)上的 rubygems 源代码?
Ruby on Rails 网站建议在 Linux 下从源代码安装 Ruby。 我在全新安装的 Ubuntu 9 上从源代码构建 ruby 时遇到了许多 C 库问题。
我在网上找到的有关在 Ubuntu 上安装 ruby 的所有说明都涉及使用预打包(基于 .deb)的 ruby。 显然这不是 Rails 人们所推荐的。
当我对 ruby 进行干净的源代码构建时,我发现 Rubygems 无法安装,因为 zlib 扩展不起作用。
出现两个问题:
1) 未构建 zlib 扩展。
解决方案:
i) 确保在 ruby 源的 extn 目录中的安装文件中取消注释 zlib,并且
ii) 确保安装了这些 zlib ubuntu 软件包:
aptitude install zlib1g
aptitude install zlib1g-dbg
aptitude install zlib1g-dev
aptitude install zlibc
2) 修复上述问题 1(并彻底重建 ruby)后,zlib仍然无法工作,因为扩展无法加载。
您可以看到,通过运行此命令并获取输出“false”,该模块无法加载:
puts require 'zlib'
我观察到这种情况发生在 extn 目录中的任意数量的其他 C 扩展上,因此这似乎是这些扩展的一个更普遍的问题,而不仅仅是zlib 特定的东西。
总结一下:
- 我的 ruby 构建找到了 ruby 特定的 C zlib 扩展,但无法加载 zlib 模块。
- /extn 中的其他扩展似乎也会发生此行为。
有没有办法找出模块加载失败的原因? 某种跟踪/详细模式?
The Ruby on Rails website recommends installing Ruby from source under Linux.
I encountered a number of C library problems building ruby from source on a clean install of Ubuntu 9.
All the instructions I found on the net about installing ruby on Ubuntu have involved using the prepackaged (.deb-based) ruby. Clearly this isn't what the rails people recommend.
When I did a clean source build of ruby I found Rubygems failed to install because the zlib extension didn't work.
Two problems occur:
1) The zlib extension isn't built.
Solution:
i) ensure zlib is uncommented in the Setup file within the extn directory of the ruby source, and
ii) ensure these zlib ubuntu packages are installed:
aptitude install zlib1g
aptitude install zlib1g-dbg
aptitude install zlib1g-dev
aptitude install zlibc
2) After fixing Problem 1 above (and doing a clean rebuild of ruby), zlib still doesn't work because the extension fails to load.
You can see that the module fails to load by running this and getting the output "false":
puts require 'zlib'
I observed this happens to any number of other C extensions in the extn directory, so it appears to be a more general problem with these extensions than just something zlib-specific.
To summarize:
- My build of ruby finds the ruby-specific C zlib extension but it fails to load the zlib module.
- This behaviour appears to happen to other extensions in /extn.
Is there a way I can find out why a module fails to load? some kind of trace/verbose mode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是我在 Ubuntu 11.04 上安装 ruby、gems 和 Rails 的操作
从源安装 ruby
从源安装 RubyGems
Here is what I did to install ruby, gems and rails on Ubuntu 11.04
Install ruby from sources
Install RubyGems from sources
我不明白你的问题是什么。 您说
require 'zlib'
返回false
。 但这意味着它确实有效! 如果出现错误,您将收到LoadError
异常。I don't see what your problem is. You say that
require 'zlib'
returnsfalse
. But that means that it did work! If there were an error, you would get aLoadError
exception.你安装了
libzlib-ruby
吗? 这是我在安装 Rubygems 之前典型的 Ubuntu 初始化:Did you install
libzlib-ruby
? Here's my typical Ubuntu initialization before installing Rubygems: