简体   繁体   中英

How can I install Ruby on CentOS 6.9?

The following errors show up when I tried to install ruby on CentOS 6.9 using yum install ruby

Error: Package: ruby-2.2.3-1.el7.x86_64 (shiqiao)
           Requires: libgdbm.so.4()(64bit)
Error: Package: ruby-2.2.3-1.el7.x86_64 (shiqiao)
           Requires: libgdbm_compat.so.4()(64bit)
Error: Package: ruby-2.2.3-1.el7.x86_64 (shiqiao)
           Requires: libffi.so.6()(64bit)
Error: Package: ruby-2.2.3-1.el7.x86_64 (shiqiao)
           Requires: libc.so.6(GLIBC_2.17)(64bit)
Error: Package: ruby-2.2.3-1.el7.x86_64 (shiqiao)
           Requires: libcrypto.so.10(OPENSSL_1.0.2)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

I tried to download required rpm package and install these rpms manually, but they always need other rpms, it seems I'm lost in some kind of an infinite loop.

How can I install Ruby correctly?

I have encountered alike situation before, finally decided to try rbenv and turned out great.
Pros: You can have multiple versions and update to newest version. Can choose version to use.
Cons: Need extra work to make it work on another account. Gems need to install again after installed new version.

So if you would like to try it, below are all the procedures you need (Will install things for building/unpacking etc.) :

sudo yum install -y git git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel

cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec -l $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
exec -l $SHELL

RUBY_CONFIGURE_OPTS=--disable-install-doc rbenv install 2.5.3
rbenv global 2.5.3

It will change ~/.bash_profile and make dir ~/.rbenv
So It's better if you backup .bash_profile first or make note what changes took place.
You can just remove .rbenv directory and restore .bash_profile file to revert these.

Second last line is to download source and build -- install the version. It will take some time to finish.
The last line rbenv global is to make the version to work as default. You can change between versions by this command.
They will install the latest stable version 2.5.3, and won't install doc (Will spend much more time and sometimes will fail to build on server that has little ram).
If you want to update or at the time you install there's newer version, just change the version number.
Also you can use below command to check available versions before install:

rbenv install -l

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM