前言

昨天晚上,我兴致勃勃的打开了cmd窗口,准备写一篇有关了解Kaggle的博客,当我文思泉涌,啪嗒啪嗒地码完整篇文章,理所当然地执行hexo clean && hexo g && hexo d部署到github时,终端窗口冷不丁地弹出了几行绚丽的错误:

1
2
3
4
5
6
7
Please make sure you have the correct access rights and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (D:\blog\hexo\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (node:events:513:28)
at cp.emit (D:\blog\hexo\node_modules\cross-spawn\lib\enoent.js:34:29)
at ChildProcess._handle.onexit (node:internal/child_process:291:12)

解决方案

删除文件夹

网上的解决方案大多是这种,但是并没有解决我自己的问题,在此只是将其列出,作为一种通用方案。

原理:我们在进行git pushhexo d的时候改变了一些.deploy_git文件夹下的内容。

  1. 删除.deploy_git文件夹
  2. cmd中输入git config --global core.autocrlf false
  3. 依次执行hexo clean&&hexo g&&hexo d

问题解决,皆大欢喜,如果错误依旧,请参考下面的方法。

github端口问题

验证:我们正常使用git pull进行拉取,终端中会显示下面的错误:

1
2
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

这个错误提示的是连接github.com的22端口被拒绝了。

由于22端口可能被防火墙屏蔽了,我们可以尝试连接github的443端口。

如果没有.ssh文件夹,可参考Github生成密钥,了解ssh的作用。

  1. 我们打开C盘中的.ssh文件夹,在其中新建config文件,注意这个文件没有后缀,编辑其内容为:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Host github.com
    User git
    Hostname ssh.github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    Port 443

    Host gitlab.com
    Hostname altssh.gitlab.com
    User git
    Port 443
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
  2. 修改完成后,在终端中敲入ssh -T git@github.com来测试和Github的网络通信是否正常,如果有下面的提示,就表示一切正常了:
    1
    2
    3
    D:\blog\hexo>ssh -T git@github.com
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Hi yanzhuang-h! You've successfully authenticated, but GitHub does not provide shell access.

接下来我们便可以尝试正常的blog部署操作。

关于其他的方法,后续我看到了将会继续总结到此片博客中。