---
title: "Fix for Travis CI failure in forked Golang Repositories"
date: 2015-08-13
lastmod: 2015-08-13
canonical: https://www.ruflin.com/2015/08/13/fix-for-travis-ci-failure-in-forked-golang-repositories/
---

If you have an open source [Golang](https://golang.org/) project on [Github](https://github.com/) and the project is forked, the [Travis CI](https://travis-ci.org/) build will no longer work for the forked project. The reason is that Travis fetches the Golang project and puts it inside the Gopath according to your repository path. In my case, I forked the project `github.com/elastic/packetbeat` to `github.com/ruflin/packetbeat`. On my local setup I still put it under the path `$GOPATH/src/github.com/elastic/packetbeat` as this is where the package is expected by Golang. But as Travis pulls the project from my repository, it puts it into `$GOPATH/src/github.com/ruflin/packetbeat`. To solve this issue, the following code must be added to your `.travis.yml` file:

```shell
before_install:
  - mkdir -p $HOME/gopath/src/github.com/elastic/packetbeat
  - rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/elastic/packetbeat/
  - export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/elastic/packetbeat
  - cd $HOME/gopath/src/github.com/elastic/packetbeat
```

These are the exact same commands Travis uses to set up the project, but with the changed path. This means Travis sets up the project twice, but since all of these commands are very fast, this is not an issue.

It is likely that there is an even simpler way to do this, such as overwriting where Travis should pull the directory, but so far I haven't found such a solution. If you use a different solution, please mention it in the comments so that I can update the post.


