Skip to content

java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system) (again, with solution) #968

Closed
@mikehardy

Description

@mikehardy

Please note: this is more of an interaction between tools. I don't think it is actually a jacoco bug.

There is a solution below that I have tested and is working.

There was no exactly on-target information I could find to resolve this.

It is my hope others that search for this problem see this and self-help, so you can focus your efforts on developing this fantastic project :-)

I will close this after logging it.

Steps to reproduce

  • JaCoCo version: 0.8.4 vs 0.8.5 (it's a difference on upgrade)
  • Tool integration: Gradle + Android instrumented tests + JaCoCo
  • Complete executable reproducer: mikehardy/Anki-Android@dfca8ff (with jacoco-agent.properties it works with 0.8.5, without it 0.8.4 works but 0.8.5 fails)
  • Steps: Demonstrating a subtle interaction between that stack of integrated tools versus the change in 0.8.5 that fails-fast on "config errors"

Expected behaviour

0.8.5 works without changes when upgrading from 0.8.4

Actual behaviour

0.8.5 crashes as it attempts to open '/jacoco.exec' during startup, as a test for file-system write access.

There is something in the android instrumented test plugin that starts with that configuration but does not actually use it - as coverage is actually written to /data/data/<android package name>/coverage.ec which is always writable.

So this configuration used to work fine even though it is technically in error from jacoco's perspective, but in 0.8.5 it now fails on startup.

Solution

The solution is well-documented in jacoco but for Android people, what you need is to add the file in /src/debug/resources/jacoco-agent.properties with the contents output=none so jacoco can startup without failing, and coverage will be written as normal and transferred correctly later by the android gradle plugin coverage implementation. (see the comment below 👇 on where exactly to put the file for your purposes)

This commit shows the required change for the upgrade, where we just put it in src/main:
mikehardy/Anki-Android@dfca8ff

That (as well as a fully-working integrated instrumented + unit test coverage report) will later show up in https://github.com/ankidroid/Anki-Android in case the commit hash is lost.

Cheers

Activity

mikehardy

mikehardy commented on Oct 21, 2019

@mikehardy
Author

For the avoidance of doubt: I don't think this was a bug and it has a solution. Hopefully it helps others that search and land here. Closing now, cheers

marchof

marchof commented on Oct 22, 2019

@marchof
Member

@mikehardy Thanks for sharing this information!

added and removed on Oct 22, 2019
Godin

Godin commented on Oct 22, 2019

@Godin
Member

@mikehardy Thank you for sharing! 👍 ❤️

For the record: intentional change in 0.8.5 to not ignore startup failures - is #910

gavra0

gavra0 commented on Apr 30, 2020

@gavra0

@Godin Should Android Gradle plugin always set output=none in jacoco-agent.propertie? I am working on fixing https://issuetracker.google.com/151471144 in order to remove noisy logcat, but I'd like to make sure adding this option will not hide any issues. Thanks!

mikehardy

mikehardy commented on Apr 30, 2020

@mikehardy
Author

From my perspective / memory as I looked at this, it was definitely unexpected behavior that for the standard Android use case I had to add a file containing the output=none directive, so it should help people if were the default AGP behavior.

In case your comment doesn't see an authoritative maintainer response, from memory in my read of the code while figuring this out, it would fix the common/documented integration of these tools but would not hide anything.

Would be great if this were fixed, excited it is getting some attention!

TWiStErRob

TWiStErRob commented on May 22, 2020

@TWiStErRob

@marchof @Godin can you please help @gavra0 out? It would be nice to see this fixed in "otherproject".

marchof

marchof commented on May 23, 2020

@marchof
Member

@TWiStErRob @gavra0 I really not into the Android SDK. If the execution data is always read via JaCoCo's runtime API you can always set output=none. There are no side effects except that no data is written.

38 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Godin@mikehardy@alex-dorokhov@ZacSweers@marchof

        Issue actions

          java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system) (again, with solution) · Issue #968 · jacoco/jacoco