簡體   English   中英

安裝 Ruby 后 MAC OS X 上的活動開發者路徑無效

[英]Invalid active developer path on MAC OS X after installing Ruby

我收到此錯誤:

xcrun: error: invalid active developer path (/Applications/Xcode.app), missing xcrun at: /Applications/Xcode.app/usr/bin/xcrun

解決方案有效,但關閉我的終端並重新打開后再次出現錯誤; 然后,每次打開新的終端窗口時,我都必須運行相同的命令。

如何應用這些更改,以便在關閉終端窗口后保存它們?

更新到 OS X El Capitan 后,我開始遇到同樣的錯誤。
就我而言,我所做的就是安裝它:

sudo xcode-select --install

它對我來說很好用。

[更新]以下步驟適用於 OS X 10.10 (Yosemite)。 那些因為升級到 10.11 (El Capitan) 而遇到這種情況的人似乎只sudo xcode-select --install按照已接受的答案中的描述運行sudo xcode-select --install

我在這里找到了一個建議它表明

sudo xcode-select -switch /

作為修復。 但是,這引發了開發人員路徑無效的錯誤。

相反,對我來說,我將其修改為

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/

(這是兩個參考鏈接解決方案的混合)並且這有效。

[編輯]

嘗試使用

xcode-select --print-path

如果 /Applications/Xcode.app/Contents/Developer/ 對您仍然無效,請找到您的開發人員路徑。

我知道這已經很老了,但我遇到了同樣的問題,然后我通過執行更多額外步驟來修復它。 當終端找不到命令行工具的實際路徑時,問題就出現了。

  1. 如果您擁有 Xcode 然后將其刪除,則終端指的是 Xcode 文件夾中的命令行工具。 嘗試使用此命令並檢查您的路徑是什么, xcode-select --print-path 這很可能會打印/Applications/Xcode.app/Contents/Developer
  2. 現在要解決此問題,請重新安裝 xcode 的命令行工具。 最初使用sudo rm -rf /Library/Developer/CommandLineTools刪除任何以前的安裝。
  3. 然后安裝命令行工具sudo xcode-select --install現在最后一步,使用sudo xcode-select -switch /Library/Developer/CommandLineTools/將 CLT 的路徑更改為實際路徑,這將修復它。

將 macOS Mojave 更新為 macOS Catalina 后,我開始遇到相同的錯誤。

我剛剛在終端中安裝了幾個命令行,

 1. $ sudo gem install cocoapods
 2. $ sudo xcode-select --install
 3. $ chsh -s /bin/zsh

然后,

Xcode -> Preferences -> Locations -> Command Line Tools and confirm you have current Xcode version selected there.

它對我來說很好用。 謝謝!!

我通過以下步驟解決了這個問題。

Xcode -> Preferences -> Locations -> Command Line Tools ->選擇與您的 Xcode 版本匹配的命令工具。

對我來說,解決方案就像重新安裝 Xcode 一樣簡單。

這里指出: https : //superuser.com/a/981126

您可以像上面建議的答案一樣通過命令行(重新)安裝 Xcode,或者直接從 App Store 安裝。

升級到 OS X EI Captian 后,我也遇到了同樣的問題。 我剛剛使用sudo xcode-select --install

sudo xcode-select -switch /對我sudo xcode-select -switch /

當我刪除安裝的兩個 Xcode 之一時,我遇到了同樣的問題。

我已經通過使用如下終端切換路徑解決了這個問題

$ sudo xcode-select --switch(將 Xcode 拖到此處以獲取路徑)

例如 sudo xcode-select --switch /Applications/Xcode\\ 10.1.app

部分診斷: https : //github.com/microsoft/vcpkg/issues/8781#issuecomment-547248760

似乎從一個 MacOS 版本升級到另一個版本會卸載一些開發工具,或者將它們移動到另一條路徑,這會破壞與使用指向工具所在舊位置的環境變量的任何工具的兼容性。

sudo xcode-select --install

使用 install 命令對我有用,但不清楚這是否只是下載並解壓縮文件然后跳過安裝並簡單地更新環境變量,或者是否將文件物理安裝在預期路徑上。 (或者它可以鏈接到新文件夾路徑)。

測試我的理論,我用ls探測文件夾結構(我應該在使用 install 命令之前這樣做):

