在弹性beanstalk的container_commands中执行命令时没有path

我正在尝试在AWS Elastic Beanstalk上部署应用程序。 我在.ebextensions有以下文件:

 commands: 01-install-git: command: "yum install -y git &>> /tmp/deploy.log" 02-install-nodejs-npm: command: "yum install -y --enablerepo=epel nodejs npm &>> /tmp/deploy.log" 03-install-grunt: command: "npm install -g grunt-cli &>> /tmp/deploy.log" 04-install-coffee: command: "npm install -g coffee-script &>> /tmp/deploy.log" 05-install-bower: command: "npm install -g bower &>> /tmp/deploy.log" container_commands: 01_grunt: command: "export PATH=/usr/local/bin:/bin:/usr/bin; grunt prod &>> /tmp/deploy.log" 

基本上,我想运行grunt prod ,并且会下载bower依赖关系,编译我的coffeescript,缩小/ concat我的js和其他一些东西。 git,nodejs,grunt,coffee和bower安装工作正常(我可以ssh并确认命令是可用的并且在path上)。 但是,如果我不包含export PATH=/usr/local/bin:/bin:/usr/bin; 当打电话给我时,我得到:

 Running "bower:install" (bower) task Fatal error: git is not installed or not in the PATH 

我试图debugging和添加which git &>> /tmp/deploy.log但是得到了which: no git in ((null)) 。 但是,如果我做echo $PATH &>> /tmp/deploy.log我得到一个好看的path: /usr/local/bin:/bin:/usr/bin

问题是:为什么在调用凉亭时需要指定path?

经过大量的debugging,似乎PATH被设置,但没有导出。 我只需要添加export PATH=$PATH; 在调用grunt之前:

 container_commands: 01_grunt: command: "export PATH=$PATH; grunt prod &>> /tmp/deploy.log" 

请注意,您必须在相同的command:执行PATH=$PATH

这不起作用…

 container_commands: 01_path: command: "export PATH=$PATH; echo $PATH &>> /tmp/01_path.log" ignoreErrors: true 02_bower_install: command: "$NODE_HOME/bin/node ./node_modules/bower/bin/bower install --allow-root &>> /tmp/02_bower_install.log" ignoreErrors: true 

因…而失败

 bower no-home HOME environment variable not set. User config will not be loaded. ENOGIT git is not installed or not in the PATH 

注意:由于container_command是以root身份执行的,所以必须使用bower install --allow-root