본문 바로가기

Flutter

you don't have write permissions for the /library/ruby/gems/2.6.0 directory (Gem::FilePermissionError해결방법)

반응형

안녕하세요? 오랜만에 작업하기 위해 플러터 프로젝트를 빌드하려고 하니 에러가 발생합니다. 

이 에러는 시스템 ruby를 이용하는데 권한이 없기 때문에 발생하는 에러라고 합니다. 

 

sudo를 통해 root권한으로 강제 실행해도 역시 설치가 가능하지만 보안상의 이유로 추천되지 않고 있습니다. 

그럼 많이들 사용하시는 rbenv를 통해 정리해보겠습니다. 

 

1.먼저 brew를 통해 rbenv를 설치한다. 

brew install rbenv ruby-build

 

2.rbenv가 잘 설치되었는지 확인한다. 

rbenv versions

 

3.다음은 rbenv로 관리되는 Ruby를 설치합니다. 

설치하기 위해 설치할 수 있는 Ruby 버전을 확인합니다. 

rbenv install -l

 

4.해당 버전으로 설치합니다. 

rbenv install

 

5.설치한 버전을 확인합니다.

rbenv versions

 

6.경로 설정에 추가합니다.

vi ~/.zshrc

[[ -d ~/.rbenv  ]] && \
  export PATH=${HOME}/.rbenv/bin:${PATH} && \
  eval "$(rbenv init -)"
  
  source ~/.zshrc

 

7.gem install을 다시 수행합니다. 

pod repo update

 

?? 안되네요ㅠ 그렇다면 다음 방법으로 넘어가보겠습니다. 

ios에 있는 podfile.lock을 지워보고 다시 설치해보겠습니다. 

1.project-ios로 이동합니다. 

pod install --repo-update

 

2.오 에러가 바뀌었습니다.

CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).

 

이 에러는 Release.xcconfig 파일에 아래 코드를 삽입해서 빌드하면 된다고 합니다. 

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"

 

굿굿 잘 빌드되네요 🙏

 

참고한 블로그입니다. 

1번 해결방법

 

Mac에서 Gem::FilePermissionError 에러 발생시 해결 방법

Mac에서 Ruby의 패키지 매니저인 gem을 통해 설치를 진행하다 다음과 같은 에러를 만납니다. $ gem install bundler ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Ge

jojoldu.tistory.com

 

2번 해결방법

 

[flutter] ios 프로젝트 설정 오류 - Runner config, CocoaPods

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Fi

doitduri.tistory.com

 

반응형