Skip to content

#797: zip symlink pure java#1995

Open
shodiBoy1 wants to merge 11 commits into
devonfw:mainfrom
shodiBoy1:feature/797-zip-symlink-pure-java
Open

#797: zip symlink pure java#1995
shodiBoy1 wants to merge 11 commits into
devonfw:mainfrom
shodiBoy1:feature/797-zip-symlink-pure-java

Conversation

@shodiBoy1

@shodiBoy1 shodiBoy1 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #797: fix VSCode install on macOS

Implemented changes:

  • On macOS, installing VSCode was failing because the ZIP extractor could not handle .framework folders. These folders use symlinks that point to other symlinks (a chain). The old code tried to resolve the full path of each symlink before creating it, which fails when the next symlink in the chain does not exist yet.
  • New behavior: write each symlink with the exact text from the ZIP, the same way unzip does. No path resolution, no existence check. The chain just works once all files are on disk.

Testing instructions

  1. Check out the PR:
    gh pr checkout 1995

  2. Run on a Mac:

  • Open the project in IntelliJ.
  • go to 'com.devonfw.tools.ide.cli.Ideasy' -> Modify Run Configuration.
  • Program arguments: vscode
  • Working directory: any empty folder (e.g. ~/test-ideasy).
  • Click Run.

Checklist for this PR

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Jun 1, 2026
@shodiBoy1 shodiBoy1 self-assigned this Jun 1, 2026
@shodiBoy1 shodiBoy1 added unpack logic to unpack archives (tar, zip, tgz, zbz2, msi, dmg, etc.) link symlinks and windows junctions labels Jun 1, 2026
@coveralls

coveralls commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 27616583660

Coverage decreased (-0.03%) to 71.256%

Details

  • Coverage decreased (-0.03%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 159 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

159 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/io/FileAccessImpl.java 157 67.99%
com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java 1 78.33%
com/devonfw/tools/ide/version/VersionSegment.java 1 89.76%

Coverage Stats

Coverage Status
Relevant Lines: 16212
Covered Lines: 12048
Line Coverage: 74.32%
Relevant Branches: 7250
Covered Branches: 4670
Branch Coverage: 64.41%
Branches in Coverage %: Yes
Coverage Strength: 3.15 hits per line

💛 - Coveralls

@shodiBoy1 shodiBoy1 marked this pull request as ready for review June 1, 2026 21:58
@shodiBoy1 shodiBoy1 moved this from 🆕 New to Team Review in IDEasy board Jun 1, 2026
@hohwille hohwille changed the title Feature/797 zip symlink pure java #797: zip symlink pure java Jun 3, 2026

@hohwille hohwille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shodiBoy1 thanks for your PR and your analysis of the root cause. I like that you always take such special problem and analyse it properly trying to come up with a rather small fixing PR👍
Surely we could merge this as is as a quickfix.
However, you revealed here that we have actually implemented our link function wrong (and therefore our "unpack" functions - not only for zip but also for tar).
IMHO your PR is not fixing that bug but adding a workaround with quite some redundancies.

My goal is that we aim for true quality so I would love to fix the link function properly.
Can you maybe extract a JUnit test that reproduces the scenario with invoking our link function?
BTW: We meanwhile also have ide ln -s <source> <link> to test such things. If you want to test with relative being true you can do ide ln -s -r <source> <link>.
If that is buggy, please lets fix the root cause.

Comment thread cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java Outdated
@shodiBoy1

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

My initial idea was to preserve the raw symlink target from the ZIP entry, because macOS framework bundles can contain chained symlinks where the final target is created later. That is why I first handled ZIP symlinks directly.

After your feedback I agree that this was too ZIP-specific and bypassed the existing PathLink/link(...) abstraction. I reworked it so ZIP and TAR both go through PathLink -> link(PathLink), and the actual fix is now in the shared link handling.

The shared link code now avoids resolving symlink targets too early, so archive symlinks can point through links that are created later. I also added a regression test that calls FileAccess.link(PathLink) directly for the macOS framework-style case.

Tested with FileAccessImplTest, LnCommandletTest, and a manual VS Code install from IntelliJ.

@hohwille hohwille added this to the release:2026.06.001 milestone Jun 16, 2026

@hohwille hohwille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shodiBoy1 thanks for rework. Now approach seems reasonable. Changing to approved 👍
Team-review should still test that link creation still works as expected and have a quick look again and the diff.

@github-project-automation github-project-automation Bot moved this from Team Review to 👀 In review in IDEasy board Jun 16, 2026

@tineff96 tineff96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the PR looks good to me.

I ran:

mvn clean test

Results:

  • Ubuntu/WSL: passes without changes

  • Windows: fails on this PR branch in:

    • testSymlinkShortcutPaths
    • testSymlinkAbsolutePassingRelativeSource

The Windows failures seem related to the mklink fallback. If relative == false, passing the relative source to mklink causes Windows to resolve it against the process working directory instead of the link parent directory.

I tested the following adjustment in FileAccessImpl.java, line 481:

Path finalSource = relative ? source : absoluteSource;

With this change, the focused test suite passes for me on Windows as well. This should keep the ZIP/macOS path able to preserve relative symlink targets when needed, while the Windows fallback keeps the previous absolute/adapted behavior for relative == false.

I still think the original macOS VSCode case should be verified manually on a Mac. I will ask a teammate with macOS to run the ide vscode scenario as well.

@AdemZarrouki

AdemZarrouki commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

tested on mac(26.5.1) arm64 [Mac OS X@arm64]

ide vscode
Start: Configuring workspace main for IDE vscode
Successfully ended step 'Configuring workspace main for IDE vscode'.
No CVEs found for version 1.124.2 of tool vscode.
Could not determine file extension from URL https://update.code.visualstudio.com/1.124.2/darwin-arm64/stable - guess was zip but may be incorrect.
Trying to download vscode-1.124.2-mac-arm64.zip from https://update.code.visualstudio.com/1.124.2/darwin-arm64/stable
Downloading 100% │████████████████████│ 237/237MiB (0:01:26 / 0:00:00) 2,8MiB/s
SHA-256 checksum d0955f81c63181d69e59f78616b7c6deac695878a542d7bf74b896df7cb19bca is correct.
Extracting ZIP file /Users/Library/Caches/IDEasy/downloads/default/vscode-1.124.2-mac-arm64.zip to /Users/Projects/_ide/tmp/extract-vscode-1.124.2-mac-arm64.zip
Extracting 100% │████████████████████│ 237/237MiB (0:00:05 / 0:00:00) 47,6MiB/s
Resetting all installed plugins...
Installing Plugins 100% │██████│ 54/54 Plugins (0:08:35 / 0:00:00) ,1 Plugins/s
...
Successfully installed vscode in version 1.124.2 at /Users/Projects/test-ideasy/software/vscode
Successfully completed ide (vscode)

vscode was installed and launched successfully.

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

Labels

link symlinks and windows junctions unpack logic to unpack archives (tar, zip, tgz, zbz2, msi, dmg, etc.)

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

vscode not working on mac

5 participants