관리 메뉴

너와 나의 스토리

gem 설치 실패 문제 해결 - You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory. 본문

개발

gem 설치 실패 문제 해결 - You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

노는게제일좋아! 2024. 8. 8. 09:29
반응형

gem으로 fluentd를 설치하려 했더니 에러가 발생했다.

  • 에러 로그:
MacBook-Pro-417:seojeongyu$ gem install fluentd
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin23/rbconfig.rb:21: warning: Insecure world writable dir /Users/seojeongyu in PATH, mode 040777
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
  • ruby 버전 조회
    • brew로 설치된 ruby의 버전은 3.3.4인데,  ruby 버전($ ruby --version)을 조회하면 2.6.1이라고 나온다.
    • 시스템이 기본적으로 쓰던 ruby를 인식하는 것으로 보임.
MacBook-Pro-417:provider seojeongyu$ brew info ruby
==> ruby: stable 3.3.4, HEAD [keg-only]
Powerful, clean, object-oriented scripting language
https://www.ruby-lang.org/
Installed
/opt/homebrew/Cellar/ruby/3.3.4 (19,837 files, 51.7MB)
  Poured from bottle using the formulae.brew.sh API on 2024-08-05 at 09:57:01
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/r/ruby.rb
License: Ruby
==> Dependencies
Build: autoconf ✔, pkg-config ✔, rust ✘
Required: libyaml ✔, openssl@3 ✔
==> Options
--HEAD
        Install HEAD version
==> Caveats
By default, binaries installed by gem will be placed into:
  /opt/homebrew/lib/ruby/gems/3.3.0/bin

You may want to add this to your PATH.

ruby 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 ruby first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc

  • 해결방법: 시키는대로 ruby 경로를 지정해주면 된다.
MacBook-Pro-417:provider seojeongyu$  echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
MacBook-Pro-417:provider seojeongyu$ source ~/.zshrc
MacBook-Pro-417:provider seojeongyu$ ruby --version
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin23]
  • gem으로 설치했던 것들(예: fluentd)이 설치되어 있지 않다고 갑자기 나온다면, ruby version을 다시 확인해보자!
반응형
Comments