fix: avoid endless vite processes when Vite is missing - #631
Open
MatheusRich wants to merge 1 commit into
Open
MatheusRich wants to merge 1 commit into
MatheusRich wants to merge 1 commit into
Conversation
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
force-pushed
the
fix-runner-self-invocation
branch
from
September 24, 2026 21:29
8258d19 to
71fd3ea
Compare
This branch has not been deployed
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.
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 forviteon the PATH. There they find theviteexecutable 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 buildorvite devsees 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 runbin/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 noVITE_prefix, because Vite copies those variables intoimport.meta.env.A check for
node_modules/.bin/viteis not possible, because Yarn Plug'n'Play has nonode_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 buildandvite devfail when a process that Vite started runs them.DEFAULT_PLUGIN_VERSIONshould move to the next plugin release to prevent this.