Skip to content

Instantly share code, notes, and snippets.

@Bigcircle
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bigcircle/9477868 to your computer and use it in GitHub Desktop.
Save Bigcircle/9477868 to your computer and use it in GitHub Desktop.
rbenv in centos
# https://github.com/sstephenson/rbenv#installing-ruby-versions
# rbenv script
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile # echo $PATH查看是否正确
# ruby-build script,提供rbenv的所有命令
mkdir -p ~/.rbenv/plugins
cd ~/.rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git
# 可能会缺少编译环境
yum -y install openssl-devel zlib-devel gcc gcc-c++ curl-devel expat-devel gettext-devel make automake autoconf readline-devel libtool
# all versions
rbenv install -l
# install 1.9.3 latest
rbenv install 1.9.3-p545
# compiling...
# 如果要设置全局
rbenv global 1.9.3-p545
rbenv global system # 使用系统默认的ruby版本
# 只设置本地版本,会在当前项目下创建.rbenv-version文件
rbenv local 1.9.3-p545
# 最后验证
which rbenv
rbenv versions
# 安装gem需要注意的地
# 使用 rbenv 后,gem 还是按照原有的方式进行安装、升级,只是 gem 的安装路径是在 rbenv 文件夹中当前 Ruby 版本文件夹下。
# 而且,安装带有可执行文件的 gem 后,需要执行一个特别的命令,告诉 rbenv 更新相应的映射关系
# 这个命令在安装新版本的 Ruby 后也需要执行:
rbenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment