Skip to content

Fix specs on Windows [Clean]#171

Merged
confused-Techie merged 7 commits intomasterfrom
fix-specs-on-windows-clean
Mar 8, 2026
Merged

Fix specs on Windows [Clean]#171
confused-Techie merged 7 commits intomasterfrom
fix-specs-on-windows-clean

Conversation

@confused-Techie
Copy link
Copy Markdown
Member

After my work over on #170 I was able to finally figure out the changes needed to get all of PPMs specs working on Windows (for the first time since GHAs was introduced in APM!)

Below I'll break down the changes, but also feel free to read my commit messages:

  • git-test-repo.git: This fixture was introduced in 2016, and seemingly has some massive incompatibilities with Windows. Despite my and @DeeDeeG's best efforts we couldn't get this file to work properly on Windows. So instead of continually fighting the slight gains we were making, I opted to create a fresh repo on modern git and manually add all the files that should be within this fixture. After doing this and updating the commit SHA's expected of some tests, it works perfectly.
  • During the ppm upgrade specs we opened a git-utils file handler that was never released and would cause the upgrade to fail on Windows. Calling repo.release() resolves this.
  • During ppm uninstall . Windows would fail to uninstall as we are currently within the directory we are trying to uninstall (the .) so I've added a check to see if we are on Windows and if our current working directory is the same as the package directory, if so we move the current working directory up one dir and continue the file deletion.
  • Lastly, during installation there were numerous git-utils file handle created that needed to be cleaned up with repo.release(), and during installation I've added a check to see if we are failing to uninstall because of any open file handles. In which case we log and attempt again with native NodeJS fs.cpSync() with the force option.

It took some time, but with just these changes we've got everything working, and can proceed to make further development within PPM easier for any Windows developers (me lol). Sorry the diff is a tad large, but the majority of that is just the update in the fixture.

Since we install a package update over existing package installations, we need to be more cautious about keeping any file handlers open and recovering when we find we may still have some open.
When attempting to delete the package in our current directory on windows, PPM must move out of the directory prior to deletion, otherwise windows will report the resource is busy, with us in it
This `.git` file proved to contain numerous incompatibilities with Windows. Despite many different attempts and techniques there was something in there that would still cause Windows to be unable to handle this file. Completely recreating it on modern git, on windows, with the same exact repo contents got everything working just fine.
Copy link
Copy Markdown
Member

@DeeDeeG DeeDeeG left a comment

Choose a reason for hiding this comment

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

I'd like to take a slow/careful look at the src/ changes, but the whole PR looks extremely promising to me.

The diff is quite a small one, easily a price I'd pay for something as monumental as "passing tests on Windows" (!!!!!!).

Truly I'm in disbelief to see this.

FWIW I get the same number of specs, all passing, before/after this PR on my macOS machine. So, this really seems to have no adverse consequences for other platforms either, at least within our spec coverage.

Wowowow!

Hope to be back with a full approve in not too too long.

Thank you so much for doing this!!!!!! 😮


- if: "!contains(matrix.os, 'windows')"
name: Run tests 👩🏾‍💻
- name: Run tests 👩🏾‍💻
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.

Amazing to finally see this. 🎉

@2colours
Copy link
Copy Markdown
Contributor

2colours commented Mar 3, 2026

So this supersedes #170 if I understand correctly?

@2colours
Copy link
Copy Markdown
Contributor

2colours commented Mar 3, 2026

My other question is: when exactly should repo.release() be called? Sometimes it appears after some exception might have already triggered. Shouldn't it be released under all circumstances of leaving the function?

@confused-Techie
Copy link
Copy Markdown
Member Author

@2colours You are correct that this is the clean commit history version of #170

As for repo.release(). The way I'm understanding it, is that it should be called before we may try to operate on a git repository further.

Since if we call git.open() against a package then fail somewhere else and exit, then the repo object will be killed when the terminal session is and we technically don't have to call release. But if we are about the move onto the next step then we should, or have to call it.

Although, there is zero harm in calling it as soon as we are done collecting information with the repo object, and it'd probably be the sanitary thing to close it out as soon as possible.

Copy link
Copy Markdown
Member

@DeeDeeG DeeDeeG left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I may be taking a break from reviewing/activity in the project for a few days (potentially?) so I didn't want to leave this un-approved.

One day it will be good to run CI at Pulsar core repo with these ppm changes, but I don't have time at the moment. Such checks will happen anyway if we PR this update over to core repo, so that can wait until then.

Not meaning to bury or override @2colours' feedback, that feedback can also be considered, and this Approve review can be considered to apply either way.

Thanks again for fixing the specs on Windows!!! Truly amazing IMO. 🎉

@confused-Techie
Copy link
Copy Markdown
Member Author

Thanks a ton for the review @DeeDeeG! Just added the suggestion by @2colours and if all tests pass I'll go ahead and merge this one! Very excited to make developing with this repo possible on all platforms

@confused-Techie confused-Techie merged commit 2de4516 into master Mar 8, 2026
11 checks passed
@confused-Techie confused-Techie deleted the fix-specs-on-windows-clean branch March 8, 2026 20:50
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.

3 participants