18/10/08/ | Sina 24 | 日常积累

本文详细介绍了在Mac上遇到Homebrew安装错误时的解决步骤,包括定位并修改xcode-select的无效路径,以及如何在VSCode中自定义快捷模板,提升编程效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mac安装homebrew报错

理论上执行下面命令行进行安装homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

可是会报错

xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'
Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

从报错来看,是说 /Library/Developer/CommandLineTools 不是 xcode-select 的有效路径。
新版本跟旧版不同,xcode的命令行工具不再安装在/Library/Developer/CommandLineTools 这个位置

因此要明确解决方法:

  1. 找到 xcode-select 的有效路径
  2. 使用有效路径替换 https://raw.githubusercontent.com/Homebrew/install/master/install 文件中的 /Library/Developer/CommandLineTools

一.查找 xcode-select的有效路径

  • 执行命令获取使用帮助:
xcode-select
  • 查看使用帮助,获得查找路径命令:
xcode-select -p
  • 得到真正路径
/Applications/Xcode.app/Contents/Developer

二.使用有效路径

  • 访问下载文件网址

    https://raw.githubusercontent.com/Homebrew/install/master/install

  • 复制全部内容到编译器中的空白文件

  • 文件内查找

    /Library/Developer/CommandLineTools

  • 全部替换成

    /Applications/Xcode.app/Contents/Developer

  • 保存文件名为install,不管后缀名

  • 在保存该文件的目录下调用终端,执行命令

    ruby -e "$(cat install)"

相关解决方法
通过Xcode命令行编译


vs code中自定义快捷模版

描述:

  • 类似键入html5出现html模版,通过自定义添加方式创建快捷模版。

方法:

  1. 找到用户代码片段在这里插入图片描述
  2. 搜索想配置的款框架在这里插入图片描述
  3. 编辑模版的内容:‘prefix’ 是你键入的表标识 ; ‘$’ 表示模版产生后光标的位置在这里插入图片描述
  4. 分别配置这两项在这里插入图片描述

vs code 关联命令行启动

描述:
使用命令行进入项目目录直接键入启动编译器

在这里插入图片描述方法:command + shift + p --> 安装code命令
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值