Skip to content

Fix import-safe checks when scripts are run from a path with symlinks - #1265

Open
otaconix wants to merge 1 commit into
actions:mainfrom
otaconix:import-safe-check-fix
Open

Fix import-safe checks when scripts are run from a path with symlinks#1265
otaconix wants to merge 1 commit into
actions:mainfrom
otaconix:import-safe-check-fix

Conversation

@otaconix

@otaconix otaconix commented Sep 8, 2026

Copy link
Copy Markdown

Description:
In v6, setup-java was made "import-safe" to facilitate testing. This prevents setup-java & cleanup-java from doing anything when their sources get imported.

This works fine in the general case, but actually invoking the script (node setup-java/index.js) when the path to the script contains symlinks led to the script incorrectly believing it was imported, and refuse to actually run.

To fix this, we pass process.argv[1] through fs.realpathSync, which resolves symlinks in the path.

Fixes #1264

NB: I did run tests, and all but one succeeded, which I think is unrelated to my changes: the Jetbrains distributor test that checks getAllAvailableVersions times out on my machine.

Check list:

  • Ran npm run check locally (format, lint, build, test) and all checks pass.
  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

In v6, setup-java was made "import-safe" to facilitate testing. This
prevents setup-java & cleanup-java from doing anything when their
sources get imported.

This works fine in the general case, but actually invoking the script
(`node setup-java/index.js`) when the path to the script contains
symlinks led to the script incorrectly believing it was imported, and
refuse to actually run.

To fix this, we pass `process.argv[1]` through `fs.realpathSync`, which
resolves symlinks in the path.

Fixes actions#1264
@otaconix
otaconix requested a review from a team as a code owner September 8, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import-safe entrypoints when run from non-canonical path: doesn't run

1 participant