Closed aduth closed 1 year ago
It feels sort of weird to me as well that they build
command has a forced install
step. +1 to this, if not removing yarn install
completely from the build
task.
I see there is a condition here for SKIP_YARN_INSTALL variable. Could you clarify:
@rserling Out of curiosity, are you also using cssbundling-rails
? I just tested in our project and was able to reproduce the redundant Yarn install, but I tracked it back to the fact that we're running an older version of cssbundling-rails
which also had a built-in Yarn install. Updating to at least cssbundling-rails@1.3.0
(https://github.com/rails/cssbundling-rails/pull/125) fixed it, as that newer version now supports the same environment variable.
@aduth thanks for the response, this is a rough blocker. Unfortunately no, my app is not using cssbundling-rails.
Ah, bummer! Well, to answer your original question, it's a simple truthy check, so any value should work (1
, true
, even empty string).
In my testing, SKIP_YARN_INSTALL=true rails assets:precompile
does not show "yarn install" as expected. For our project, we configure this in continuous integration using the CI's environment configuration (GitLab variables
in our case), though I'd imagine any equivalent way to set an environment variable should work.
I'm not too sure why it's not working for you, but some ideas to check:
jsbundling-rails
at least v1.1.2 which included this change?assets:precompile
that might be running yarn install
?Thanks @aduth I've verified that during build we are getting version 1.3.0 of jsbundling-rails. It is not clear whether something else is calling yarn install. Failure errors involve rake. I am using docker with s2i to test locally. Here is the relevant output:
Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
rake aborted!
jsbundling-rails: Command build failed, ensure `yarn build` runs without errors
/opt/app-root/bundle/ruby/3.1.0/gems/jsbundling-rails-1.3.0/lib/tasks/jsbundling/build.rake:14:in `block (2 levels) in <main>'
/opt/app-root/bundle/ruby/3.1.0/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => assets:precompile => javascript:build
(See full trace by running task with --trace)
Failed assembling
Error: building at STEP "RUN .s2i/bin/assemble": while running runtime: exit status 1
Closes #130
These changes allow a project to skip the
yarn install
prestep of the JavaScript build if, for example, their build pipeline will already ensure that dependencies have been installed.Open question: Should this logic be contained to the existing
build
task, rather than spun out as a new prerequisite task as proposed?