diff --git a/.travis.yml b/.travis.yml
index 307e605..73aa95c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,8 @@ before_install:
  # workaround for /usr/local/Library/ENV/4.3/sed: No such file or directory
  # http://stackoverflow.com/a/38471887
  - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew reinstall -s libtool; fi
+ # https://github.com/travis-ci/travis-ci/issues/6307
+ - if [ "$TRAVIS_OS_NAME" = "osx" ]; then rvm get stable; fi
 
 script:
  # abort on any command failure
@@ -22,8 +24,12 @@ script:
  - test -z "$commit" || git checkout $commit
  - git log -1
  - autoreconf -f -i
- - ./configure --prefix=/usr
+ - case "$TRAVIS_OS_NAME" in osx) prefix=/usr/local;; linux) prefix=/usr;; esac
+ - ./configure --prefix=$prefix
  - make -j4
+   # remove system file package first
+   # see https://github.com/file/file-tests/issues/3
+ - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get remove -y libmagic1 file; fi
  - sudo make install
  - cd ..
  - which file