2015-02-05 70 views
4

我正试图在AWS Elastic Beanstalk上部署应用程序。我有以下文件中.ebextensions在弹性beanstalk的container_commands中执行命令时没有路径

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,并且将下载的凉亭依赖,编译CoffeeScript的我,缩小/ CONCAT我的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

问题是:为什么我需要指定路径时调用鲍尔?

回答

7

经过大量的调试,似乎PATH已设置但未导出。我只需要调用咕噜之前添加export PATH=$PATH;

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

语法'命令:PATH = $ PATH grunt prod&>>/tmp/deploy.log'也可以工作,因为变量定义命令也允许在用导出的变量设置变量之后运行命令。如果你已经有了一个多行命令,你将需要'export PATH = $ PATH; ...语法。 –

0

请注意,您必须在同一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作为根执行,你必须使用bower install --allow-root

相关问题