깃헙 페이지 리눅스(우분투) 개발 환경 세팅하기

깃헙 페이지 로컬 빌드를 위해 사용되는 jekyll과 bundler 설치를 위해 ruby gem이 사용됩니다. 문제는 기본으로 깔려있는 시스템 ruby를 사용하게 될 경우 다음과 같은 권한 문제로 에러가 출력됩니다.
$gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.
시스템 ruby는 /var/lib/gems 폴더 내에 gem install을 실행하려 하는데 기본적으로 해당 폴더 쓰기 권한이 유저에게 없기 때문에 rbenv를 통해 ruby를 다시 설치하는 과정이 필요합니다.
rbenv & ruby 설치하기
rbenv installer를 사용해 rbenv 설치
# with curl curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash
rbenv 명령어 인식을 위해 PATH에 경로 추가
add PATH(/home/{USER_NAME}/.rbenv/bin
) to ~/.bashrc or ~/.zshrc쉘에
rbenv init
을 입력후 나오는 데로 ~/.bashrc or ~/.zshrc에 내용 추가rbenv init # Load rbenv automatically by appending # the following to ~/.bash_profile: eval "$(rbenv init -)"
rbenv를 사용하여 최신 루비 설치
rbenv install -l # 리스트 중 최신 버전의 ruby(2.7.2) 설치 rbenv install 2.7.2 rbenv global 2.7.2
jekyll & bundler 설치
gem install jekyll bundler
이후 blog가 위치한 폴더로 이동한 후 빌드해 주시면 됩니다.
bundle update
bundle exec jekyll serve