Rails precompile assets Yarn executable was not detected
Asked Answered
T

3

15

I have a Rails project that we converted from Rails 5.0 to Rails 5.1.0. When I try to precompile the assets, I get the following error message:

Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install

Everything I read from an internet search says yarn and webpacker comes with Rails 5.1. I get the following from check the rails version.

$rails --version
Rails 5.1.0

How do I fix this? I'd also like to know what is happening.

Tussock answered 3/8, 2017 at 13:56 Comment(1)
Do you have installed webpacker and yarn?Hellfire
P
8

Rails 5.1 comes with SUPPORT for yarn and webpack, but you need to install them yourself. Yarn is a package manager and webpack is a package.

Follow instruction at https://yarnpkg.com/lang/en/docs/install/ to install Yarn in your system and then add webpack to your project like:

yarn add --dev webpack webpack-dev-server

Additionally, the message you're seeing is warning, rather than straight up error. If you do not need to use any of the fancy js packages, you can just use good ol' asset pipeline

Pvc answered 3/8, 2017 at 14:33 Comment(6)
I didn't see that the files were outputted. I just deleted public/assets/* and it created new files. Before I emptied the directory, I got no messages that it outputted compiled asset files. That this is just a warning is the critical information I needed. Thanks.Tussock
@FabrizioBertoglio What's the output of yarn -V? What's your system?Pvc
@Pvc thanks a lot. this is the solution of my problem #45498813Cervin
with rails 5.1, use yarn and webpack is obligated?!Elvia
It doesn't seem right that Rails 5.1 should depend on yarn - at least to the extent that it complains about its absence - but not add a dependency for it. It should at least be clear that installing yarn is not a requirement.Maugham
this worked for me -> you can just use good ol' asset pipelineStale
R
5

You could just remove bin/yarn from your App directory if you're not using yarn/webpacker to avoid the log message.

Rooftop answered 19/2, 2019 at 16:4 Comment(0)
E
2

If you're trying to deploy a Rails 5.2 project with Yarn at Heroku, I suggest you look into the Buildpacks order.

To make it work here, I needed the heroku/NodeJS to be placed before the heroku/Ruby.

enter image description here

Exportation answered 5/9, 2020 at 0:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.