Search code examples
javaspring-bootmaventestingtravis-ci

Travis failing all builds "bad interpreter: No such file or directory"


for some reasons all the builds in travis are failing in my spring boot project with maven, I don't have a clue why it's happening since I have used it for django projects and it worked fine.

This is my travis.yml, quite simple

dist: trusty
language: java
jdk: oraclejdk8
services:
  - mysql
before_install:
  - mysql -e 'CREATE DATABASE petclinic;'
script: mvn test -Dspring.profiles.active=mysql-travis

and this is the travis trace I get every time

$ java -Xmx32m -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
$ javac -J-Xmx32m -version
javac 1.8.0_151
before_install
0.01s$ mysql -e 'CREATE DATABASE petclinic;'
3.01s$ ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
/home/travis/.travis/functions: ./mvnw: /bin/sh^M: bad interpreter: No such file or directory
The command "eval ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying, 2 of 3.
/home/travis/.travis/functions: ./mvnw: /bin/sh^M: bad interpreter: No such file or directory
The command "eval ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying, 3 of 3.
/home/travis/.travis/functions: ./mvnw: /bin/sh^M: bad interpreter: No such file or directory
The command "eval ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed 3 times.
The command "./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V" failed and exited with 126 during .
Your build has been stopped.

I never had this error in my django projects so I'm not sure what's happening, and searching for this error in the web didn't give me a solution related to travis


Solution

  • Really stupid error. For some strange reason the mvnw file in the root was modified. The first line was supposed to be the comment:

    "# !/bin/sh"
    

    but for some reason it became

    #!/bin/sh
    

    and travis though it wasn't a comment.