ruby中的错误:无法加载此类文件 - zlib

时间:2013-02-06 13:14:17

标签: ruby linux rvm

当我尝试在Ubuntu 12.10中安装rails时出现此错误:

$ gem install rails
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand

所以我完全删除了rvm:

rvm implode
sudo rm -rf ~/.rvm

删除了.bashrc.bash_profile

中的脚本调用

并检查它们是否真的被删除了:

env | grep rvm #no output, so rvm is removed
ruby -v #The program 'ruby' can be found in the following packages: blabla

我已经通过sudo apt-get install:

curl zlib1g-dev zlib1g libssl-dev build-essential openssl libreadline6 libreadline6-dev curl git-core libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

然后从头开始安装

curl -L https://get.rvm.io | bash -s stable --ruby --auto-dotfiles

然后运行该行并重新启动终端关于此消息:

  * To start using RVM you need to run `source /home/adige/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

然后rvm pkg install readline,但错误完成:

...
Error running 'autoreconf -is --force', please read /home/adige/.rvm/log/readline/autoreconf.log
...
Please note that it's required to reinstall all rubies:

    rvm reinstall all --force

我认为无论如何都安装好了吧?在重新安装所有红宝石之前,我当然安装了zlib:

# w/out verify, it gives checksum error
rvm pkg install zlib --verify-downloads 1

然后再次运行rvm reinstall all --force并完成错误:

...
Install of ruby-1.9.3-p374 - #complete 
Making gemset ruby-1.9.3-p374 pristine.
Error running '' under ,
please read /home/adige/.rvm/log/ruby-1.9.3-p374/gemset.pristine.log
Making gemset ruby-1.9.3-p374@global pristine.

gemset.pristine.log

然后用zlib支持重新安装ruby:

rvm reinstall 1.9.3-p374 --with-zlib-dir=$rvm_path/usr

返回相同的错误和same log,但无论如何都已完成。

最后我尝试再次安装rails gem,但cannot load such file -- zlib

以下是rvm info

我做错了什么?

1 个答案:

答案 0 :(得分:1)

您不应在ubuntu上安装readline / zlib,请按以下步骤操作:

rvm get head
rvm pkg remove
rvm requirements run force
rvm reinstall 1.9.3-p374

如果失败,请确保包含安装过程的输出,还包括所有提到的日志文件