Skip to content

chore: make justfile fully compatible with Windows/PowerShell#100

Open
MusabYK wants to merge 2 commits into
bitcoindevkit:mainfrom
MusabYK:chore/windows-justfile-compat
Open

chore: make justfile fully compatible with Windows/PowerShell#100
MusabYK wants to merge 2 commits into
bitcoindevkit:mainfrom
MusabYK:chore/windows-justfile-compat

Conversation

@MusabYK

@MusabYK MusabYK commented Jun 27, 2026

Copy link
Copy Markdown

Description

This PR addresses #97 #98 and several platform-specific compatibility bugs in the justfile. Running certain recipes natively on Windows (via PowerShell) caused execution panics or syntax errors due to hardcoded Unix commands (rm -rf, open) and bash-specific operators (&&).

Changes Implemented

  1. set unstable := true: Allow experimental features like [group(...)]
  2. set shell := ["sh", "-c"]: Default shell for Mac and Linux
  3. set windows-shell := ["powershell.exe", "-Command"] Specific override ONLY for Windows users
  4. generate-bindings: Fixed a crash where bash was explicitly invoked. Refactored it to conditionally cd into native and invoke the windows specific binding generation commands to correctly generate bindings for bdk_dart_ffi.dll.
  5. clean: Conditionally swapped Unix rm -rf for PowerShell's native Remove-Item -Recurse -Force when executing on a windows host, preventing command parsing failures.
  6. repo: Conditionally replaced the open command with Windows Start-Process for launching the GitHub repository in the default browser.
  7. demo-analyze & demo-test: Conditionally replaced the chaining operator && with the PowerShell's separator ; for Windows environments.

Investigation & findings

After fixing the Justfile to support Windows, I ran the just ci command, the project builds and the test suite starts successfully, but when the just ci reaches demo-test several demo tests fail with the following error.

Error:

PathAccessException: Deletion failed, path = 'C:\Users...\wallet_service_test_xxxxx'
(OS Error: The process cannot access the file because it is being used by another process, errno = 32)
dart:io FileSystemEntity.delete
package:bdk_demo/core/utils/wallet_storage_paths.dart 57:17 WalletStoragePaths.deleteFallbackWalletData
package:bdk_demo/services/wallet_service.dart 617:32 WalletService._reseedWalletToFallbackSqlite

Recommendation

The PathAccessException error should be addressed through a separate PR, once its fixed, the just ci should pass on Windows just as it does on Linux and macOS.

@j-kon j-kon 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.

Thanks for taking this on, @MusabYK. This is a helpful improvement for Windows contributors, and I like that the scope stays focused on the Justfile.

I was not able to run just locally on my machine because it is not installed here, so one thing I would like to confirm before this is merged: have you tested the updated recipes on Windows/PowerShell, especially just list, just format, just clean, and just generate-bindings?

If those pass on Windows, this looks aligned with #97 and #98 to me.

Comment thread justfile Outdated
generate-bindings:
bash ./scripts/generate_bindings.sh
{{ if os() == "windows" {
"cd native; cargo build --profile dev; cargo run --profile dev --bin uniffi-bindgen -- generate --library target\\debug\\bdk_dart_ffi.dll --language dart --config uniffi.toml --out-dir ..\\lib\\"

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.

Small behavior note: PowerShell ; always runs the next command, so if cd native or cargo build fails, the following command can still run. Could we keep this fail-fast like the original script behavior?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, great point I'll look into fixing that.

Comment thread justfile Outdated
{{ if os() == "windows" {
"Start-Process https://github.com/bitcoindevkit/bdk-dart"
} else {
"open https://github.com/bitcoindevkit/bdk-dart"

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.

Small cross-platform note: this still uses macOS open for every non-Windows OS. Since this PR is improving cross-platform Justfile support, should we use xdg-open on Linux and keep open only for macOS?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thats a good idea, i assumed the current justfile support Linux as well, I just test all the just commands on my WSL, they all passed except the just repo command.
I'll look into that as well. Thanks!

- Replace manual directory switching with native '[working-directory]' attribute.
- Add fail-fast error checking ('if (-not $?)') to Windows bindings generation.
- Standardize Windows file paths to use forward slashes.
@MusabYK

MusabYK commented Jun 29, 2026

Copy link
Copy Markdown
Author

Hi @j-kon I have applied the requested changes and refactored the justfile:

  • Added Linux compatibility to just repo using xdg-open.
  • Replaced manual cd commands with the native [working-directory] attribute for the demo tasks.
  • Standardised the paths with forward slashes and added fail-fast checks to the bindings generation script,
    Let me know if there is anything else to adjust

@j-kon

j-kon commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Thanks @MusabYK, I checked the latest update and the two review points look addressed now.

The repo recipe now handles Linux with xdg-open, while keeping macOS/Windows separate, and the Windows generate-bindings path now has fail-fast checks after the key steps. Nice cleanup with the [working-directory] refactor too.

Comment thread justfile
[doc("Build native library and regenerate bindings.")]
generate-bindings:
bash ./scripts/generate_bindings.sh
{{ if os() == "windows" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This multi-line interpolation has the same parser issue as the generate-bindings recipe: just --list --unsorted fails with error: Unterminated interpolation before any recipe can run.

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