Skip to content

fix(cli): pass forge args as an array so project paths with spaces work - #5303

Open
theluckystrike wants to merge 1 commit into
wevm:mainfrom
theluckystrike:fix-foundry-root-spaces
Open

theluckystrike wants to merge 1 commit into
wevm:mainfrom
theluckystrike:fix-foundry-root-spaces

Conversation

@theluckystrike

Copy link
Copy Markdown

The foundry plugin built its forge clean and forge build calls as template strings passed to execSync, so a project path with a space was split into two arguments. forge config had the same problem through spawnSync(..., { shell: true }), which joins the array back into one string, so its result was silently dropped and the plugin fell back to the default out dir. The result is "Artifacts not found." for any project under a folder like ~/My Projects/app.

This switches clean, build and --version to execFileSync with an argument array, and drops shell: true from the config call. The --watch path already used spawn with an array.

The new test points the plugin at a stub forge and a project dir named my project, then checks that every --root value arrives as one argument.

pnpm vitest run --project cli packages/cli/src/plugins/foundry.test.ts   (forge 1.9.0)
before: Tests 1 failed | 8 passed   "Error: Artifacts not found."
after:  Tests 9 passed

Biome and tsgo --noEmit for @wagmi/cli are clean. Changeset added.

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

@theluckystrike is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4b29d04

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wagmi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tydavid5 tydavid5 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the fix against the reported bug, and it checks out.

Root cause is right: the foundry plugin built forge clean and forge build as template strings passed to execSync, so a project path with a space was split into two arguments by the shell. Switching to execFileSync with the arguments as an array fixes that at the source, and removing shell: true from the forge config call through spawnSync closes the same hole there.

I checked the rest of packages/cli/src/plugins/foundry.ts at this head. There is no execSync left in the file. The spawn call for the build output already passes its arguments as an array, and the forge --version check is now execFileSync with ['--version'] too, so the fix is complete across the file, not just for clean and build.

The test covers the reported case well. It creates a project folder called my project, runs the plugin against a fake forge script, and asserts the exact arguments received for config, clean and build, with the full project path as one argument each time. That is the exact failure the issue describes, and the test would fail on the old string based calls.

One note, not a blocker: the new test is skipped on win32, so a Windows path with spaces is still not covered by a test here. execFileSync without a shell is still the right direction on Windows, but the coverage gap is worth knowing.

Approving, the fix is correct and tested.

This branch has not been deployed

No deployments
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.

2 participants