sh 安装我们的开发ruby环境

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 安装我们的开发ruby环境相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env bash

set -eo pipefail

# Install rbenv
if [[ ! -d ~/.rbenv ]]; then
	echo "Installing rbenv"
  git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
	if [[ ! `grep 'eval "\$(rbenv init -)"' ~/.bashrc` ]]; then
		echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
		echo 'eval "$(rbenv init -)"' >> ~/.bashrc
	fi
  git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
fi

if [[ -z "$RUBY_VERSION" ]];then
  RUBY_VERSION=2.1.0
fi
  
if [[ -f /app/.ruby-version ]]; then
	RUBY_VERSION=$(< /app/.ruby-version)
fi

. ~/.bash_profile

# Install ruby version
if [[ ! `rbenv versions | grep $RUBY_VERSION` ]];then
  rbenv install $RUBY_VERSION
fi
rbenv global $RUBY_VERSION

gem install bundler

rbenv rehash

以上是关于sh 安装我们的开发ruby环境的主要内容,如果未能解决你的问题,请参考以下文章