본문 바로가기

리눅스

우분투에서 Ruby 2를 설치하는 방법

728x90

우분투에서 Ruby 2를 설치하는 방법

테스트 환경

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

필수 패키지 설치

sudo apt-get update
sudo apt-get install -y git curl libssl-dev libreadline-dev zlib1g-dev

rbenv 설치

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
exec $SHELL

ruby-build 플러그인 설치

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
728x90

Ruby 2 설치

rbenv install 2.7.6
$ rbenv install 2.7.6
To follow progress, use 'tail -f /tmp/ruby-build.20221222144042.50871.log' or pass --verbose
Downloading openssl-1.1.1s.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa
Installing openssl-1.1.1s...
Installed openssl-1.1.1s to /root/.rbenv/versions/2.7.6

Downloading ruby-2.7.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.bz2
Installing ruby-2.7.6...

WARNING: ruby-2.7.6 is nearing its end of life.
It only receives critical security updates, no bug fixes.

Installed ruby-2.7.6 to /root/.rbenv/versions/2.7.6

NOTE: to activate this Ruby version as the new default, run: rbenv global 2.7.6

전역으로 Ruby 2 설정

rbenv global 2.7.6

설치 확인

ruby --version
ln -s /root/.rbenv/shims/ruby /bin/ruby

rbenv 사용법

$ rbenv
rbenv 1.1.2
Usage: rbenv <command> [<args>]

Some useful rbenv commands are:
   commands    List all available rbenv commands
   local       Set or show the local application-specific Ruby version
   global      Set or show the global Ruby version
   shell       Set or show the shell-specific Ruby version
   install     Install a Ruby version using ruby-build
   uninstall   Uninstall a specific Ruby version
   rehash      Rehash rbenv shims (run this after installing executables)
   version     Show the current Ruby version and its origin
   versions    List installed Ruby versions
   which       Display the full path to an executable
   whence      List all Ruby versions that contain the given executable

See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/rbenv/rbenv#readme

 

rbenv를 통해 Ruby 2를 우분투에 성공적으로 설치하였습니다

 

참고URL

- ruby latest version : https://rubychangelog.com/versions-latest/

 

728x90