Linux 即使使用 rvm pkg install zlib 也无法加载此类文件 - zlib
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9727908/
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
cannot load such file -- zlib even after using rvm pkg install zlib
提问by Razor Storm
I installed zlib package and ruby 1.9.3 using rvm, but whenever I try to install
gems it says
cannot load such file -- zlib
我使用 rvm 安装了 zlib 包和 ruby 1.9.3,但是每当我尝试安装 gems 时,它都会说
cannot load such file -- zlib
The commands I used to install are
我用来安装的命令是
$ rvm install 1.9.3
$ rvm pkg install zlib $ rvm reinstall 1.9.3 --with-readline-dir=/home/username/.rvm/usr \ --with-iconv-dir=/home/username/.rvm/usr \ --with-zlib-dir=/home/username/.rvm/usr \ --with-openssl-dir=/home/username/.rvm/usr $ rvm use 1.9.3 $ gem install heroku ERROR: Loading command: install (LoadError) cannot load such file -- zlib ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommand
All the help on this subject tells me to just do rvm pkg install zlib
, and
then reinstall the ruby with --with-zlib-dir=/home/username/.rvm/usr
, but this
didn't work.
有关此主题的所有帮助都告诉我只需执行rvm pkg install zlib
,然后使用 重新安装 ruby --with-zlib-dir=/home/username/.rvm/usr
,但这不起作用。
采纳答案by Razor Storm
I ended up installing zlib from apt-get and then reinstalling ruby to notuse the rvm directory for zlib.
我最终从 apt-get 安装 zlib,然后重新安装 ruby 以不使用 zlib 的 rvm 目录。
Here's how do:
操作方法如下:
$ sudo apt-get install zlib1g-dev
$ rvm reinstall 1.9.3
[Edit]As commenter @chrisfinne mentions, on CentOS/RedHat based systems:
[编辑]正如评论者@chrisfinne 提到的,在基于 CentOS/RedHat 的系统上:
$ sudo yum install zlib-devel
$ rvm reinstall 1.9.3
回答by mpapis
The both other responses were almost right...
其他两个回答几乎是正确的...
The rvm site for zlibprovides a quick fix!
On the top off the page is a "Quick fix" follow it's instructions, it will:
在页面顶部是“快速修复”,按照它的说明,它将:
- fix your installation,
- provide you instructions what to do to install zlib from your system
- and show how to reinstall ruby
- 修复您的安装,
- 为您提供从系统安装 zlib 的说明
- 并展示如何重新安装 ruby
回答by Kewin
rvm pkg install openssl && rvm pkg install zlib && rvm pkg install libyaml && rvm pkg install iconv rvm install 1.9.3-p0 --with-opt-dir=$HOME/.rvm/usr \ --with-libxml2-dir=/usr/local/Cellar/libxml2/2.7.8 \ --with-readline-dir=/usr/local/Cellar/readline/6.2.1
回答by Isaac Rabinovitch
Ruby has a bunch of package dependencies like the one on zlib-devel. They're nasty because there's nothing to indicate you need the library until get some obscure error message while trying to do something routine.
Ruby 有一堆包依赖,比如 zlib-devel 上的依赖。它们很糟糕,因为在尝试执行某些常规操作时收到一些模糊的错误消息之前,没有任何迹象表明您需要该库。
The solution is to use rvm. Use it even if you only need one version of ruby. Why? Because then you can do
解决方案是使用rvm。即使您只需要一个版本的 ruby,也可以使用它。为什么?因为那时你可以做到
rvm requirements
This will probe your particular OS and produce a set of commands you can copy back to the command line to install those missing packages.
这将探测您的特定操作系统并生成一组命令,您可以将其复制回命令行以安装那些丢失的软件包。
回答by mpapis
Use autolibs to install dependencies:
使用 autolibs 安装依赖项:
rvm autolibs enable
rvm reinstall 1.9.3
RVM will automatically install missing dependencies and use them for compiling ruby.
RVM 将自动安装缺少的依赖项并使用它们来编译 ruby。
More details on autolibs => http://rvm.io/rvm/autolibs
有关 autolibs 的更多详细信息 => http://rvm.io/rvm/autolibs
回答by belgoros
The solution that worked for me is described in rvm github repo, issue #3389.
rvm github repo, issue #3389 中描述了对我有用的解决方案。
Run
跑
rvm install 2.3.0 --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8
for ruby 2.3.0version.
对于 ruby 2.3.0版本。