어느날 pod install 명령어를 수행했지만 아래와 같은 오류가 뿜어졌다.
/Users/{name}/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems.rb:265:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
from /Users/{name}/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems.rb:284:in `activate_bin_path'
from /usr/local/bin/pod:25:in `<main>'
이 오류는 cocoapods가 시스템에 설치되지 않았거나 현재 사용 중인 Ruby 버전에서 cocoapods gem을 찾을 수 없을 때 발생하는 오류라고 한다.
그렇다면 원인은 셋 중 하나라고 생각이 들었다.
1. Gem 미설치: cocoapods가 해당 Ruby 버전에 설치되지 않았을 때
2. rbenv 버전 문제: rbenv로 관리 중인 Ruby 버전과 cocoapods 설치 버전 불일치.
3. Path 설정 오류: gem 경로가 제대로 설정되지 않았음.
그렇다면 일단 gem install cocoapods
를 실행하여 pod 버전을 확인하려고 하였다.
엥
Fetching xcodeproj-1.27.0.gem
Fetching benchmark-0.4.0.gem
Fetching securerandom-0.3.2.gem
Fetching cocoapods-core-1.16.2.gem
Fetching activesupport-7.2.2.gem
Fetching cocoapods-1.16.2.gem
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory @ dir_s_mkdir -
혹시 몰라 권한 문제인가 sudo
를 포함하여 다시 실행시켜보았다.
Fetching benchmark-0.4.0.gem
Fetching cocoapods-1.16.2.gem
Fetching xcodeproj-1.27.0.gem
Fetching activesupport-7.2.2.gem
Fetching cocoapods-core-1.16.2.gem
Successfully installed xcodeproj-1.27.0
Successfully installed benchmark-0.4.0
ERROR: Error installing cocoapods:
The last version of drb (>= 0) to support your Ruby & RubyGems was 2.0.6. Try installing it with `gem install drb -v 2.0.6` and then running the current command again
drb requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210.
맨 마지막에 출력된 문장을 주목하자.
The last version of drb (>= 0) to support your Ruby & RubyGems was 2.0.6. Try installing it with `gem install drb -v 2.0.6` and then running the current command again
drb requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210.
보아하니, drb
버전과 현재 사용중인 Ruby
버전이 호환되지 않아 발생한 문제인 것 같다.
drb
는 Ruby 2.7.0
부터 지원하지만 현재 내가 사용중인 버전은 2.6.10
이어서 발생한 문제인 것 같다. 따라서 Ruby
버전을 업그레이드하는 작업을 수행하였다!
rbenv install 3.1.2
rbenv global 3.1.2 # 글로벌로 설정
rbenv rehash # 환경 새로고침
ruby -v
# cocoapods 재설치
sudo gem install cocoapods
성공🎉