执行gcloud app deploy遇INVALID_ARGUMENT错误,求调试方法
解决gcloud app deploy时的"Any spaces must be in the middle of a filename"错误
问题场景
执行gcloud app deploy部署App Engine应用时,返回以下错误:
descriptor: [/home/ilija/code/meezer/backend/app.yaml] source: [/home/ilija/code/meezer/backend] target project: [mosh-marketplace-7eca5] target service: [default] target version: [20230319812345] target url: [https://mosh-marketplace-7eca5.uc.r.appspot.com] target service account: [App Engine default service account] Do you want to continue (Y/n)? y Beginning deployment of service [default]... ╔════════════════════════════════════════════════════════════╗ ╠═ Uploading 0 files to Google Cloud Storage ═╣ ╚════════════════════════════════════════════════════════════╝ File upload done. ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: Any spaces must be in the middle of a filename:
调试与解决步骤
1. 定位带问题的文件/目录
错误核心是文件名/目录名的空格位置不符合要求(比如开头、结尾有空格,而非中间)。执行以下命令扫描部署目录下所有带空格的文件和目录:
find /home/ilija/code/meezer/backend -name "* *"
重点检查结果中是否存在:
- 开头带空格的文件/目录(如
"readme.md") - 结尾带空格的文件/目录(如
readme.md) - 连续多个空格的文件/目录(如
file .txt)
2. 启用调试日志定位具体文件
如果扫描结果未发现明显问题,用verbose模式重新部署,获取更详细的扫描日志:
gcloud app deploy --verbosity=debug
日志中会列出部署工具扫描到的所有文件,从中找到触发错误的目标文件。
3. 检查app.yaml配置
确认app.yaml中所有路径配置(如handlers下的static_files、upload、script字段)没有引用带无效空格的路径,也不要在路径开头/结尾添加多余空格。
4. 修复问题并重新部署
- 重命名所有带无效空格的文件/目录,确保空格仅出现在文件名中间(如将
"temp file.txt"改为temp file.txt) - 若存在部署缓存干扰,添加
--no-cache参数重新部署:gcloud app deploy --no-cache
内容的提问来源于stack exchange,提问作者Ilija
相关产品推荐
相关产品推荐

