You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Elastic Beanstalk部署含Git子模块的代码无执行权限问题

解决Elastic Beanstalk部署Git子模块权限问题

方法1:通过Git配置忽略权限变更

从源头避免Git同步子模块时重置文件权限:

  • 进入本地子模块仓库目录,关闭Git的文件权限检测:
    git config core.fileMode false
    
  • 提交子模块的Git配置变更:
    git add .git/config
    git commit -m "Disable file mode tracking to preserve permissions"
    
  • 返回主项目仓库,更新子模块引用并提交:
    git submodule update --remote
    git add path/to/your/submodule
    git commit -m "Update submodule with permission fix"
    
  • 重新执行eb deploy部署项目

方法2:用Elastic Beanstalk扩展配置强制修正权限

让Beanstalk在部署后自动调整子模块权限:

  1. 在项目根目录创建.ebextensions文件夹(如果不存在)
  2. 在该文件夹下创建01-submodule-permissions.config文件,内容如下:
    container_commands:
      01_fix_submodule_perms:
        command: "chmod -R 755 /var/app/current/[你的子模块路径]"
        leader_only: false
    
    把[你的子模块路径]替换成实际的子模块相对路径,比如my_submodule
  3. 提交这个配置文件到Git,然后重新执行eb deploy

方法3:直接修正子模块仓库的文件权限

如果子模块仓库本身的Python文件权限就不对,直接在子模块里修改后同步:

  • 进入本地子模块目录,修改所有Python文件的权限:
    chmod +x *.py
    # 如果子模块有子目录,递归修改
    find . -name "*.py" -exec chmod +x {} \;
    
  • 提交并推送子模块的权限变更:
    git add .
    git commit -m "Fix Python file execution permissions"
    git push
    
  • 回到主项目仓库,更新子模块引用并重新部署:
    git submodule update --remote
    git add path/to/your/submodule
    git commit -m "Update submodule with fixed permissions"
    eb deploy
    

内容的提问来源于stack exchange,提问作者hoshmy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 09:15:35