Rbenv
Groom your app’s Ruby environment with rbenv.
How to use
apt-get update -qy
apt-get install -y git curl build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libssl-dev
cd
RBENV=~/.rbenv
RBENV_PLUGINS=$RBENV/plugins
git clone git://github.com/sstephenson/rbenv.git $RBENV
export PATH=$RBENV/bin:$PATH
eval "$(rbenv init -)"
git clone git://github.com/sstephenson/ruby-build.git $RBENV_PLUGINS/ruby-build
export PATH=$RBENV_PLUGINS/ruby-build/bin:$PATH
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
rbenv install 2.2.4
rbenv global 2.2.4
아니면 Ubuntu 의 경우:
Linux 에서 특정 로컬 위치에서 초기화 방법
## 없다면 설치
rbenv install 3.1.2
## 디렉토리 이동
cd your/project/dir/
## 로컬 설정 (.ruby-version 파일이 생성됨)
rbenv local 3.1.2
## 초기화
eval "$(rbenv init - --no-rehash bash)"
## 확인 방법
ruby -v
gem install bundler
gem env home
ruby-build
자세한 내용은 ruby-build 참고.
간단히:
## Clone as rbenv plugin using git
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
## Upgrade with:
git -C "$(rbenv root)"/plugins/ruby-build pull
Troubleshooting
make: *** [uncommon.mk:295: build-ext] Error 2
$ rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
BUILD FAILED (Ubuntu 22.04 using ruby-build 20200401)
Inspect or clean up the working tree at /tmp/ruby-build.20251203133341.255405.k3q9wr
Results logged to /tmp/ruby-build.20251203133341.255405.log
Last 10 log lines:
make[2]: Leaving directory '/tmp/ruby-build.20251203133341.255405.k3q9wr/ruby-2.7.1/ext/bigdecimal'
make[2]: Leaving directory '/tmp/ruby-build.20251203133341.255405.k3q9wr/ruby-2.7.1/ext/date'
At top level:
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
linking shared-object ripper.so
make[2]: Leaving directory '/tmp/ruby-build.20251203133341.255405.k3q9wr/ruby-2.7.1/ext/ripper'
make[1]: Leaving directory '/tmp/ruby-build.20251203133341.255405.k3q9wr/ruby-2.7.1'
make: *** [uncommon.mk:295: build-ext] Error 2
#ruby-build 플러그인을 설치한 후 재시도하자.