Cargo tarpaulin fails

Dear CircleCI,

I’m using CircleCI to generate coverage reports for some Rust projects. This used to work really well: the coverage tool, Tarpaulin, comes as a xd009642/tarpaulin docker image and all I needed to make it run was

version: 2
jobs:
  build:
    docker:
      - image: xd009642/tarpaulin
    steps:
      - checkout
      - run:
          name: Generate coverage report
          command: cargo tarpaulin --out Xml --all-features

Beautiful! Easy to set up and the container ran with lightning speed.

However, recently I’m seeing the builds fail with

[ERROR tarpaulin] Failed to run tests! Error: ASLR disable failed: EPERM: Operation not permitted

You’ll find the builds under https://circleci.com/gh/mgeisler/textwrap:

  • Build 53: worked on 2019-04-25
  • Build 54: failed on 2019-05-04

Does anybody know what changed between last week and today?

Tarpaulin tells people to avoid running tests in containers on TravisCI, to avoid this issue: fails on travis with ASLR disable failed: EPERM · Issue #77 · xd009642/tarpaulin · GitHub. Is there anything similar I can do for CircleCI?

Thanks in advance for any tips!

Yes, use a Machine executor instead of a Docker executor - see the docs. It’s a traditional VM instead of a lightweight container.

1 Like

Thanks! While being significantly slower due to building everything from scratch instead of using a pre-made Docker image, the following seems to do the trick:

version: 2
jobs:
  build:
    machine: true
    steps:
      - checkout
      - run:
          name: Download rustup
          command: |
            wget https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
            chmod +x rustup-init
      - run:
          name: Install Rust
          command: |
            ./rustup-init -y --no-modify-path --default-toolchain nightly
            rm rustup-init
            echo 'export PATH=$HOME/.cargo/bin:$PATH' >> $BASH_ENV
      - run:
          name: Install Tarpaulin
          command: cargo install cargo-tarpaulin
          environment:
            RUSTFLAGS: --cfg procmacro2_semver_exempt
      - run:
          name: Generate coverage report
          command: cargo tarpaulin --out Xml --all-features
      - run:
          name: Upload to codecov.io
          command: bash <(curl -s https://codecov.io/bash) -Z -f cobertura.xml

What sort of extra time does it take? I wonder if you could keep the dependency tarballs/rpms/binaries in the CircleCI cache.

Yes, caching would definitely be something to try! Comparing

it seems the time jumped from 1 to 17 minutes. This is because I’m first building the Tarpaulin code coverage tool, and the Rust compiler is rather slow.

Can you build it as a static, self-contained binary, in a different build process? I am not familiar with Rust, but I believe that you can do that with any compilable/linkable language (it is popular with Go, but presumably can be done with C/C++ etc). If you can do this with Rust then you could just commit it to a repo or storage service and then pull it into place.

Yeah, Rust can also be compiled statically. In this case, I believe Tarpaulin is tied to a particular version of Rust so I think I’ll try running is via the same Docker image (xd009642/tarpaulin) as I did originally, but from the machine executor so it can run with full privileges.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.