diff --git a/.travis.yml b/.travis.yml
index cfdfc5fd2271fcc745b3c576d2ac42dc5e09f8bd..501e18f91b92dfb7999bad33a026c0c81944e0f0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -115,8 +115,7 @@ before_install:
     if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
       # adding apt repos in travis is really fragile => retry a couple of times.
       for i in {1..10}; do sudo apt-add-repository --yes 'ppa:ubuntu-toolchain-r/test' && break; sleep 2; done
-      for i in {1..10}; do sudo apt-get update && break; sleep 2; done
-      for i in {1..10}; do sudo apt-get install gcc-8  $(if [ "$BACKEND" = cpp ]; then echo -n "g++-8"; fi ) && break; sleep 2; done
+      for i in {1..10}; do sudo apt-get update && sudo apt-get install --yes gcc-8  $(if [ "$BACKEND" = cpp ]; then echo -n "g++-8"; fi ) && break; sleep 2; done
       sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 $(if [ "$BACKEND" = cpp ]; then echo " --slave /usr/bin/g++ g++ /usr/bin/g++-8"; fi)
       sudo update-alternatives --set gcc /usr/bin/gcc-8
       export CC=gcc-8