2015-02-05 68 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

相關問題