-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exit before assets:precompile task if yarn:install fails #36852
Exit before assets:precompile task if yarn:install fails #36852
Conversation
I'm unsure why CI failed on this one with the change I did. Any ideas? They seem to be unrelated to what this PR is about (i.e. actioncable for example). |
I was interested in this, and so I had a dig around. It seems like the test failures stem from the dummy Our Incidentally, it feels like we might want to have a deeper look at the test cases here, in case we're missing other examples that are passing by coincidence. But that feels like another PR. |
@sarcas Thank you, that was helpful. I will take a look at the specs. I will take a crack at updating the specs in this PR this week and see how big of a task this is. Maybe the webpacker gem tests can give me an idea of how to solve this. |
@juliantrueflynn you're welcome! I had more time this evening, and it looks like the file in question was introduced here: #35184. Interestingly that PR was about |
@@ -9,6 +9,7 @@ namespace :yarn do | |||
valid_node_envs.include?(Rails.env) ? Rails.env : "production" | |||
end | |||
system({ "NODE_ENV" => node_env }, "#{Rails.root}/bin/yarn install --no-progress --frozen-lockfile") | |||
exit(1) unless $?.success? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit(1) unless $?.success? | |
system({ "NODE_ENV" => node_env }, "#{Rails.root}/bin/yarn install --no-progress --frozen-lockfile") || raise |
I think raise
is more appropriate than exit
. This allows to switch to the using exception: true
option when only support Ruby >= 2.6.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This `raise` was recommended by @y-yagi in rails#36852
Fixed by #41824 |
Summary
I made this change to Webpacker and was recommended by @gauravtiwari to make it to Rails itself:
rails/webpacker#2192
Reason for change: When doing
yarn:install
if it failed theassets:precompile
task would still be invoked. This PR ensures that on failure withyarn:install
thatassets:precompile
will not be invoked.Other Information
Link to original issue for person who spotted this: rails/webpacker#2185