rej@Ryans-MacBook-Air:~$ ls /Library/Developer/CommandLineTools/usr/bin/
rej@Ryans-MacBook-Air:~$ ls -la /Library/Developer/CommandLineTools/usr/bin/
total 243776
drwxr-xr-x  124 root  wheel   3.9K Oct 28 23:03 ./
drwxr-xr-x    7 root  admin   224B Oct 28 23:05 ../
lrwxr-xr-x    1 root  wheel    64B Oct 28 23:03 2to3@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/2to3
lrwxr-xr-x    1 root  wheel    68B Oct 28 23:03 2to3-3.7@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/2to3-3.7
-rwxr-xr-x    1 root  wheel   116K Sep  5 22:51 DeRez*
-rwxr-xr-x    1 root  wheel    31K Sep  5 22:51 GetFileInfo*
-rwxr-xr-x    1 root  wheel    33K Sep  5 22:51 ResMerger*
-rwxr-xr-x    1 root  wheel   126K Sep  5 22:51 Rez*
-rwxr-xr-x    1 root  wheel    31K Sep  5 22:51 SetFile*
-rwxr-xr-x    1 root  wheel    32K Sep  5 22:51 SplitForks*
-rwxr-xr-x    1 root  wheel    41K Sep  5 22:51 ar*
-rwxr-xr-x    1 root  wheel    40K Sep  5 22:51 as*
-rwxr-xr-x    1 root  wheel    27K Sep  5 22:51 asa*
-rwxr-xr-x    1 root  wheel   216K Sep  5 22:51 bison*
-rwxr-xr-x    1 root  wheel   159K Sep  5 22:51 bitcode_strip*
lrwxr-xr-x    1 root  wheel     5B Oct 28 23:03 c++@ -> clang
-rwxr-xr-x    1 root  admin    31K Sep  5 22:51 c89*
-rwxr-xr-x    1 root  admin    31K Sep  5 22:51 c99*
lrwxr-xr-x    1 root  wheel     5B Oct 28 23:03 cc@ -> clang
-rwxr-xr-x    1 root  wheel    80M Sep  5 22:51 clang*
lrwxr-xr-x    1 root  wheel     5B Oct 28 23:03 clang++@ -> clang
-rwxr-xr-x    1 root  wheel   125K Sep  5 22:51 cmpdylib*
-rwxr-xr-x    1 root  wheel   154K Sep  5 22:51 codesign_allocate*
lrwxr-xr-x    1 root  wheel    17B Oct 28 23:03 codesign_allocate-p@ -> codesign_allocate
-rwxr-xr-x    1 root  admin   3.3K Aug 16 06:55 cpp*
-rwxr-xr-x    1 root  wheel    36K Sep  5 22:51 ctags*
-rwxr-xr-x    1 root  wheel   150K Sep  5 22:51 ctf_insert*
-rwxr-xr-x    1 root  wheel    30M Sep  5 22:51 dsymutil*
lrwxr-xr-x    1 root  wheel    14B Oct 28 23:03 dwarfdump@ -> llvm-dwarfdump
-rwxr-xr-x    1 root  wheel   477K Sep  5 22:51 dwarfdump-classic*
-rwxr-xr-x    1 root  wheel   211K Sep  5 22:51 dyldinfo*
-rwxr-xr-x    1 root  wheel   239B Sep  5 19:18 easy_install-3.7*
-rwxr-xr-x    1 root  wheel   572K Sep  5 22:51 flex*
-rwxr-xr-x    1 root  wheel   572K Sep  5 22:51 flex++*
lrwxr-xr-x    1 root  wheel     3B Oct 28 23:03 g++@ -> gcc
-rwxr-xr-x    1 root  wheel   101K Aug 16 07:31 gatherheaderdoc*
-rwxr-xr-x    1 root  admin    27K Sep  5 22:51 gcc*
lrwxr-xr-x    1 root  wheel     8B Oct 28 23:03 gcov@ -> llvm-cov
-rwxr-xr-x    1 root  wheel   2.4M Sep  5 22:51 git*
lrwxr-xr-x    1 root  wheel     3B Oct 28 23:03 git-receive-pack@ -> git
-rwxr-xr-x    1 root  wheel   1.4M Sep  5 22:51 git-shell*
lrwxr-xr-x    1 root  wheel     3B Oct 28 23:03 git-upload-archive@ -> git
lrwxr-xr-x    1 root  wheel     3B Oct 28 23:03 git-upload-pack@ -> git
-rwxr-xr-x    1 root  wheel   148K Sep  5 22:51 gm4*
-rwxr-xr-x    1 root  wheel   166K Sep  5 22:51 gnumake*
-rwxr-xr-x    1 root  wheel    98K Sep  5 22:51 gperf*
-rwxr-xr-x    1 root  wheel    33K Sep  5 22:51 hdxml2manxml*
-rwxr-xr-x    1 root  wheel   158K Aug 16 07:31 headerdoc2html*
-rwxr-xr-x    1 root  wheel    73K Sep  5 22:51 indent*
-rwxr-xr-x    1 root  wheel   142K Sep  5 22:51 install_name_tool*
-rwxr-xr-x    1 root  wheel   2.5M Sep  5 22:51 ld*
-rwxr-xr-x    1 root  wheel   230B Aug 16 07:13 lex*
-rwxr-xr-x    1 root  wheel   163K Sep  5 22:51 libtool*
-rwxr-xr-x    1 root  wheel    73K Sep  5 22:51 lipo*
-rwxr-xr-x    1 root  wheel   332K Sep  5 22:51 lldb*
-rwxr-xr-x    1 root  wheel   3.6M Sep  5 22:51 llvm-cov*
-rwxr-xr-x    1 root  wheel   7.9M Sep  5 22:51 llvm-dwarfdump*
-rwxr-xr-x    1 root  wheel   9.8M Sep  5 22:51 llvm-nm*
-rwxr-xr-x    1 root  wheel    11M Sep  5 22:51 llvm-objdump*
-rwxr-xr-x    1 root  wheel    40K Sep  5 22:51 llvm-otool*
-rwxr-xr-x    1 root  wheel   1.6M Sep  5 22:51 llvm-profdata*
-rwxr-xr-x    1 root  wheel   2.9M Sep  5 22:51 llvm-size*
-rwxr-xr-x    1 root  wheel   3.5K Aug 16 07:19 lorder*
-rwxr-xr-x    1 root  wheel   148K Sep  5 22:51 m4*
-rwxr-xr-x    1 root  wheel   166K Sep  5 22:51 make*
-rwxr-xr-x    1 root  wheel   7.7K Aug 16 07:16 mig*
lrwxr-xr-x    1 root  wheel     7B Oct 28 23:03 nm@ -> llvm-nm
-rwxr-xr-x    1 root  wheel   142K Sep  5 22:51 nm-classic*
-rwxr-xr-x    1 root  wheel   171K Sep  5 22:51 nmedit*
lrwxr-xr-x    1 root  wheel    12B Oct 28 23:03 objdump@ -> llvm-objdump
lrwxr-xr-x    1 root  wheel    10B Oct 28 23:03 otool@ -> llvm-otool
-rwxr-xr-x    1 root  wheel   644K Sep  5 22:51 otool-classic*
-rwxr-xr-x    1 root  wheel   138K Sep  5 22:51 pagestuff*
-rwxr-xr-x    1 root  wheel   221B Sep  5 19:18 pip3*
-rwxr-xr-x    1 root  wheel   221B Sep  5 19:18 pip3.7*
-rwxr-xr-x    1 root  wheel    32K Sep  5 22:51 projectInfo*
lrwxr-xr-x    1 root  wheel    66B Oct 28 23:03 pydoc3@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/pydoc3
lrwxr-xr-x    1 root  wheel    68B Oct 28 23:03 pydoc3.7@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/pydoc3.7
lrwxr-xr-x    1 root  wheel    67B Oct 28 23:03 python3@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/python3
lrwxr-xr-x    1 root  wheel    74B Oct 28 23:03 python3-config@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/python3-config
lrwxr-xr-x    1 root  wheel    69B Oct 28 23:03 python3.7@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/python3.7
lrwxr-xr-x    1 root  wheel    76B Oct 28 23:03 python3.7-config@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/python3.7-config
lrwxr-xr-x    1 root  wheel    70B Oct 28 23:03 python3.7m@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/python3.7m
lrwxr-xr-x    1 root  wheel    77B Oct 28 23:03 python3.7m-config@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/python3.7m-config
lrwxr-xr-x    1 root  wheel    66B Oct 28 23:03 pyvenv@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/pyvenv
lrwxr-xr-x    1 root  wheel    70B Oct 28 23:03 pyvenv-3.7@ -> ../../Library/Frameworks/Python3.framework/Versions/3.7/bin/pyvenv-3.7
lrwxr-xr-x    1 root  wheel     7B Oct 28 23:03 ranlib@ -> libtool
-rwxr-xr-x    1 root  wheel    70K Sep  5 22:51 resolveLinks*
-rwxr-xr-x    1 root  wheel    85K Sep  5 22:51 rpcgen*
-rwxr-xr-x    1 root  wheel    56K Sep  5 22:51 segedit*
lrwxr-xr-x    1 root  wheel    12B Oct 28 23:03 size@ -> size-classic
-rwxr-xr-x    1 root  wheel   125K Sep  5 22:51 size-classic*
-rwxr-xr-x    1 root  admin   138K Sep  5 22:51 stapler*
-rwxr-xr-x    1 root  wheel   126K Sep  5 22:51 strings*
-rwxr-xr-x    1 root  wheel   179K Sep  5 22:51 strip*
-rwxr-xr-x    1 root  wheel   330K Sep  5 22:51 svn*
-rwxr-xr-x    1 root  wheel   118K Sep  5 22:51 svnadmin*
-rwxr-xr-x    1 root  wheel   105K Sep  5 22:51 svnbench*
-rwxr-xr-x    1 root  wheel    64K Sep  5 22:51 svndumpfilter*
-rwxr-xr-x    1 root  wheel    71K Sep  5 22:51 svnfsfs*
-rwxr-xr-x    1 root  wheel    98K Sep  5 22:51 svnlook*
-rwxr-xr-x    1 root  wheel    70K Sep  5 22:51 svnmucc*
-rwxr-xr-x    1 root  wheel    89K Sep  5 22:51 svnrdump*
-rwxr-xr-x    1 root  wheel   122K Sep  5 22:51 svnserve*
-rwxr-xr-x    1 root  wheel    90K Sep  5 22:51 svnsync*
-rwxr-xr-x    1 root  wheel    44K Sep  5 22:51 svnversion*
-rwxr-xr-x    1 root  wheel    90M Sep  5 22:51 swift*
lrwxr-xr-x    1 root  wheel     5B Oct 28 23:03 swift-autolink-extract@ -> swift
-rwxr-xr-x    1 root  admin   6.1M Sep  5 22:51 swift-build*
-rwxr-xr-x    1 root  admin   734K Sep  5 22:51 swift-build-tool*
-rwxr-xr-x    1 root  wheel   687K Sep  5 22:51 swift-demangle*
lrwxr-xr-x    1 root  wheel     5B Oct 28 23:03 swift-format@ -> swift
-rwxr-xr-x    1 root  admin   6.1M Sep  5 22:51 swift-package*
-rwxr-xr-x    1 root  admin   6.1M Sep  5 22:51 swift-run*
-rwxr-xr-x    1 root  wheel    61K Sep  5 22:51 swift-stdlib-tool*
-rwxr-xr-x    1 root  admin   6.1M Sep  5 22:51 swift-test*
lrwxr-xr-x    1 root  wheel     5B Oct 28 23:03 swiftc@ -> swift
-rwxr-xr-x    1 root  wheel    12M Sep  5 22:51 tapi*
-rwxr-xr-x    1 root  wheel    41K Sep  5 22:51 unifdef*
-rwxr-xr-x    1 root  wheel   2.9K Aug 16 07:19 unifdefall*
-rwxr-xr-x    1 root  wheel    63K Sep  5 22:51 unwinddump*
-rwxr-xr-x    1 root  wheel    49K Sep  5 22:51 vtool*
-rwxr-xr-x    1 root  wheel    45K Sep  5 22:51 xml2man*
-rwxr-xr-x    1 root  wheel   135B Aug 16 07:22 yacc*

很明顯,這些文件實際上位於該文件夾位置,並且安裝程序安裝了缺少的組件。 MacOS 的升級過程卸載了我的開發環境的事實是不友好的,Apple 應該受到譴責。

從 macOS Mojave v10.14 升級到 Catalina v10.15 后,我第一次運行 Homebrew 時遇到了類似的錯誤。

在不了解 Homebrew 安裝有什么問題以及這些命令實際上做了什么的情況下運行命令絕不是一個好主意。 您的第一個也是最好的選擇是運行brew doctor 此命令不僅會告訴您是否有問題,還會告訴您如何解決問題。 就我而言,它顯示:

Warning: Your Xcode is configured with an invalid path.
You should change it to the correct path:
  sudo xcode-select -switch /Applications/Xcode.app

解決問題后,再次運行brew doctor 基本上,重復這個過程,直到你得到所有明確的信息。

在某些情況下,您會得到類似的信息:

Unbrewed dylibs/header files/static libraries were found in /usr/local/....

如果您在 Homebrew 之外安裝了同樣使用相同位置來存儲文件的軟件,就會發生這種情況。 在許多情況下,忽略這些警告是安全的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM