実現したいこと
XCodeでSnapKitを使いたいのですが
CocoaPodsをインストールできません
発生している問題・エラーメッセージ・試したこと
https://pursue.fun/tech/how-to-cocoapods/
上記サイトを見ながらインストールしようとしました。
sudo gem install cocoapods
実行
エラーがでました
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
このエラーの原因らしいことが書いてある
https://qiita.com/trsxxii/items/4bb4708de03e6ee14a4a
サイトをみて下記のコマンドを実行しました
sudo gem install -n /usr/local/bin cocoapods
これもエラーになりました
~ % sudo gem install cocoapods -n /usr/local/bin Password: ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory. /Library/Ruby/Site/2.6.0/rubygems/installer.rb:712:in `verify_gem_home' /Library/Ruby/Site/2.6.0/rubygems/installer.rb:902:in `pre_install_checks' /Library/Ruby/Site/2.6.0/rubygems/installer.rb:302:in `install' /Library/Ruby/Site/2.6.0/rubygems/resolver/specification.rb:104:in `install' /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:194:in `block in install' /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:182:in `each' /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:182:in `install' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:214:in `install_gem' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:230:in `block in install_gems' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:223:in `each' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:223:in `install_gems' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:169:in `execute' /Library/Ruby/Site/2.6.0/rubygems/command.rb:323:in `invoke_with_build_args' /Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:251:in `invoke_command' /Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:191:in `process_args' /Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:149:in `run' /Library/Ruby/Site/2.6.0/rubygems/gem_runner.rb:51:in `run' /usr/bin/gem:21:in `<main>'
エラーを検索したらだいたいのサイトがhomebrew + rbenv + rubyで、一般ユーザの領域にrubyの環境を作ることが必要ですとのこと
https://qiita.com/ryamate/items/e51c77fbabc2aec185fc
このサイトをみて実行したコマンドです
brew install rbenv ruby-build
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
source ~/.zshrc
~ % which gem /usr/bin/gem
~ % which ruby /usr/bin/ruby
~ % rbenv versions * system
現在のRuby安定版は 3.2.1だったのでrbenv install 3.2.1実行
~ % rbenv install 3.2.1 To follow progress, use 'tail -f /var/folders/fx/_h88t_5907j_zrby6jsfh0fr0000gn/T/ruby-build.20230227184206.30732.log' or pass --verbose Downloading openssl-3.0.8.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e Installing openssl-3.0.8... Installed openssl-3.0.8 to /Users/koalapanda/.rbenv/versions/3.2.1 Downloading ruby-3.2.1.tar.gz... -> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.1.tar.gz Installing ruby-3.2.1... ruby-build: using readline from homebrew BUILD FAILED (macOS 12.6 using ruby-build 20230222) Inspect or clean up the working tree at /var/folders/fx/_h88t_5907j_zrby6jsfh0fr0000gn/T/ruby-build.20230227184206.30732.HX2pva Results logged to /var/folders/fx/_h88t_5907j_zrby6jsfh0fr0000gn/T/ruby-build.20230227184206.30732.log Last 10 log lines: compiling ossl_x509crl.c compiling ossl_x509ext.c compiling ossl_x509name.c compiling ossl_x509req.c compiling ossl_x509revoked.c compiling ossl_x509store.c linking shared-object date_core.bundle linking shared-object openssl.bundle linking shared-object ripper.bundle make: *** [build-ext] Error 2
エラーがでます
エラーを検索すると
RUBY_CFLAGS="-w" つけてみると解決するかもしれないと
https://qiita.com/kouta1206/items/3c56884df4d10f39ebde
https://autovice.jp/articles/178
コマンド実行してもインストールできません
~ % RUBY_CFLAGS="-w" rbenv install 3.2.1 To follow progress, use 'tail -f /var/folders/fx/_h88t_5907j_zrby6jsfh0fr0000gn/T/ruby-build.20230227185659.83636.log' or pass --verbose Downloading openssl-3.0.8.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e Installing openssl-3.0.8... Installed openssl-3.0.8 to /Users/koalapanda/.rbenv/versions/3.2.1 Downloading ruby-3.2.1.tar.gz... -> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.1.tar.gz Installing ruby-3.2.1... ruby-build: using readline from homebrew BUILD FAILED (macOS 12.6 using ruby-build 20230222) Inspect or clean up the working tree at /var/folders/fx/_h88t_5907j_zrby6jsfh0fr0000gn/T/ruby-build.20230227185659.83636.WJtS11 Results logged to /var/folders/fx/_h88t_5907j_zrby6jsfh0fr0000gn/T/ruby-build.20230227185659.83636.log Last 10 log lines: compiling ossl_x509ext.c compiling ossl_x509name.c compiling ossl_x509req.c linking shared-object date_core.bundle compiling ossl_x509revoked.c compiling ossl_x509store.c installing default openssl libraries linking shared-object openssl.bundle linking shared-object ripper.bundle make: *** [build-ext] Error 2
ちがうRubyのバージョンでやってみても同じエラーでした。
RUBY_CFLAGS="-w" rbenv install 2.5.3
もしかしてCocoaPods入ってる?と思ったが入ってませんでした。
~ % pod --version /Library/Ruby/Site/2.6.0/rubygems.rb:263:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException) from /Library/Ruby/Site/2.6.0/rubygems.rb:282:in `activate_bin_path' from /usr/local/bin/pod:23:in `<main>'
この問題を解決するにはどうすればよいのか教えていただきたいです。よろしくお願いします。
補足情報(FW/ツールのバージョンなど)
M1MacBook Air
OS Monterey ver.12.6
zsh --version
zsh 5.8.1 (x86_64-apple-darwin21.0)
xcode-select --version
xcode-select version 2395.
brew --version
Homebrew 4.0.3
回答1件
あなたの回答
tips
プレビュー