Ruby-on-rails 在 zlib 上安装 Ubuntu rails 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/769496/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ubuntu rails install fails on zlib
提问by Paul
I've just moved over to Ubuntu 8.10 as my dev box; it's my first serious foray into Linux as a daily-use OS, and I'm having a hard time getting Rails going. I have followed a number of tutorials which all seem to work fine, but when I try and use gem install or gem update on anything, I get an error that looks like this:
我刚刚转移到 Ubuntu 8.10 作为我的开发箱;这是我第一次认真地尝试将 Linux 作为日常使用的操作系统,而且我很难让 Rails 运行起来。我遵循了许多似乎都可以正常工作的教程,但是当我尝试在任何东西上使用 gem install 或 gem update 时,我收到一个如下所示的错误:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:5
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:167:in `load_and_instantiate'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:88:in `[]'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:144:in `find_command'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:131:in `process_args'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:102:in `run'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:58:in `run'
from /usr/local/bin/gem:21
I have (as recommended in the tutorials) installed zlib, zlib1g, and zlib1g-dev. I've even found a few tutorials on this particular problem (all for flavors other than mine, however) but they didn't help.
我已经(按照教程中的建议)安装了 zlib、zlib1g 和 zlib1g-dev。我什至找到了一些关于这个特定问题的教程(然而,所有这些都适用于我以外的其他口味),但它们没有帮助。
I'm on Ubuntu 8.10, ruby version 1.8.8dev gem version 1.3.2
我在 Ubuntu 8.10,ruby 版本 1.8.8dev gem 版本 1.3.2
I've tried reinstalling ruby and gems each and separately, to no avail.
我试过分别重新安装 ruby 和 gems,但无济于事。
回答by JosephL
If you come across this question trying to install Ruby using Ruby Version Manager (RVM) on Ubuntu 10.04 then there are instructions on installing zlib on the rvm web site http://rvm.beginrescueend.com/packages/zlib/
如果您在 Ubuntu 10.04 上尝试使用 Ruby 版本管理器 (RVM) 安装 Ruby 时遇到这个问题,那么 rvm 网站上有关于安装 zlib 的说明http://rvm.beginrescueend.com/packages/zlib/
The steps are:
步骤是:
rvm pkg install zlib
(or rvm package install zlibif you get "ERROR: Unrecognized command line argument: 'pkg'" - older versions of rvm used the verb 'package' instead)
(或者,rvm package install zlib如果您收到“错误:无法识别的命令行参数:'pkg'” - 较旧版本的 rvm 使用动词 'package' 代替)
then
然后
rvm remove 1.9.1
rvm install 1.9.1
回答by AdrianVeidt
I am using Ubuntu 10.04 (Lucid), i wanted to install ruby 1.9.2 because 1.9.1 is not recommended with Rails. So I downloaded the source for 1.9.2 and unzipped/unarchived it. my source distro is ruby-1.9.2-p0. After I unpacked it, I built zlib as follows:
我使用的是 Ubuntu 10.04 (Lucid),我想安装 ruby 1.9.2,因为 Rails 不推荐 1.9.1。所以我下载了 1.9.2 的源代码并解压/解压了它。我的源发行版是 ruby-1.9.2-p0。解压后,我构建了zlib,如下所示:
cd ruby-1.9.2-p0/ext/zlib
ruby extconf.rb
make
sudo make install
sudo gem install rails
that fixed the problem. This is similar to what other people posted above, but not exactly, so I figured I may as well post exactly what I did to get it going.
解决了这个问题。这与上面其他人发布的内容类似,但不完全相同,所以我想我最好发布一下我为让它运行所做的工作。
回答by Daniel
I have the same problem in CentOS and fix it by executing the following command:
我在 CentOS 中遇到了同样的问题,并通过执行以下命令来修复它:
First, I ensure that zlib and zlib-devel exist (like many suggested above).
首先,我确保 zlib 和 zlib-devel 存在(就像上面建议的许多)。
yum install zlib zlib-devel
Second, I recompiled and installed the sources of zlib that comes with ruby.
其次,我重新编译安装了ruby自带的zlib源码。
cd /home/myname/installers/ruby-1.8.7-p174/ext/zlib/
ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
make
make install
That commands seem to fix the problem, then I execute gem update --systemand the error with zlib vanished. Then I install rails with gem install rails. Note to mention I had installed gem before, and after recompile and install zlib, I don't recompile neither install gem (actually I don't knew how uninstall it because I don't found a script to do that)
该命令似乎解决了问题,然后我执行gem update --system了 zlib 的错误消失了。然后我用 gem install rails 安装 rails。请注意,我之前安装了 gem,重新编译并安装 zlib 后,我没有重新编译 install gem(实际上我不知道如何卸载它,因为我没有找到执行此操作的脚本)
That works for me...hope to you to.
这对我有用...希望你能。
Regards.
问候。
回答by Dan
try
尝试
aptitude install zlib1g-dev
Then go about your business.
然后去处理你的事情。
回答by Knowself
I really didn't like any of these answers ... none really focused on the users actual needs and question ... just people telling what they did ... no context and it didn't even work for me ...
我真的不喜欢这些答案中的任何一个......没有一个真正关注用户的实际需求和问题......只是人们告诉他们他们做了什么......没有上下文,它甚至对我不起作用......
So, ..
所以, ..
I'm installing a new box Ubuntu 8.04 LTS 64-bit ...
我正在安装一个新的盒子 Ubuntu 8.04 LTS 64 位 ...
So, I ...
所以我 ...
cd ~
wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
tar -xvvf ruby-1.9.2-p180.tar.gz
cd ruby-*
./configure
make
install
sudo make install
And then I have this problem with ...
然后我有这个问题......
gem list
it doesn't work ... something about zLib not found crap ...
它不起作用......关于zLib的东西没有找到废话......
So, I actually READ the README and find that I need to edit a file ...
所以,我实际上阅读了自述文件,发现我需要编辑一个文件......
[my ruby source directory]/ext/Setup
and UN-COMMENT the line with zLib in it ... by removing the "#" in the first column
并取消注释带有 zLib 的行...通过删除第一列中的“#”
Then I run the commands again ... included here for reference ...
然后我再次运行命令......包括在这里以供参考......
./configure
make
install
sudo make install
and all is well ... it's logical ... and is devoid of "rvm" and other ... "just install more stuff to make it work" type solutions.
一切都很好......这是合乎逻辑的......并且没有“rvm”和其他......“只需安装更多东西以使其工作”类型的解决方案。
Joet
乔特
回答by Saurabh
Just goto Ruby Source Package , Unzip it.
只需转到 Ruby Source Package ,解压它。
Goto /your-ruby-dir/ext/zlib
转到 /your-ruby-dir/ext/zlib
ruby extconf.rb
make
sudo make install
If the packages are missing it will tell you, mainly libzlib related packages
如果包丢失它会告诉你,主要是libzlib相关的包
Regards
问候
Saurabh
索拉布
回答by Rod McLaughlin
rvm package install zlib
rvm remove 1.9.1
rvm install 1.9.1
That did it. After numerous wild goose chases, I'm glad I found this page.
做到了。经过无数次的追逐,我很高兴找到了这个页面。
回答by Paul
yes, and that didn't do the job either. Got this from another source, this finally did it for me where the other stuff failed.
是的,这也不起作用。从另一个来源得到这个,这终于为我做了其他事情失败的地方。
wget http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.6.0.tar.gz
tar xvzf ruby-zlib-0.6.0.tar.gz
cd ruby-zlib-0.6.0
ruby extconf.rb && make
sudo make install
Reinstall ruby gems from source
从源重新安装 ruby gems
Thanks anyway, guys.
无论如何,谢谢,伙计们。
回答by nkassis
Did you try apt-get install libzlib-ruby?
你试过 apt-get install libzlib-ruby 吗?
Also install rubygems from rubyforge. I don't like the rubygems package in Ubuntu.
还要从 rubyforge 安装 rubygems。我不喜欢 Ubuntu 中的 rubygems 包。
回答by Don Werve
The problem is that Ruby on Ubuntu isn't built against zlib; you'll want to do a source build to install Ruby. You can do this with apt-get source -b ruby
问题是 Ubuntu 上的 Ruby 不是针对 zlib 构建的。您需要进行源代码构建以安装 Ruby。你可以这样做apt-get source -b ruby

