지금 티스토리 블로그를 하고 있지만
개발 관련한 부분은 깃허브 블로그로 이관하고자
깃허브 블로그를 셋팅하던 중,
아주 골칫거리를 하나 만났다. 바로 Ruby!
며칠 조금씩 건들이며
계속 답답해하던 중 해결책을 찾아 공유해본다.
사실 간단했다. 요약하자면,
1. ruby가 기본적으로 셋팅된 2.6.0 버전은
기존 mac 운영체제 파일의 의존성때문에 냅두고,
2. 최신 버전을 추가로 설치하여 switching 해준다.
3. gem 경로의 home 셋팅을 다시 해준다.
사실 이것이 문제가 됐던 원인은
gem 경로를 flutter 환경 설정하면서
zshrc에 박아두었던 것도 에러의 원인 중 포함이었다.
꼼꼼하게 vi를 보지 않았던 탓...
아무튼 시간 낭비를 줄이기 위해
이 포스팅이 도움이 되시길 바란다.
❯ gem install bundler
<internal:/opt/homebrew/Cellar/ruby/3.2.2_1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': linked to incompatible /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/libruby.2.6.dylib - /Users/gomae/.gem/gems/psych-5.1.2/lib/psych.bundle (LoadError)
from <internal:/opt/homebrew/Cellar/ruby/3.2.2_1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
깃허브 지킬 셋팅의 필수인 bundler 설치를 하려고 하면
기존에는 이렇게 뭐 자꾸 버전이 안 맞다며...
gem install bundler를 빠꾸 시켰다.
❯ brew update
Updated 3 taps (homebrew/cask-versions, homebrew/core and homebrew/cask).
==> New Formulae
doltgres kiota urlscan
halp libnsbmp veilid
hopscotch-map libwapcaplet vulkan-volk
jot netsurf-buildsystem
k8sgpt sugarjar
일단은 brew update를 해준다.
❯ brew install rbenv ruby-build
Warning: rbenv 1.2.0 is already installed and up-to-date.
To reinstall 1.2.0, run:
brew reinstall rbenv
ruby-build 20231114 is already installed but outdated (so it will be upgraded).
==> Downloading https://ghcr.io/v2/homebrew/core/ruby-build/manifests/20231225
####################################################################### 100.0%
==> Fetching dependencies for ruby-build: autoconf and ca-certificates
==> Upgrading curl
8.4.0 -> 8.5.0
==> Installing dependencies for curl: gettext
==> Installing curl dependency: gettext
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/manifests/0.22.4
Already downloaded: /Users/gomae/Library/Caches/Homebrew/downloads/3ceb9457127eaa7378dd80ed256098ffb391e2350069becb25cfe2a14f0b7d6d--gettext-0.22.4.bottle_manifest.json
==> Pouring gettext--0.22.4.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/gettext/0.22.4: 2,042 files, 24.3MB
==> Installing curl
==> Pouring curl--8.5.0.arm64_sonoma.bottle.tar.gz
==> Caveats
curl is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have curl first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/curl/bin:$PATH"' >> ~/.zshrc
For compilers to find curl you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/curl/lib"
export CPPFLAGS="-I/opt/homebrew/opt/curl/include"
For pkg-config to find curl you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/curl/lib/pkgconfig"
zsh completions have been installed to:
/opt/homebrew/opt/curl/share/zsh/site-functions
==> Summary
🍺 /opt/homebrew/Cellar/curl/8.5.0: 522 files, 4.5MB
==> Running `brew cleanup curl`...
Removing: /opt/homebrew/Cellar/curl/8.4.0... (522 files, 4.4MB)
==> Upgrading edencommon
2023.11.27.00 -> 2023.12.04.00
일단 rbenv ruby-build를 brew로 설치해준다.
중간중간에 curl이 업데이트 되었으니 뭘 해달라고 하긴 한다.
하라는대로 다 하면 날 샌다. 일단은 패스...
❯ rbenv versions
* system
rbenv versions 명령어를 때리면
system에 디폴트로 설치된 애를 가리킨다.
얘를 바꿔줘야 한다.
❯ rbenv install -l
3.0.6
3.1.4
3.2.2
3.3.0
jruby-9.4.5.0
mruby-3.2.0
picoruby-3.0.0
truffleruby-23.1.1
truffleruby+graalvm-23.1.1
Only latest stable releases for each Ruby implementation are shown.
Use `rbenv install --list-all' to show all local versions.
현 시점 가장 최신 버전인 3.3.0을 설치해보자.
❯ rbenv install 3.3.0
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.3.0.tar.gz...
-> curl -q -fL -o ruby-3.3.0.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.0M 100 21.0M 0 0 27.1M 0 --:--:-- --:--:-- --:--:-- 27.3M
==> Installing ruby-3.3.0...
응 그렇쥬 옳지 잘한다
❯ rbenv install 3.3.0
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.3.0.tar.gz...
-> curl -q -fL -o ruby-3.3.0.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.0M 100 21.0M 0 0 27.1M 0 --:--:-- --:--:-- --:--:-- 27.3M
==> Installing ruby-3.3.0...
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/3.3.0" --with-openssl-dir=/opt/homebrew/opt/openssl@3 --enable-shared --with-readline-dir=/opt/homebrew/opt/r
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# 2023.07.26 update theme
ZSH_THEME="powerlevel10k/powerlevel10k"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# zstyle ':omz:update' mode disabled # disable automatic updates
# Uncomment the following line to change how often to auto-update (in days).
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# brew 2023.07.25.Tue
export PATH=/opt/homebrew/bin:$PATH
eval $(/opt/homebrew/bin/brew shellenv)
# NVM 2023.07.25.Tue
export NVM_DIR="$HOME/.nvm"
# GEM 2023.07.25.Tue
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
# JDK 2023.07.25.Tue
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
# Android SDK 2023.07.25.Tue
export ANDROID_HOME=/Users/gomae/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
eadline --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-ext=openssl,psych,+
-> make -j 10
-> make install
==> Installed ruby-3.3.0 to /Users/gomae/.rbenv/versions/3.3.0
NOTE: to activate this Ruby version as the new default, run: rbenv global 3.3.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# 2023.07.26 update theme
ZSH_THEME="powerlevel10k/powerlevel10k"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# zstyle ':omz:update' mode disabled # disable automatic updates
# Uncomment the following line to change how often to auto-update (in days).
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# brew 2023.07.25.Tue
export PATH=/opt/homebrew/bin:$PATH
eval $(/opt/homebrew/bin/brew shellenv)
# NVM 2023.07.25.Tue
export NVM_DIR="$HOME/.nvm"
# GEM 2023.07.25.Tue
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
# JDK 2023.07.25.Tue
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
# Android SDK 2023.07.25.Tue
export ANDROID_HOME=/Users/gomae/Library/Android/sdk
0
명령어를 탁 때리면 쉘에 나의 zshrc도 다 읽고 있고
경로들을 계속 뭔가 읽고 있다는 사실을 알 수 있다.
역시 다 그냥 되는 것은 없다.
저 위에서 기존의 문제가 됐던 경로 설정은
# GEM 2023.07.25.Tue
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
이 부분이었다.
내가 2023년 7월 25일 화요일에 설정한
GEM_HOME...
저 부분을 좀 있다가 또 바꿔줄거다.
일단 아래 순서대로 실행해보자.
+ flutter은 요즘 안 쓰니까 설정 싹 다 주석 쳤음.
❯ rbenv versions
* system
3.3.0
이제 rbenv 3.3.0이 설치가 됐다.
스위칭을 해주자.
❯ rbenv global 3.3.0
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
//... zshrc 경로들
그러면 또 zshrc를 호롤로 읽고 있는 걸 볼 수 있음.
❯ rbenv versions
system
* 3.3.0 (set by /Users/gomae/.rbenv/version)
스위칭 완료.
~ ─────────────────────────────────────────── 1m 43s 09:26:09
❯ vi ~/.zshrc
~ ────────────────────────────────────────────────────── 09:26:12
❯ source ~/.zshrc
chruby: unknown Ruby: ruby-3.3.0
스위칭을 했으니 이제 zshrc에서 gem 경로를 바꿔줘야 한다.
// vi ./zshrc
# GEM 2023.07.25.Tue
#export GEM_HOME=$HOME/.gem
export GEM_HOME=$HOME/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0
export PATH=$GEM_HOME/bin:$PATH
vi ./zshrc 명령어로 설정 파일 들어가주고,
기존 GEM_HOME은 혹시 모르니 주석 쳐버리고
GEM_HOME 경로를 바꿔준다.
$HOME은 따로 딱히 설정한 곳이 없다면
mac 안에 user(사용자)임.
둘 사이 비교해보면 얼추 폴더 구조도 맞음. 이렇게 설정해줬다.
# flutter
#export PATH="$PATH:$HOME/develop/sdk/flutter/bin"
#source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
#source /opt/homebrew/opt/chruby/share/chruby/auto.sh
#chruby ruby-3.3.0
#export PATH="$HOME/.gem/ruby/2.6.0/bin:$PATH"
#export PATH="$HOME/.gem/ruby/2.6.0/bin:$PATH"
기존에 flutter 환경 설정은 주석 쳐버림.
지금은 일단 안 쓰니까...
나중에는 버전 또 맞춰줘야 할 것 같다.
# rbenv
[[ -d ~/.rbenv ]] && \
export PATH=${HOME}/.rbenv/bin:${PATH} && \
eval "$(rbenv init -)"
그리고 zshrc에 위 rbenv 설정도 추가해주자.
rbenv 경로는 여기에요... 얘기해줄 수 있게.
❯ gem env home
/Users/gomae/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0
❯ gem install bundler
Fetching bundler-2.5.4.gem
Successfully installed bundler-2.5.4
Parsing documentation for bundler-2.5.4
Installing ri documentation for bundler-2.5.4
Done installing documentation for bundler after 2 seconds
1 gem installed
A new release of RubyGems is available: 3.5.3 → 3.5.4!
Run `gem update --system 3.5.4` to update your installation.
드디어!!!!!!!!!!!!!!!!!!
bundler가 제대로 동작하는 것을 볼 수 있음.
오늘 목표... 깃허브 블로그 셋팅하기..
아 이게 뭐라고 진짜ㅏ 엄청 헤맸네ㅠ
설치할 때 대충 넘기지 말고 꼼꼼히 보자.
Jekyll의 마음에 드는 테마를 찾았으면 fork 떠서
내 repository 이름을 [username].github.io 로 바꾸고 저장.
이 repository를 git clone해와서 로컬 컴퓨터에 셋팅한다.
딱히 추가 설정할 것은 없지만
jekyll 테마 만든 author의 github를 들어가서
대략적인 가이드를 살펴보며 바꿔줄건 바꿔준다.
그리고
요렇게 bundler를 설치해주고 bundle install을
나의 github.io 레포지토리 안에서 해준다.
지킬 번들이 서빙해서 서버를 돌려줌.
localhost 4000번으로 접속하면 된다.
음 만족스러워 *^^*
다른 깔끔한 테마들을 대부분 많이 쓰긴 하지만
나는 늘 남들과 다른 것을 선호하기에...
ㅎ
만족스럽다.
나름 커스텀해가면서 블로그 해바야지.
재밌당
'개발 > Ruby On rails' 카테고리의 다른 글
[Ruby] Ruby 문서 참고하며 연습 1 (0) | 2021.05.03 |
---|---|
[Ruby] Ruby 손쉽게 설치하기 (0) | 2021.05.03 |