【bug fixed】hexo d的时候Spawn failed

在执行hexo d部署的时候,遇到报错:

% hexo d
INFO  Validating config
INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
INFO  Copying files from extend dirs...
[main 8e89088] Site updated: 2024-09-27 16:41:34
 4 files changed, 27 insertions(+), 27 deletions(-)
Enumerating objects: 733, done.
Counting objects: 100% (733/733), done.
Delta compression using up to 8 threads
Compressing objects: 100% (415/415), done.
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (733/733), 60.61 MiB | 23.52 MiB/s, done.
Total 733 (delta 185), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
    at ChildProcess.<anonymous> (/Users/zhaodongyu/Documents/Blog/node_modules/hexo-util/lib/spawn.js:51:21)
    at ChildProcess.emit (node:events:520:28)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)

看信息与 Hexo 的部署到 Git 仓库过程中发生的 RPC failed 错误有关。

错误信息中显示有 60.61 MiB 的数据,这会超过 GitHub 或其他 Git 服务器的默认传输大小限制。

我通过增加 Git 的 HTTP 传输缓冲区大小来解决:

git config --global http.postBuffer 524288000

这会将 Git 的 HTTP 缓冲区增加到 500MB(默认是 1MB)。

问题解决。


如果这样还是不能解决,在hexo的官网中也有相关讨论:
请添加图片描述

<think>好的,用户遇到了Hexo部署到GitHub时执行hexo d命令报spawn failed错误的问题,需要解决方案。首先,我需要回顾一下之前收集的相关引用信息,看看有哪些解决方法已经提供过。 根据引用[2]和[3],常见的解决方法包括检查网络连接、Git配置,修改deploy.repo为SSH格式,检查分支设置,删除.deploy_git文件夹,调整Git超时设置等。引用[4]提到了增加Git的postBuffer和调整低速限制参数。用户可能没有正确配置部署仓库的地址,或者网络问题导致连接失败,也可能是.git配置或文件权限问题。 接下来,我需要整理这些解决方案,按照逻辑顺序排列,确保用户能够一步步排查问题。首先应该检查最基本的网络连接和Git配置,然后检查仓库地址是否正确,接着处理可能的文件夹冲突,最后考虑调整Git的超时设置。此外,可能还需要提醒用户在执行每个步骤后都要重新生成和部署,比如hexo clean && hexo g && hexo d。 同时,要注意用户是否在Windows系统上,因为路径分隔符或换行符的问题可能导致错误,引用[3]中提到设置core.autocrlf为false可能有效。另外,确保用户使用的是SSH密钥认证而不是HTTPS,避免密码输入的问题。 最后,生成相关问题,帮助用户进一步解决可能遇到的关联问题,比如如何生成SSH密钥,或者如何检查部署状态等。需要确保回答结构清晰,步骤详细,用户能够跟随操作。</think>### 解决Hexo部署到GitHub时`hexo d`报错"Spawn failed"的步骤 #### 1. **检查网络连接** - 使用命令`ping github.com`测试网络连通性。若无法连接,需检查代理或防火墙设置[^2]。 - 如果使用HTTPS协议,尝试切换为SSH协议(见步骤3)以规避网络限制[^3]。 #### 2. **验证Git配置** - 打开Hexo主目录的`_config.yml`文件,检查`deploy`配置是否为以下格式: ```yaml deploy: type: git repo: git@github.com:用户名/用户名.github.io.git # SSH格式 branch: main # 分支需与GitHub仓库设置一致 ``` 错误的仓库地址(如使用HTTPS链接)或分支名称会导致认证失败[^2]。 #### 3. **处理`.deploy_git`文件夹冲突** - 删除本地生成的部署文件夹: ```bash rm -rf .deploy_git/ ``` - 针对Windows系统,执行以下命令避免换行符问题: ```bash git config --global core.autocrlf false ``` 随后重新执行`hexo clean && hexo g && hexo d`[^3]。 #### 4. **调整Git超时设置** - 增大缓冲区大小并延长超时时间: ```bash git config --global http.postBuffer 524288000 git config --global http.lowSpeedLimit 0 git config --global http.lowSpeedTime 99999 ``` 此操作适用于大仓库或网络不稳定场景[^4]。 #### 5. **检查SSH密钥** - 生成并绑定SSH密钥到GitHub: ```bash ssh-keygen -t ed25519 -C "your_email@example.com" cat ~/.ssh/id_ed25519.pub ``` 将公钥添加到GitHub账户的`SSH and GPG keys`设置中,确保免密推送权限[^3]。 #### 6. **重装部署插件** - 若上述步骤无效,尝试卸载并重新安装`hexo-deployer-git`: ```bash npm uninstall hexo-deployer-git --save npm install hexo-deployer-git --save ``` --- ### 操作验证 完成修改后,按顺序执行: ```bash hexo clean # 清除缓存 hexo g # 重新生成静态文件 hexo d # 部署到GitHub ``` 若仍报错,可在命令后添加`--debug`参数查看详细日志: ```bash hexo d --debug ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值