cssbundling-rails icon indicating copy to clipboard operation
cssbundling-rails copied to clipboard

Cssbundling-rails 1.4.3 using bun in project, which using yarn and contain yarn.lock

Open le0pard opened this issue 9 months ago • 7 comments

Hello.

In project we are using yarn 4.6.0. All works till version 1.4.2 included.

1.4.3 now thinking if system have bun installed, it run it and generate bun.lock file in project. Which is incorrect behaviour, because project have only yarn.lock and managed by yarn. Installed bun in system doesn't mean project using bun.

Thanks

Looks like issue was introduced by https://github.com/rails/cssbundling-rails/pull/165

le0pard avatar Mar 04 '25 19:03 le0pard

Does your package.json has a packageManager field, it could be interesting to choose tools from that perhaps. Otherwise we will have to follow https://github.com/rails/cssbundling-rails/pull/165#discussion_r1979318719

navidemad avatar Mar 04 '25 20:03 navidemad

  "packageManager": "[email protected]",

in package.json present @navidemad

le0pard avatar Mar 04 '25 20:03 le0pard

I think bun mean bun.lock files in project. So not clear why bun should manage yarn.lock

le0pard avatar Mar 04 '25 20:03 le0pard

Hello,

I'm experiencing the same issue

We're using yarn classic 1.22.22 (for this particular project)

The original package.json didn't include a packageManager field.

I've tried by adding:

  "packageManager": "[email protected]",

but the result does not change: running rake when cssbundling-rails 1.4.3 is installed does create a bun.lock file in the root folder of the repository

$ rake
bun install v1.2.4 (fd9a5ea6)

Checked 118 installs across 112 packages (no changes) [6.00ms]
$ tailwindcss -i ./app/assets/stylesheets/active_admin.css -o ./app/assets/builds/active_admin.css --minify -c tailwind-active_admin.config.js

Rebuilding...

Done in 1234ms.

As a workaround, I've uninstalled bun

tagliala avatar Mar 05 '25 08:03 tagliala

We just should remove yarn.lock as autodetection for bun.

Also, for such cases as in https://github.com/rails/cssbundling-rails/pull/165 create config variable, which will set js package manager and will use it instead autodetection mechanism (so person can set bun even if have yarn.lock)

le0pard avatar Mar 05 '25 08:03 le0pard

I will try a PR

navidemad avatar Mar 05 '25 11:03 navidemad

@le0pard @navidemad The lockfile & command sniffing approach keeps fixing one setup while breaking another—there are a lot of possible combinations of existing lockfiles and commands.

Adding config that allows differentiating the build command from the package manager seems like the best path. 👍

I encountered the same basic problem in https://github.com/rails/jsbundling-rails/pull/213, which I now realize may fix my setup and break another's. I think the two gems should align on their solution, so I'm keeping an eye on this so I can update that PR accordingly.

jbarrieault avatar Mar 07 '25 12:03 jbarrieault

I posted my encounter with this in jsbundling-rails/issues/219 but then realized the problem is in cssbundling-rails.

When I run rails _8.0.2_ new website --js=esbuild --css=tailwind it creates yarn and bun lockfiles and adds unwanted Bun stuff to package.json and Procfile.dev. I delete the Bun lockfile, fix the package.json and Procfile.dev files, but then the Bun lockfile comes back when I run bin/rails test.

I haven't figured out yet why that is happening, because I can't find "bun" anywhere in the project. In the meantime I have to run tests by pointing directly at test files, or Bun creates another mess.

j127 avatar May 02 '25 23:05 j127

Hello,

as far as I understand, this has been fixed in #172, merged on main, but not released yet

would it be possible to cut out a new release? this is preventing rails app being deployed on render (which comes with bun by default, as far as I can tell)

tagliala avatar Nov 02 '25 09:11 tagliala