Codesigner

[Ruby] MacOS에 Ruby 설치하는 법 본문

Ruby

[Ruby] MacOS에 Ruby 설치하는 법

eunsukimme 2019. 9. 11. 02:07

Github page를 활용하기 위해 내 맥북에 Ruby를 설치할 일이 생겼는데, 나중에 설치할 때도 참고하기 위해 위 과정을 정리해보려고 한다.

 

 

 

Ruby 설치하기

먼저, 루비를 다운로드하기 위해 공식 다운로드 페이지로 이동하자.

https://www.ruby-lang.org/en/downloads/

 

Download Ruby

Here you can get the latest Ruby distributions in your favorite flavor. The current stable version is 2.6.4. Please be sure to read Ruby’s License. Ways of Installing Ruby We have several tools on each major platform to install Ruby: On Linux/UNIX, you can

www.ruby-lang.org

위 페이지에 접속하면 아래와 같은 화면이 나온다

 

 

 

<그림 1> 루비 공식 다운로드 페이지

여기에서 Ways of Installing Ruby 섹션의 중간에 macOS는 rbenv 나 RVM과 같은 써드 파티 툴로 설치 가능하다고 나와있다. 이번 포스팅에서는 rbenv로 설치해 보도록 하겠다. rbenv 링크를 누르면 다음과 같은 Github 레포지토리로 넘어간다.

 

 

 

 

<그림 2> rbenv Github repository

README.md 를 읽어보면 친절하게 설치하는 방법을 설명해주고 있다. rbenv가 무엇인지 설명하기 위해 위 레포지토리의 설명을 인용하자면 다음과 같다.

 

Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production. Put rbenv to work with Bundler for painless Ruby upgrades and bulletproof deployments.

 

간단히 하면 원하는 Ruby 버전을 선택해서 사용할 수 있고, 개발 환경과 프로덕션 환경을 맞출 수 있다는 것이다. 자세한 내용은 rbenv 깃허브 레포지토리를 참고하도록 하고, 이제 본격적으로 루비를 설치해 보도록 하자. 먼저, brew로 rbenv를 설치하자.

$ brew install rbenv

 

위 명령은 자동적으로 ruby-build 라는 녀석을 같이 설치해주는데, 이로 인해 다른 여러 루비 버전을 설치할 수 있다. 계속해서 rbenv를 셋업 해주자.

$ rbenv init

 

그런 다음 터미널 창을 껐다가 새로 켜준다. 그런 다음 명령을 통해 rbenv 가 적절하게 셋업 되었는지 확인해보도록 하자.

$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20170523)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `~/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK

 

위처럼 결과가 출력된다면 rbenv가 잘 설치된 것이다. 결과를 들여다보면 현재 설치 가능한 Ruby 버전은 2.2.4라고 나온다. 다음 명령을 통해 ruby 2.2.4 버전을 설치하도록 하자.

$ rbenv install 2.2.4

 

설치된 루비 버전들은 다음 명령을 통해 확인할 수 있다.

$ rbenv versions

 

 

 

Review

지금까지 Ruby를 설치하는 방법을 간단하게 알아보았다. rbenv를 다루는 자세한 방법들은 해당 Github의 공식 문서를 참고하도록 하자.

 

 

'Ruby' 카테고리의 다른 글

[Ruby] rbenv로 ruby 버전 변경이 안될 때  (1) 2019.09.11
Comments