Ruby安装redis过程中,当执行下面命令:

[root@ip-172 rubygems-3.0.3]# ruby setup.rb
Bundler 1.17.3 installed
RubyGems 3.0.3 installed
Traceback (most recent call last):
	14: from setup.rb:41:in `<main>'
	13: from /usr/local/rubygems-3.0.3/lib/rubygems/gem_runner.rb:59:in `run'
	12: from /usr/local/rubygems-3.0.3/lib/rubygems/command_manager.rb:148:in `run'
	11: from /usr/local/rubygems-3.0.3/lib/rubygems/command_manager.rb:178:in `process_args'
	10: from /usr/local/rubygems-3.0.3/lib/rubygems/command.rb:321:in `invoke_with_build_args'
	 9: from /usr/local/rubygems-3.0.3/lib/rubygems/commands/setup_command.rb:176:in `execute'
	 8: from /usr/local/rubygems-3.0.3/lib/rubygems/commands/setup_command.rb:617:in `regenerate_binstubs'
	 7: from /usr/local/rubygems-3.0.3/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
	 6: from /usr/local/rubygems-3.0.3/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
	 5: from /usr/local/rubygems-3.0.3/lib/rubygems/commands/pristine_command.rb:3:in `<top (required)>'
	 4: from /usr/local/rubygems-3.0.3/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
	 3: from /usr/local/rubygems-3.0.3/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
	 2: from /usr/local/rubygems-3.0.3/lib/rubygems/package.rb:47:in `<top (required)>'
	 1: from /usr/local/rubygems-3.0.3/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/rubygems-3.0.3/lib/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- zlib (LoadError)

出现上面的异常信息。

验证Ruby的version,ruby是成功安装的。

导致此问题的原因可能是没有安装zlib-devel

yum -y install zlib-devel

进入ruby源码文件夹,安装ruby自身提供的zlib包

cd ruby-2.6.0/ext/zlib
ruby ./extconf.rb
make
make install

如果执行make时出现如下异常:

make: *** 没有规则可以创建“zlib.o”需要的目标“/include/ruby.h”。 停止。

则需修改MakeFile。

vim ./Makefile

把下面一行代码

zlib.o: $(top_srcdir)/include/ruby.h

改为:

zlib.o: ../../include/ruby.h

然后,再重新执行一下命令:

make
make install

同样,如果出现以下异常:

cannot load such file -- openssl (LoadError)

进入openssl目录,类似上面的处理。

Ruby redis 安装cannot load such file — zlib异常插图


Ruby redis 安装cannot load such file — zlib异常插图1

关注公众号:程序新视界,一个让你软实力、硬技术同步提升的平台

除非注明,否则均为程序新视界原创文章,转载必须以链接形式标明本文链接

本文链接:https://choupangxia.com/2019/11/07/ruby-redis-cannot-load-such-file-zlib/