Skip to content

JAVA_HOME is not set correctly on MacOS for local (jdkFile) installed JDKs that are present in the tool cache #396

Description

@erwin1

Description:
Local installed JDKs using the jdkFile option that are already present in the tool cache are not checked for suffix 'Contents/Home' on macos, so as a result the JAVA_HOME is not set correctly.

Task version:
v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:

  • run a workflow with setup-java with a jdkFile option on a self-hosted runner on MacOS using a JDK that places files in 'Contents/Home'
  • the first time this works fine. JAVA_HOME is set correctly including 'Contents/Home'
  • run the workflow again, this time the JDK will already be present in the tool cache
  • setup-java now sets JAVA_HOME without the 'Contents/Home' suffix

Expected behavior:
When the JDK is available in the tool cache, JAVA_HOME must be set correctly.

Actual behavior:
When the JDK is available in the tool cache, JAVA_HOME is set without checking if the JDK is placed in 'Contents/Home'

Activity

  1. panticmilos commented on Oct 28, 2022

    @panticmilos
    Contributor

    hi @erwin1, thank you for the report. We will take a look at it

  2. panticmilos commented on Oct 28, 2022

    @panticmilos
    Contributor

    By the way, could you provide us public repo with repro steps?

  3. erwin1 commented on Oct 28, 2022

    @erwin1
    ContributorAuthor

    Thanks.

    Here's a public repo: https://github.com/erwin1/setup-java-mac-sscce
    On a hosted runner it's a bit harder to reproduce because every run happens on a different runner (so less chance of having a tool cache).

    Although I was able to reproduce with a trick to use setup-java again in the same job.

    This fails:
    https://github.com/erwin1/setup-java-mac-sscce/actions/runs/3344915283/jobs/5539822614

    And using the proposed fix from #397 it works:
    https://github.com/erwin1/setup-java-mac-sscce/actions/runs/3344942099/jobs/5539881412

  4. erwin1 commented on Oct 30, 2022

    @erwin1
    ContributorAuthor

    added 2 unit tests of which one fails (java is resolved from toolcache including Contents/Home on MacOS) without the proposed fix

  5. self-assigned this
    on Nov 1, 2022
  6. erwin1 commented on Dec 2, 2022

    @erwin1
    ContributorAuthor

    Any chance we can move this forward?

  7. panticmilos commented on Dec 20, 2022

    @panticmilos
    Contributor

    hi @erwin1, sorry for the delayed answer, thank you for the repo I will take a look again :)

  8. erwin1 commented on Feb 4, 2023

    @erwin1
    ContributorAuthor

    We are still regularly running into this issue, so it would be great to get a review on the PR. Thanks!

  9. self-assigned this
    on Feb 6, 2023
  10. dmitry-shibanov commented on Apr 4, 2023

    @dmitry-shibanov
    Contributor

    Hello @erwin1. We've merged your pull request. For now you can try to use this changes with actions/setup-java@main. We'll ping you when new release is ready.

    For now I'm going to reopen it until we release a new version.

  11. erwin1 commented on Apr 4, 2023

    @erwin1
    ContributorAuthor
  12. IvanZosimov commented on Jul 24, 2023

    @IvanZosimov
    Contributor

    Hi, @erwin1 👋 The new version of the setup-java is released. Please, check it out.

    I'm going to close this issue, If you have any additions or questions feel free to ping us.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions