ERROR: While executing gem ... (Gem::FilePermissionError) You don‘t have write permissions for

安装或者更新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.

1.删除CocoaPods;

2.用命令which -a ruby,查看只有一个系统自带的ruby目录。

chunxiao@bogon ios % which -a ruby
/usr/bin/ruby

3.使用命令brew install ruby安装一个最新版本的ruby

Running `brew update --auto-update`...
Error: Failed to download https://formulae.brew.sh/api/cask.jws.json!
==> Homebrew collects anonymous analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).

==> homebrew/core is old and unneeded, untapping to save space.
Untapping homebrew/core...
Untapped 3 commands and 6649 formulae (7,084 files, 481.3MB).
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################## 100.0%
==> Auto-updated Homebrew!
Updated 3 taps (dart-lang/dart, homebrew/core and homebrew/cask).
==> New Formulae
abi3audit                       onionprobe
action-validator                opentofu
adb-enhanced                    orbiton
aerleon                         orbuculum
ain                             orcania
alass                           orogene
ali                             osctrl-cli
amass                           oslo
ansible@8                       pan
apify-cli                       patat
apkleaks                        patch-package
apprise                         pciutils
appstream                       pdfalyzer
arm-none-eabi-binutils          perl-xml-parser
arm-none-eabi-gcc               pgrok
arm-none-eabi-gdb               [email protected]
asitop                          phylum-cli
asn                             pixi
asnmap                          plog
auditwheel                      pmix
authz0                          pop
awscli-local                    postgresql@16
bacon                           powerlevel10k
badkeys                         presenterm
bandicoot                       prettierd
bao                             proxify
bashunit                        proxygen
bazel-diff                      pter
bazel-remote                    pwned
bbot                            pylyzer
bfs                             pypy3.10
bilix                           pypy3.9
biodiff                         pyspelling
biome                           pystring
bkcrack                         python-abseil
blades                          python-anytree
blake3                          python-argcomplete
blink                           python-asn1crypto
bob                             python-attrs
bomber                          python-boto3
botan@2                         python-botocore
bounceback                      python-brotli
bozohttpd                       python-cachetools
build2                          python-certifi
caracal                         python-chardet
cargo-all-features              python-charset-normalizer
cargo-auditable                 python-cli-helpers
cargo-binstall                  python-click
cargo-binutils                  python-colorama
cargo-deps                      python-configargparse
cargo-docset                    python-configobj
cariddi                         python-cryptography
cbonsai                         python-cycler
cdi                             python-dateutil
cdxgen                          python-dicttoxml
certgraph                       python-distlib
certsync                        python-distro
cf2tf                           python-docopt
cfripper                        python-filelock
chainloop-cli                   python-flit-core
chainsaw                        [email protected]
changie                         python-hatch-fancy-pypi-readme
chaoskube                       python-hatch-vcs
checkdmarc                      python-hatchling
cherrybomb                      python-idna
cidr                            python-jinja
cliam                           python-jmespath
cloud-sql-proxy                 python-json5
cloudfox                        python-kiwisolver
cloudlist                       python-lxml
cloudsplaining                  python-magic
codelimit                       python-mako
coder                           python-markdown-it-py
colmap                          python-markupsafe
couchbase-shell                 python-matplotlib
counts                          python-mdurl
cppinsights                     python-mpmath
crabz                           python-msgpack
crunchy-cli                     python-mutagen
cryptopp                        python-networkx
crystalline                     python-oauthlib
csprecon                        python-openapi3
ctpv                            python-packaging
cyclonedx-gomod                 python-pathspec
cyclonedx-python                python-pbr
cycode                          python-platformdirs
czkawka                         python-pluggy
daktilo                         python-ply
dart-lang/dart/[email protected]        python-prompt-toolkit
dart-lang/dart/[email protected]         python-psutil
dcp                             python-pycurl
der-ascii                       python-pyparsing
dezoomify-rs                    python-pyproject-hooks
dicebear                        python-pytz
diffoci                         python-regex
dnsrobocert                     python-requests
dockerfile-language-server      python-requests-oauthlib
dockly                          python-rich
dolphie                         python-s3transfer
doppler                         python-setuptools
dovi_tool                       python-setuptools-scm
driftwood                       python-sympy
dysk                            python-termcolor
eatmemory                       [email protected]
ebook2cw                        python-toml
erg                             python-trove-classifiers
erlang@25                       python-urllib3
espflash                        python-wcwidth
eza                             python-websocket-client
faircamp                        python-xlsxwriter
falco                           [email protected]
falcoctl                        qalculate-qt
favirecon                       qbittorrent-cli
feishu2md                       quictls
flyscrape                       rapidfuzz-cpp
frozen                          raven
fuc                             rdap
fw                              recoverpy
fwupd                           redwax-tool
gdrive@2                        reflex
geoip2fast                      regclient
ggshield                        rekor-cli
[email protected]                         retry
[email protected]                         richgo
gickup                          rio
gismo                           riscv64-elf-binutils
git-mediate                     riscv64-elf-gcc
gitea                           riscv64-elf-gdb
gitsign                         risor
gittuf                          roadrunner
[email protected]                         rpmspectool
goread                          ruff-lsp
goresym                         ruler
gossip                          runme
gotestwaf                       s3scanner
gotpm                           saf-cli
govulncheck                     sbom-tool
gptline                         scarb
graphqlviz                      scikit-image
haiti                           scilla
helidon                         scoutsuite
hex                             scrapy
hoverfly                        sh4d0wup
hyfetch                         shell2http
img2pdf                         shellspec
imgdiet                         shuffledns
imgdiff                         sickchill
immer                           sigma-cli
incus                           signmykey
instaloader                     sigstore
intercept                       skate
invoice                         sloth
iocextract                      smlfmt
ittapi                          snakeviz
jprq                            snyk-cli
jr                              solo2-cli
json2ts                         [email protected]
jupyter-r                       spacer
karmadactl                      spglib
katana                          spicetify-cli
kew                             spidermonkey@91
killport                        sqlfmt
kor                             sqlpage
kosli-cli                       sqlsmith
lager                           squealer
ldeep                           squiid
ldid-procursus                  ssh-mitm
legitify                        sshportal
libconfini                      strip-nondeterminism
libcyaml                        surelog
libdicom                        tailspin
libdivsufsort                   tailwindcss
libdpp                          talhelper
[email protected]                     telegram-downloader
libimobiledevice-glue           terraform-graph-beautifier
libjcat                         terraform-local
libjuice                        terragrunt-atlantis-config
libmapper                       texttest
libnghttp3                      tf-profile
libpanel                        three-body
libsail                         tlrc
libshumate                      toxiproxy
libversion                      tpm
libxmlb                         trafilatura
llm                             trufflehog
llvm@16                         trzsz-ssh
lr                              tzdiff
lune                            udp2raw-multiplatform
lxi-tools                       uffizzi
mailpit                         uhdm
[email protected]                    uncover
[email protected]                    urlfinder
massdriver                      uvicorn
mediamtx                        vet
medusa                          virtctl
memray                          vulkan-utility-libraries
mentat                          vulsio-gost
meson-python                    vunnel
mfem                            web-ext
mgis                            webpod
minder                          wget2
mjml                            whisper-cpp
modsecurity                     witness
modsurfer                       woodpecker-cli
mtbl                            woof-doom
mvfst                           wormhole-william
mvt                             wpscan
[email protected]                wtfis
[email protected]                       xe
neonctl                         xeol
netlistsvg                      xlsxio
node@20                         xnvme
noir                            yazi
notation                        yder
ntbtls                          yyjson
numbat                          zchunk
nvimpager                       zix
ollama                          zug
==> New Casks
4k-video-downloaderplus         low-profile
affine                          luniistore
aifun                           maa
akuity                          macgpt
amie                            mdb-accdb-viewer
apidog                          mediamate
applite                         meld-studio
ava                             metamer
batchoutput-pdf                 mindmac
batteryboi                      mitmproxy
bepo                            modrinth
bezel                           monotype
brickstore                      music-decoy
browser-deputy                  mutedeck
btp                             muyu
chainner                        mycard
chatall                         nvs
cilicon                         ok-json
clibor                          orka3
clickhouse                      ovito
clinq                           ovito-pro
clop                            paulxstretch
cloudnet                        picoscope
codewhisperer                   pieces
commandpost                     pieces-os
crystalfetch                    piphero
deskpad                         playdate-mirror
deveco-studio                   poe
devtunnel                       proton-drive
dockx                           proxy-audio-device
douyin-chat                     recipeui
drata-agent                     replay
draw-things                     reqable
dropbox-dash                    rippling
dropshelf                       ripx
ecodms-client                   rode-central
effect-house                    routine
elektron-overbridge             rustrover
elektron-transfer               score
energiza                        screen-studio
ente                            sf
expo-orbit                      sfm
fedistar                        shattered-pixel-dungeon
finbar                          showmeyourhotkeys
flexoptix                       simple-web-server
floorp                          simplex
font-finagler                   songkong
fossa                           space-capsule
free-podcast-transcription      spacedrive
git-credential-manager          sparkplate
glaze                           spundle
greenery                        stash
gstreamer-development           telegram-a
gstreamer-runtime               ths
herd                            timemachinestatus
hhkb                            to-audio-converter
hides                           tunetag
hoppscotch                      twelite-stage
hovrly                          updf
hp-easy-admin                   viso
hypercal                        voicepeak
iem-plugin-suite                wetype
jazz2-resurrection              whisky
json-viewer                     wiso-steuer-2022
jukebox                         wiso-steuer-2023
keyclu                          writerside
keymapp                         xiaomi-cloud
kreya                           xliff-editor
kuaitie                         xsplit-vcam
libndi                          zspace
lm-studio                       zui

