---
title: Composer, Travis and Bash Source
date: 2018-05-30T11:23:31+00:00
modified: 2018-06-01T07:52:09+00:00
image:: https://kaspars.net/wp-content/uploads/2018/05/travis-error-composer-source.png
permalink: https://kaspars.net/blog/composer-travis-bash-source
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
category:
  - Development
  - Linux
post_tag:
  - PHP
---

# Composer, Travis and Bash Source

Today I learned that Composer [uses](https://github.com/composer/composer/blob/ea78712822e2efecf177cdd01f5c001587b47e8e/src/Composer/Util/ProcessExecutor.php#L65-L68) the [Symphony Process component](https://github.com/symfony/process) for executing the shell commands defined as [Composer scripts](https://getcomposer.org/doc/articles/scripts.md). This [internally calls](https://github.com/symfony/process/blob/4f10286a128df6b60b3706752e11f6227fcac844/Process.php#L304) `proc_open()` [which](https://www.daemon-systems.org/man/popen.3.html) “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](https://travis-ci.org/xwp/wp-dev-lib/builds/385632956#L1013):

```
{
  "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](https://travis-ci.org/xwp/wp-dev-lib/jobs/385635734#L1011) 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](https://ss64.com/bash/source.html) 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).