Composer, Travis and Bash Source

Today I learned that Composer uses the Symphony Process component for executing the shell commands defined as Composer scripts. This internally calls proc_open() which “opens a process by creating a bidirectional pipe, forking, and invoking the shell”.

I had this script failing on a Travis build with Ubuntu 14.04.5 LTS and PHP 5.6:

{
  "scripts": {
    "test": "source scripts/test.sh"
  }
}

with the following error:

sh: 1: source: not found

Turns out that /bin/sh on Ubuntu Trusty is a symlink to /bin/dash:

$ ls -lah /bin/sh
lrwxrwxrwx 1 root root 4 Feb 19  2014 /bin/sh -> dash

And the source command is a bash built-in which simply isn’t available in dash. The solution is to replace all instances of source something.sh with . something.sh (note the space between the dot and the script filename).

Leave a Reply