You have 5 outdated formulae installed.

==> Fetching dependencies for ruby: ca-certificates, openssl@3 and readline
==> Fetching ca-certificates
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-b
######################################################## 100.0%
==> Fetching openssl@3
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-b
######################################################## 100.0%
==> Fetching readline
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-b
######################################################## 100.0%
==> Fetching ruby
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-b
######################################################## 100.0%
==> Installing dependencies for ruby: ca-certificates, openssl@3 and readline
==> Installing ruby dependency: ca-certificates
==> Pouring ca-certificates-2023-08-22.all.bottle.1.tar.gz
==> Regenerating CA certificate bundle from keychain, this may 
  /usr/local/Cellar/ca-certificates/2023-08-22: 3 files, 221.5KB
==> Installing ruby dependency: openssl@3
==> Pouring [email protected]
  /usr/local/Cellar/openssl@3/3.2.0: 6,805 files, 32.4MB
==> Installing ruby dependency: readline
==> Pouring readline-8.2.7.ventura.bottle.tar.gz
  /usr/local/Cellar/readline/8.2.7: 50 files, 1.7MB
==> Installing ruby
==> Pouring ruby-3.2.2_1.ventura.bottle.tar.gz
==> Caveats
ruby is keg-only, which means it was not symlinked into /usr/local,
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="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby you may need to set:
  export LDFLAGS="-L/usr/local/opt/ruby/lib"
  export CPPFLAGS="-I/usr/local/opt/ruby/include"
