Repository navigation
fix(gradle-plugin): run posthog-cli through cmd /c correctly on Windows - #982
Merged
Merged
Conversation
The Windows branch put `cmd /c` after the CLI as arguments, so uploads ran `posthog-cli cmd /c …` and failed. Run `cmd /c <cli> …` instead, and run an .exe directly. Fixes #981
Contributor
There was a problem hiding this comment.
PostHog Review · Standard · reviewed acb7088: 1 Must fix.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
Resolve posthog-cli.exe on PATH so the default CLI skips cmd, which would otherwise treat a `&` in the mapping path as a command separator. Only a .cmd shim, which always runs inside cmd, still goes through cmd /c.
marandaneto
approved these changes
Nov 16, 2026
marandaneto
left a comment
Member
There was a problem hiding this comment.
The code looks good; no qualifying findings. Verdict: correct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Fixes #981. On Windows, the plugin put
cmd /cafter the CLI as arguments, so every upload ranposthog-cli cmd /c exp proguard upload …and failed withunrecognized subcommand 'cmd'. This broke both ProGuard mapping and native symbol uploads on Windows, and it has done so since the ProGuard support first shipped (#316).Now on Windows:
posthog-cli, the plugin looks forposthog-cli.exeon PATH (the native release) and runs it directly, so arguments never pass throughcmd. A&in the project path would otherwise split the command..exeon PATH, it runscmd /c posthog-cli …so an npmposthog-cli.cmdshim still resolves. A.cmdalways runs insidecmdanyway..exepath runs directly. A configured non-.exepath goes throughcmd /c.macOS and Linux are unchanged.
Known limitation: a user-configured
.cmd/.batpath that contains spaces can still hitcmd /c's quote stripping. That case is broken today too. Fixing it means layering extra quotes on top of Java's own, which I didn't want to ship without a Windows machine to check it on.💚 How did you test it?
postHogCliCommandLine(executable, args, isWindows)function and addedPostHogCliCommandLineTest.PostHogCliResolverTestalso covers the Windows.exelookup, with thePathkey spelled the way Windows spells it. The test first ran against the old logic and reproduced the issue ([posthog-cli, cmd, /c, exp, …]), then passed with the fix../gradlew :posthog-android-gradle-plugin:test :posthog-android-gradle-plugin:functionalTest spotlessCheckpasses locally on macOS.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
cmd /cpassed as CLI arguments) #981, confirmed it from the source, wrote a failing unit test first, and then made the fix.cmd /centirely, since the reporter's CLI is a native.exe. We kept it because that would break npm-installed.cmdshims. The.exeexception covers the native install and paths with spaces.cmdtreats a&in the path as a command separator, the default CLI now resolvesposthog-cli.exeon PATH and skipscmd..cmd-path-with-spaces case above, which I've left as a known limitation.🤖 Generated with Claude Code