Skip to content

Fix just clean command for Windows PowerShell compatibility and missing directory handling #730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 24, 2025

The just clean command was failing on Windows due to two issues:

  1. PowerShell compatibility: The command rm -f interface.wasm is ambiguous in PowerShell on Windows, causing the clean operation to fail.

  2. Missing directory handling: The command would fail if the src/tests/rust_guests/witguest directory didn't exist, which could happen in certain build scenarios or incomplete checkouts.

Changes Made

This PR fixes both issues by implementing cross-platform conditional logic in the clean-rust target:

Before:

cd src/tests/rust_guests/witguest && cargo clean
cd src/tests/rust_guests/witguest && rm -f interface.wasm

After:

{{ if os() == "windows" { "cd src/tests/rust_guests/witguest -ErrorAction SilentlyContinue; cargo clean" } else { "[ -d src/tests/rust_guests/witguest ] && cd src/tests/rust_guests/witguest && cargo clean || true" } }}
{{ if os() == "windows" { "Remove-Item src/tests/rust_guests/witguest/interface.wasm -Force -ErrorAction SilentlyContinue" } else { "rm -f src/tests/rust_guests/witguest/interface.wasm" } }}

Platform-Specific Solutions

  • Windows: Uses PowerShell's ErrorAction SilentlyContinue to ignore errors and Remove-Item to delete files
  • Unix/Linux/macOS: Uses shell conditionals [ -d ... ] and rm -f with proper error handling

Testing

The fix has been tested for the following scenarios:

  • ✅ Normal operation when directory and files exist
  • ✅ Graceful handling when interface.wasm file doesn't exist
  • ✅ Graceful handling when witguest directory doesn't exist
  • ✅ Build system continues to work correctly after changes

Fixes #729.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@simongdavies simongdavies added the kind/bugfix For PRs that fix bugs label Jul 24, 2025
@Copilot Copilot AI changed the title [WIP] just clean does not work on windows Fix just clean command for Windows PowerShell compatibility and missing directory handling Jul 24, 2025
@Copilot Copilot AI requested a review from simongdavies July 24, 2025 12:36
Copilot finished work on behalf of simongdavies July 24, 2025 12:36
@syntactically
Copy link
Member

@simongdavies is this really the simplest way to do this on pwsh?

@simongdavies
Copy link
Contributor

@simongdavies is this really the simplest way to do this on pwsh?

No, @copilot please use -ErrorAction SilentlyContinue on commands instead of using conditional if (Test-Path src/tests/rust_guests/witguest/*). Also make sure to force the delete of file on windows.

Copy link
Contributor Author

Copilot AI commented Jul 24, 2025

@simongdavies is this really the simplest way to do this on pwsh?

No, @copilot please use -ErrorAction SilentlyContinue on commands instead of using conditional `if (Test-Path src/tests/rust_gu...

Updated to use -ErrorAction SilentlyContinue instead of conditional Test-Path checks, and added -Force flag for file deletion on Windows. This is much cleaner and simpler. Changes committed in 3510202.

Copilot finished work on behalf of simongdavies July 24, 2025 14:30
@simongdavies
Copy link
Contributor

@copilot , its not possible to use '-ErrorAction SilentlyContinueon thecargo clean` command please remove it from there, Also update the PR description to reflect the new implementation

Copy link
Contributor Author

Copilot AI commented Jul 24, 2025

@copilot , its not possible to use '-ErrorAction SilentlyContinueon thecargo clean` command please remove it from there, Also update the PR description to reflect the new implementation

Removed -ErrorAction SilentlyContinue from the cargo clean command since it's not a PowerShell cmdlet and reverted to using Test-Path conditional check. Updated the PR description to reflect the current implementation. Changes committed in 8c3c339.

Copilot finished work on behalf of simongdavies July 24, 2025 14:49
@simongdavies
Copy link
Contributor

@copilot instead of using if (Test-Path src/tests/rust_guests/witguest) use -ErrorAction SilentlyContinue on the cd src/tests/rust_guests/witguest, but do not change cargo clean as -ErrorAction SilentlyContinue will not wok there, but this fine since that command will not fail, also update the description to reflect this update

Copy link
Contributor Author

Copilot AI commented Jul 24, 2025

@copilot instead of using if (Test-Path src/tests/rust_guests/witguest) use -ErrorAction SilentlyContinue on the cd src/tests/rust_guests/witguest, but do not change cargo clean as `-ErrorAction Silen...

Updated to use -ErrorAction SilentlyContinue on the cd command instead of the Test-Path conditional check. The cargo clean command remains unchanged as requested since -ErrorAction SilentlyContinue doesn't work with external programs. PR description has been updated to reflect the current implementation. Changes committed in 6c28cf0.

Copilot finished work on behalf of simongdavies July 24, 2025 15:15
@simongdavies simongdavies marked this pull request as ready for review July 24, 2025 18:23
…y handling

Co-authored-by: simongdavies <[email protected]>
Signed-off-by: Simon Davies <[email protected]>
@simongdavies simongdavies enabled auto-merge (squash) July 24, 2025 18:28
@simongdavies simongdavies merged commit 1a155a7 into main Jul 24, 2025
43 of 64 checks passed
@simongdavies simongdavies deleted the copilot/fix-729 branch July 24, 2025 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bugfix For PRs that fix bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

just clean does not work on windows
4 participants