Huon on the internet

travis-cargo 0.1.3: --no-sudo

By Huon Wilson30 Jun 2015

I just pushed travis-cargo version 0.1.3, which adds a --no-sudo command to the coveralls and coverage subcommands to allow recording/uploading test coverage without needing sudo.

This is based0 on @seanmonstar’s investigation/implementation of sudo-less kcov. It works because Travis’s apt addon has whitelisted everything necessary. Unfortunately, it does require these to be installed explicitly, which seems to be something travis-cargo can’t do itself: they seem to have to be explicitly listed in the manifest.

1
2
3
4
5
6
addons:
  apt:
    packages:
      - libcurl4-openssl-dev
      - libelf-dev
      - libdw-dev

This allows leveraging Travis’ container-based infrastructure, with all its benefits, especially around speed and latency. If you switch1, you can check that your builds are using it by looking for the following paragraph in the build-logs:

1
2
3
This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables.
If you require sudo, add 'sudo: required' to your .travis.yml
See http://docs.travis-ci.com/user/workers/container-based-infrastructure/ for details.

--no-sudo is opt-in because it’d be a breaking change to do anything else, and because adding sudo: required is simpler than the whole addons: apt: ... thing.

  1. @jonas-schievink had a similar observation a month ago but I only noticed after already implementing it just today: sorry Jonas! 

  2. I think I have also sometimes found it necessary to also add sudo: false to forcibly opt-in to the container-based infrastructure.