命令行安装Xcode-select
解决报错xcode-select: error: command line tools are already installed, use “Software Update”
报错信息
youtai@macdeMacBook-Pro server % go run main.go
# runtime/cgo
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.
youtai@macdeMacBook-Pro Developer % xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
youtai@macdeMacBook-Pro Developer % Software Update
zsh: command not found: Software
# 打印出来的目录不存在
youtai@macdeMacBook-Pro Developer % xcode-select -p
/Applications/Xcode.app/Contents/Developer
youtai@macdeMacBook-Pro CommandLineTools % Software Update
zsh: command not found: Software
解决办法:
- 到苹果开发者官网的下载专区搜索Command Line Tools并下载安装包。
要下载对应版本的安装包
如下, 查看 CLT: 14.2.0.0.1.1668646533 这信息
查看配适合系统的安装包版本
youtai@macdeMacBook-Pro ~ % brew config
HOMEBREW_VERSION: 3.4.5-16-gf6ab300
ORIGIN: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
HEAD: f6ab300fc169777705f025c67c4b7c35605f4a66
Last commit: 2 years ago
Core tap ORIGIN: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
Core tap HEAD: cd8aa98141fb099894c52dcf0a4d0316f58af7f5
Core tap last commit: 2 years ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit skylake
Clang: 14.0.0 build 1400
Git: 2.35.1 => /usr/local/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 12.7.3-x86_64
CLT: 14.2.0.0.1.1668646533
Xcode: N/A
或者到下面连接查询
https://xcodereleases.com/
下载后双击安装即可。
这里我下载:
Command_Line_Tools_for_Xcode_14.2.dmg
2.命令行安装
xcode-select –version // 查看版本
xcode-select –install // 安装命令
一般Xcode安装后,第一次打开时,会弹窗提示安装Command Line Tools
,直接安装即可。
有时Command Line Tools
出了问题,可以先尝试恢复默认设置来解决:
// 恢复默认设置(需要sudo权限)
sudo xcode-select –reset
还是解决不了,可以考虑删掉后重新安装:
// 强制删除安装目录下的文件
sudo rm -rf /Library/Developer/CommandLineTools
// 重新安装
xcode-select –install
安装界面xcode
到下面的网站下载安装包
https://developer.apple.com/download/all/?q=xcode
这里我下载 Xcode 14.2
作者:海马 创建时间:2024-04-05 14:55
最后编辑:海马 更新时间:2024-12-22 19:32
最后编辑:海马 更新时间:2024-12-22 19:32