webpacker icon indicating copy to clipboard operation
webpacker copied to clipboard

Rake task `webpacker:compile` fails when `which` is not installed

Open cbochs opened this issue 7 months ago • 0 comments

I thought I would report this here instead of shakapacker, since shakapacker hasn't been updated in more than 2 years. It appears that the yarn check depends on which being available on the system for the check to succeed. If it is not, then webpacker:compile fails with a relatively ambiguous error of:

$ bundle exec rake webpacker:compile

Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/
Exiting!

This occurs when running ruby/rails on a docker container which does not have which installed by default (e.g. an almalinux image).

Ruby version: 3.0.7 Rails version: 6.1.0 Webpacker version: shakapacker-6.5.2, but this issue is still present in the most recent RC (v6.0.0.rc.6)

Expected behavior:

Webpacker compiles

Actual behavior:

Webpacker fails to compile.

Small, reproducible repo:

$ docker run --rm -it almalinux

# dnf install -y epel-release
# dnf install --enablerepo-crb -y ruby-devel gcc libyaml-devel yarnpkg
# gem install shakapacker -v '6.5.2'

# type which
bash: type: which: not found

# type yarn
yarn is /usr/bin/yarn

# echo 'import "/usr/local/share/gems/gems/shakapacker-6.5.2/lib/tasks/webpacker/check_yarn.rake"' > Rakefile

# rake webpacker:check_yarn
Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/
Exiting!

cbochs avatar Jul 18 '24 15:07 cbochs