Skip to content

fix: avoid endless vite processes when Vite is missing - #631

Open
MatheusRich wants to merge 1 commit into
ElMassimo:mainfrom
MatheusRich:fix-runner-self-invocation
Open

MatheusRich wants to merge 1 commit into
ElMassimo:mainfrom
MatheusRich:fix-runner-self-invocation

Conversation

@MatheusRich

Copy link
Copy Markdown

The runner starts Vite through the package manager, for example bun x --bun vite. When the vite package is not installed, Bun and pnpm look for vite on the PATH. There they find the vite executable of this gem, which starts the runner again. Each process waits for its child, so the processes accumulate without end.

This commit adds a marker variable to the environment of the process that the runner starts. When vite build or vite dev sees the marker, it stops with an error. The error tells the user to install the JavaScript packages. vite-plugin-ruby removes the marker when Vite loads, so a process that Vite starts can still run bin/vite.

The check runs before Builder#build. With the build lock of PR #630, a later check would deadlock instead of failing. The marker has no VITE_ prefix, because Vite copies those variables into import.meta.env.

A check for node_modules/.bin/vite is not possible, because Yarn Plug'n'Play has no node_modules. A check of the parent PID does not work either, because pnpm starts the child through two processes.

With an older vite-plugin-ruby, vite build and vite dev fail when a process that Vite started runs them. DEFAULT_PLUGIN_VERSION should move to the next plugin release to prevent this.

The runner starts Vite through the package manager, for example
`bun x --bun vite`. When the vite package is not installed, Bun and
pnpm look for `vite` on the PATH. There they find the `vite`
executable of this gem, which starts the runner again. Each process
waits for its child, so the processes accumulate without end.

This commit adds a marker variable to the environment of the process
that the runner starts. When `vite build` or `vite dev` sees the
marker, it stops with an error. The error tells the user to install
the JavaScript packages. vite-plugin-ruby removes the marker when Vite
loads, so a process that Vite starts can still run `bin/vite`.

The check runs before `Builder#build`. With the build lock of PR ElMassimo#630,
a later check would deadlock instead of failing. The marker has no
`VITE_` prefix, because Vite copies those variables into
`import.meta.env`.

A check for `node_modules/.bin/vite` is not possible, because Yarn
Plug'n'Play has no `node_modules`. A check of the parent PID does not
work either, because pnpm starts the child through two processes.

With an older vite-plugin-ruby, `vite build` and `vite dev` fail when
a process that Vite started runs them. `DEFAULT_PLUGIN_VERSION` should
move to the next plugin release to prevent this.
@MatheusRich
MatheusRich force-pushed the fix-runner-self-invocation branch from 8258d19 to 71fd3ea Compare September 24, 2026 21:29

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.

1 participant