==> Summary
  /usr/local/Cellar/ruby/3.2.2_1: 16,605 files, 46.2MB
==> Running `brew cleanup ruby`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Upgrading 1 dependent of upgraded formulae:
Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
fastlane 2.213.0 -> 2.217.0
==> Fetching fastlane
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-b
######################################################## 100.0%
==> Upgrading fastlane
  2.213.0 -> 2.217.0 

==> Pouring fastlane-2.217.0.ventura.bottle.1.tar.gz
  /usr/local/Cellar/fastlane/2.217.0: 3,902 files, 42.1MB
==> Running `brew cleanup fastlane`...
Removing: /usr/local/Cellar/fastlane/2.213.0... (3,981 files, 45.4MB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/fastlane--2.213.0.ventura.bottle.tar.gz... (13MB)
==> Checking for dependents of upgraded formulae...
==> No broken dependents found!
==> `brew cleanup` has not been run in the last 30 days, runnin
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/ca-certificates/2023-01-10... (3 files, 216.8KB)
Removing: /usr/local/Cellar/ca-certificates/2023-05-30... (3 files, 216.1KB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/ca-certificates--2023-01-10.all.bottle.tar.gz... (122.6KB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/ca-certificates--2023-05-30.ventura.bottle.tar.gz... (122.1KB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/dart--3.0.5.zip... (203.6MB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/libyaml--0.2.5.ventura.bottle.tar.gz... (106.3KB)
Removing: /usr/local/Cellar/openssl@3/3.1.0... (6,494 files, 29.9MB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/[email protected]... (7.9MB)
Removing: /usr/local/Cellar/readline/8.2.1... (50 files, 1.7MB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/readline--8.2.1.ventura.bottle.tar.gz... (547KB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/[email protected]... (11.9MB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/terminal-notifier--2.0.0.ventura.bottle.tar.gz... (369.7KB)
Removing: /Users/chunxiao/Library/Caches/Homebrew/Cask/fastclicker--1.1.zip... (970KB)
Removing: /Users/chunxiao/Library/Logs/Homebrew/terminal-notifier... (64B)
Removing: /Users/chunxiao/Library/Logs/Homebrew/dart... (115B)
Removing: /Users/chunxiao/Library/Logs/Homebrew/libyaml... (64B)
Removing: /Users/chunxiao/Library/Logs/Homebrew/readline... (64B)
Removing: /Users/chunxiao/Library/Logs/Homebrew/openssl@3... (64B)
Removing: /Users/chunxiao/Library/Logs/Homebrew/ca-certificates... (64B)
Removing: /Users/chunxiao/Library/Logs/Homebrew/fastlane... (64B)
Removing: /Users/chunxiao/Library/Logs/Homebrew/[email protected]... (64B)
Pruned 0 symbolic links and 8 directories from /usr/local
==> Caveats
==> ruby
ruby is keg-only, which means it was not symlinked into /usr/local,
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="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby you may need to set:
  export LDFLAGS="-L/usr/local/opt/ruby/lib"
  export CPPFLAGS="-I/usr/local/opt/ruby/include"

4.安装完后检查系统目录

chunxiao@bogon ios % which -a ruby
/usr/bin/ruby

5.把新版本加到环境变量中

chunxiao@bogon ios % echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
chunxiao@bogon ios % source ~/.zshrc

6.再次检查系统目录,发现已经有两个了

chunxiao@bogon ios % which -a ruby  
/usr/local/opt/ruby/bin/ruby
/usr/bin/ruby

7.安装CocoaPods

sudo gem install -n /usr/local/bin cocoapods
Fetching claide-1.1.0.gem
Fetching xcodeproj-1.23.0.gem
Fetching atomos-0.1.3.gem
Fetching colored2-3.1.2.gem
Fetching ruby-macho-2.5.1.gem
Fetching nanaimo-0.3.0.gem
Fetching CFPropertyList-3.0.6.gem
Fetching rexml-3.2.6.gem
Fetching nap-1.1.0.gem
Fetching molinillo-0.8.0.gem
Fetching gh_inspector-1.1.3.gem
Fetching fourflusher-2.3.1.gem
Fetching escape-0.0.4.gem
Fetching cocoapods-try-1.2.0.gem
Fetching netrc-0.11.0.gem
Fetching cocoapods-trunk-1.6.0.gem
Fetching cocoapods-search-1.0.1.gem
Fetching cocoapods-plugins-1.0.0.gem
Fetching cocoapods-downloader-2.1.gem
Fetching cocoapods-deintegrate-1.0.5.gem
Fetching ffi-1.16.3.gem
Fetching ethon-0.16.0.gem
Fetching typhoeus-1.4.1.gem
Fetching public_suffix-4.0.7.gem
Fetching fuzzy_match-2.0.4.gem
Fetching concurrent-ruby-1.2.2.gem
Fetching httpclient-2.8.3.gem
Fetching algoliasearch-1.27.5.gem
Fetching addressable-2.8.5.gem
Fetching tzinfo-2.0.6.gem
Fetching i18n-1.14.1.gem
Fetching cocoapods-core-1.14.3.gem
Fetching cocoapods-1.14.3.gem
Fetching connection_pool-2.4.1.gem
Fetching activesupport-7.1.2.gem
Successfully installed rexml-3.2.6
Successfully installed nanaimo-0.3.0
Successfully installed colored2-3.1.2
Successfully installed claide-1.1.0
Successfully installed CFPropertyList-3.0.6
Successfully installed atomos-0.1.3
Successfully installed xcodeproj-1.23.0
Successfully installed ruby-macho-2.5.1
Successfully installed nap-1.1.0
Successfully installed molinillo-0.8.0
Successfully installed gh_inspector-1.1.3
Successfully installed fourflusher-2.3.1
Successfully installed escape-0.0.4
Successfully installed cocoapods-try-1.2.0
Successfully installed netrc-0.11.0
Successfully installed cocoapods-trunk-1.6.0
Successfully installed cocoapods-search-1.0.1
Successfully installed cocoapods-plugins-1.0.0
Successfully installed cocoapods-downloader-2.1
Successfully installed cocoapods-deintegrate-1.0.5
Building native extensions. This could take a while...
Successfully installed ffi-1.16.3
Successfully installed ethon-0.16.0
Successfully installed typhoeus-1.4.1
Successfully installed public_suffix-4.0.7
Successfully installed fuzzy_match-2.0.4
Successfully installed concurrent-ruby-1.2.2
Successfully installed httpclient-2.8.3
A new major version is available for Algolia! Please now use the https://rubygems.org/gems/algolia gem to get the latest features.
Successfully installed algoliasearch-1.27.5
Successfully installed addressable-2.8.5
Successfully installed tzinfo-2.0.6
Successfully installed i18n-1.14.1
Successfully installed connection_pool-2.4.1
Successfully installed activesupport-7.1.2
Successfully installed cocoapods-core-1.14.3
Successfully installed cocoapods-1.14.3
Parsing documentation for rexml-3.2.6
Installing ri documentation for rexml-3.2.6
Parsing documentation for nanaimo-0.3.0
Installing ri documentation for nanaimo-0.3.0
Parsing documentation for colored2-3.1.2
Installing ri documentation for colored2-3.1.2
Parsing documentation for claide-1.1.0
Installing ri documentation for claide-1.1.0
Parsing documentation for CFPropertyList-3.0.6
Installing ri documentation for CFPropertyList-3.0.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for xcodeproj-1.23.0
Installing ri documentation for xcodeproj-1.23.0
Parsing documentation for ruby-macho-2.5.1
Installing ri documentation for ruby-macho-2.5.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for molinillo-0.8.0
Installing ri documentation for molinillo-0.8.0
Parsing documentation for gh_inspector-1.1.3
Installing ri documentation for gh_inspector-1.1.3
Parsing documentation for fourflusher-2.3.1
Installing ri documentation for fourflusher-2.3.1
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for cocoapods-try-1.2.0
Installing ri documentation for cocoapods-try-1.2.0
Parsing documentation for netrc-0.11.0
Installing ri documentation for netrc-0.11.0
Parsing documentation for cocoapods-trunk-1.6.0
Installing ri documentation for cocoapods-trunk-1.6.0
Parsing documentation for cocoapods-search-1.0.1
Installing ri documentation for cocoapods-search-1.0.1
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-downloader-2.1
Installing ri documentation for cocoapods-downloader-2.1
Parsing documentation for cocoapods-deintegrate-1.0.5
Installing ri documentation for cocoapods-deintegrate-1.0.5
Parsing documentation for ffi-1.16.3
Installing ri documentation for ffi-1.16.3
Parsing documentation for ethon-0.16.0
Installing ri documentation for ethon-0.16.0
Parsing documentation for typhoeus-1.4.1
Installing ri documentation for typhoeus-1.4.1
Parsing documentation for public_suffix-4.0.7
Installing ri documentation for public_suffix-4.0.7
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for concurrent-ruby-1.2.2
Installing ri documentation for concurrent-ruby-1.2.2
Parsing documentation for httpclient-2.8.3
Installing ri documentation for httpclient-2.8.3
Parsing documentation for algoliasearch-1.27.5
Installing ri documentation for algoliasearch-1.27.5
Parsing documentation for addressable-2.8.5
Installing ri documentation for addressable-2.8.5
Parsing documentation for tzinfo-2.0.6
Installing ri documentation for tzinfo-2.0.6
Parsing documentation for i18n-1.14.1
Installing ri documentation for i18n-1.14.1
Parsing documentation for connection_pool-2.4.1
Installing ri documentation for connection_pool-2.4.1
Parsing documentation for activesupport-7.1.2
Couldn't find file to include 'activesupport/README.rdoc' from lib/active_support.rb
Installing ri documentation for activesupport-7.1.2
Parsing documentation for cocoapods-core-1.14.3
Installing ri documentation for cocoapods-core-1.14.3
Parsing documentation for cocoapods-1.14.3
Installing ri documentation for cocoapods-1.14.3
Done installing documentation for rexml, nanaimo, colored2, claide, CFPropertyList, atomos, xcodeproj, ruby-macho, nap, molinillo, gh_inspector, fourflusher, escape, cocoapods-try, netrc, cocoapods-trunk, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, ffi, ethon, typhoeus, public_suffix, fuzzy_match, concurrent-ruby, httpclient, algoliasearch, addressable, tzinfo, i18n, connection_pool, activesupport, cocoapods-core, cocoapods after 20 seconds
35 gems installed

之后就可以用 pod install 安装三方了

你可能感兴趣的:(ios,flutter)