您的位置:首页 > 编程语言 > Ruby

源码安装ruby时 ERROR: Loading command: install (LoadError) cannot load such file -- zlib 解决方法

2018-04-04 11:23 691 查看
一、执行步骤
1、wget http://www.ruby-lang.org/en/downloads/ 下载最新版本源码,tar -zxvf 解压。
2、cd  ruby-2.5.1目录,执行 ./configure  、make  、makeinstall等命令。
3、ruby -v可查看到版本信息。
4、执行gem install --no-rdoc --no-ri tprov,报错如下:
ERROR:  Loading command: install (LoadError) cannot load such file -- zlib

ERROR:  While executing gem ... (NoMethodError)    undefined method `invoke_with_build_args' for nil:NilClass
二、找解决方法

1、cd ruby-2.5.1/ext/zlib目录,执行 ruby ./extconf.rb、make 、make install命令。
2、make时报错(chmod +x Makefile):make: *** No rule to make target `/include/ruby.h', needed by `zlib.o'.  Stop.
3、更改Makefile文件, zlib.o: $(top_srcdir)/include/ruby.h  改成   zlib.o: ../../include/ruby.h;到这里就可以make成功了。
4、进入/ruby-2.5.1/ext/openssl目录执行 ruby ./extconf.rb、make 、make install命令。

5、yum install zlib-devel && rvm reinstall 2.5.1
6、这里提示-bash: rvm: command not found,然后执行 curl -L get.rvm.io | bash -s stable,报错为gpg: Can't check signature: No public key,然后执行了gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3,再执行curl -L get.rvm.io | bash -s stable,到这里rvm安装成功!
7、然后提示执行source /etc/profile/rvm.sh,执行后rvm -v可以正常输出了。
8、执行gem install --no-rdoc --no-ri tprov,此时就可以成功了。

参考了: https://stackoverflow.com/questions/9727908/cannot-load-such-file-zlib-even-after-using-rvm-pkg-install-zlib http://rensanning.iteye.com/blog/1927921
等等
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