我正在尝试在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,缩小/连接我的js和其他一些东西。 git,nodejs,grunt,coffee和bower安装工作正常(我可以ssh并确认命令可用并且在路径上)。但是,如果我在调用凉亭时没有包含export PATH=/usr/local/bin:/bin:/usr/bin;
部分,我会得到:
Running "bower:install" (bower) task
Fatal error: git is not installed or not in the PATH
我尝试调试并添加which git &>> /tmp/deploy.log
,但获得了which: no git in ((null))
。但是,如果我echo $PATH &>> /tmp/deploy.log
,我会看到一条好看的路径:/usr/local/bin:/bin:/usr/bin
问题是:为什么我需要在调用凉亭时指定路径?
答案 0 :(得分:7)
经过大量调试后,似乎设置了PATH但未导出。我只需要在调用grunt之前添加export PATH=$PATH;
:
container_commands:
01_grunt:
command: "export PATH=$PATH; grunt prod &>> /tmp/deploy.log"
答案 1 :(得分:0)
请注意,您必须在同一PATH=$PATH
内执行command:
。
这不起作用......
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