巴拉巴拉
小魔仙

git frok app husky 失败

项目中加入了husky, 用于提交commit的时候对代码进行一些格式化, 检查, commit-msg的校验等操作

不过后来更新了一次brew后重新安装了环境, 这些检查就都在git可视化工具fork不能执行了

$ git commit --file=/var/folders/l9/lx74h_wn5z50vvhxmtjlsbkc0000gp/T/216324C1-8E81-4947-9E35-59F292A84464

Can't find yarn in PATH: /usr/local/Cellar/git/2.30.1/libexec/git-core:/Applications/Fork.app/Contents/Resources/git-instance/git-lfs:/Applications/Fork.app/Contents/Resources/gitflow-avh:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Skipping pre-commit hook
Can't find yarn in PATH: /usr/local/Cellar/git/2.30.1/libexec/git-core:/Applications/Fork.app/Contents/Resources/git-instance/git-lfs:/Applications/Fork.app/Contents/Resources/gitflow-avh:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
[333 20b4d44] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
Skipping commit-msg hook
 create mode 100644 a.md

查看日志后分析, 是执行的husky的脚本中找不到依赖yarn函数

从日志中分析出, fork app中的所有路径为

/usr/local/Cellar/git/2.30.1/libexec/git-core
/Applications/Fork.app/Contents/Resources/git-instance/git-lfs
/Applications/Fork.app/Contents/Resources/gitflow-avh
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

检查yarn命令所在的真实路径

which yarn
/Users/xxxxx/.nvm/versions/node/v14.16.0/bin/yarn

可以得出yarn函数不在fork中的环境变量中

解决方案:

建立yarn软连接到 /usr/local/bin/yarn
这个路径用户有直接操作权限, 个别几个系统级别的路径会 Operation not permitted

ln -s /Users/xxxxx/.nvm/versions/node/v14.16.0/bin/yarn /usr/local/bin/yarn
赞(1) 打赏
如果文章对你有帮助,欢迎你来评价反馈。AgainFly » git frok app husky 失败

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  • Q Q(选填)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