Skip to content
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

Clear error message when yarn or node not installed #2943

Merged

Conversation

melissavoegeli
Copy link

@melissavoegeli melissavoegeli commented Mar 3, 2021

This fix addresses #954

When yarn is NOT installed I run into the following issue:

   $ rake webpacker:check_yarn
   bin/rails: No such file or directory - yarn
   rails aborted!
   NoMethodError: undefined method `strip' for nil:NilClass
   Tasks: TOP => webpacker:check_yarn
   (See full trace by running task with --trace)

It looks like lib/tasks/webpacker/check_yarn.rake behaves as expected when line 6 calls yarn_version = `yarn --version`.strip. When yarn is not installed the shell raises an exception and is rescued on line 25.

HOWEVER! When running this in the application, Rails will rescue this exception and yarn --version will return nil. The tests do not test this adequately in a Rails environment.

This fix will more elegantly call which yarn first and follow the expected error handling.

when yarn is NOT installed I run into the following issue:

   $ rake webpacker:check_yarn
   bin/rails: No such file or directory - yarn
   rails aborted!
   NoMethodError: undefined method `strip' for nil:NilClass
   Tasks: TOP => webpacker:check_yarn
   (See full trace by running task with --trace)

It looks like lib/tasks/webpacker/check_yarn.rake behaves as expected
when line 6 calls yarn_version = `yarn --version`.strip.  When yarn is
not installed the shell raises an exception and is rescued on line 25.

HOWEVER! When running this in the application, Rails will rescue this exception
and `yarn --version` will return nil.  The tests do not test this adequately
in a Rails environment.

This fix will more elegantly call `which yarn` first and follow the
expected error handling.
@melissavoegeli melissavoegeli changed the title When I attempt to run the check_yarn take task Clear error message when yarn or node not installed Mar 3, 2021
@pedrofurtado
Copy link
Member

Hi @melissavoegeli ! 👋

Thank you for your contribution! Great fix 🍻

Looks good to be merged ✅ @gauravtiwari

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants