6

I want to add PATH to packages on eb deploy. Packages are Installed to /var/www/html/vendor/bin

It can be add by manually through SSH, but how can I add PATH with config file.

I have config file like this .ebextensions/ec2.config. 01-set_timezone works fine 02-set_path dosen't

commands:
  01-set_timezone:
    command: cp /usr/share/zoneinfo/Japan /etc/localtime
  02-set_path:
    command: export PATH=$PATH:/var/www/html/vendor/bin

2 Answers2

10

each command is performed in its own shell. so the export won't work. you'd need to put it into ~/.bash_profile to ensure it's executed with every new command.

commands:
  set_path:
    test: test ! -f /opt/elasticbeanstalk/.post-provisioning-complete
    command: echo 'export PATH=$PATH:/var/www/html/vendor/bin' >> /root/.bash_profile

to make it run only once, add the following file:

.ebextensions/99_finalize_setup.config:

commands:
  99_write_post_provisioning_complete_file:
    command: touch /opt/elasticbeanstalk/.post-provisioning-complete
Tal
  • 7,827
  • 6
  • 38
  • 61
  • This will be added PATH to `.bash_profile` every deploy. Is there any way to add path once on each instance. – Tomotsugu Kaneko Dec 10 '15 at 00:34
  • This is the key part of the answer: `each command is performed in its own shell` -- understanding that allowed us to make progress in referencing custom installs of Anaconda & Python and ensuring we were using the right installs of Conda & Flask in subsequent commands in our config script. – tatlar Oct 18 '17 at 17:47
0

To have the PATH available during setup you can do the following.

Create a config file .ebextensions/set_path.conf

option_settings:
  "aws:elasticbeanstalk:application:environment":
    "PATH": "/var/www/html/vendor/bin:$PATH"
Justin Tanner
  • 14,062
  • 17
  • 82
  • 103