vite_ruby icon indicating copy to clipboard operation
vite_ruby copied to clipboard

Corepack packageManager set to pnpm triggers warning with assets:precompile

Open jprosevear opened this issue 1 year ago • 1 comments

  • [x] I have tried upgrading by running bundle update vite_ruby.
  • [x] I have read the troubleshooting section before opening an issue.

Description 📖

With corepack enabled and packageManager set (to pnpm in my case), running rake assets:precompile will throw a warning (but continue):

/Users/jpr/.asdf/installs/nodejs/20.14.0/lib/node_modules/corepack/dist/lib/corepack.cjs:22373
              throw new UsageError(`This project is configured to use ${result.spec.name} because ${result.target} has a "packageManager" field`);
                    ^

UsageError: This project is configured to use pnpm because /Users/jpr/src/Rhino/mono-test/rhino-project-template_rails_mono/package.json has a "packageManager" field
    at Engine.findProjectSpec (/Users/jpr/.asdf/installs/nodejs/20.14.0/lib/node_modules/corepack/dist/lib/corepack.cjs:22373:21)
    at async Engine.executePackageManagerRequest (/Users/jpr/.asdf/installs/nodejs/20.14.0/lib/node_modules/corepack/dist/lib/corepack.cjs:22404:24)
    at async Object.runMain (/Users/jpr/.asdf/installs/nodejs/20.14.0/lib/node_modules/corepack/dist/lib/corepack.cjs:23096:5) {
  clipanion: { type: 'usage' }
}

I have traced this to: https://github.com/ElMassimo/vite_ruby/blob/a3182a9b8abc058004e47b81b214ea6e578e7e6f/vite_ruby/lib/tasks/vite.rake#L92

Because it runs the yarn command (when it is not installed), triggering the warning. I suspect that yarn call should either:

  • Check for the 'yarn' binary before running the command OR
  • Only run this if yarn is the package manager

Reproduction 🐞

Vite Ruby Info

Run bin/rake vite:info and provide the output:

bin/vite present?: true
vite_ruby: 3.8.2
vite_rails: 3.0.17
rails: 7.1.3.4
ruby: ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin23]
node: v20.14.0
pnpm: 9.9.0

Logs 📜

Screenshots 📷

image image

jprosevear avatar Sep 07 '24 01:09 jprosevear

This doesn't seem to be a problem since everything still gets installed, but it would be nice to remove the warning.

emptyflask avatar Mar 03 '25 16:03 emptyflask