Plots2: Error Command "webpack" Not Found

Created on 28 Mar 2021  Â·  17Comments  Â·  Source: publiclab/plots2

Builds have been failing in the stable deployment due to the error error Command "webpack" not found

This seems to be a common error and there are some solutions as suggested below;

https://github.com/rails/webpacker/issues/522#issuecomment-328985202
https://github.com/rails/webpacker/issues/522#issuecomment-309873612

I am not sure what criteria we should use to pick a fix.

bug high-priority

All 17 comments

Do you have any thoughts on this @noi5e?

Running

rails webpacker:install

on my local machine seems to solve this issue

As pointed out in the gitter channel by @noi5e -

bundle install
rails webpacker:install
rails webpacker:install:react
rails generate react:install

Running these commands solves the issue.

Is this related to the lack of manifest.js file as well?

I just added these notes to https://github.com/publiclab/plots2/issues/3840#issue-375308231 as @TildaDares noted this:

Noting that due to recent install of webpacker there's an extra step needed, apologies if this has caused you trouble!

For now, you have to create a manifest.js file, following the steps shown here: https://stackoverflow.com/questions/58339607/why-does-rails-fails-to-boot-with-expected-to-find-a-manifest-file-in-app-asse#answer-58370129:~:text=Easy%20Steps%20To%20Solve%20the%20Problem%3A

The error you may see for which this is the solution is:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/jeff/.gem/ruby/2.6.6/gems/mimemagic-0.3.8/ext/mimemagic
/Users/jeff/.rubies/ruby-2.6.6/bin/ruby -rrubygems
/Users/jeff/.gem/ruby/2.6.6/gems/rake-13.0.3/exe/rake
RUBYARCHDIR\=/Users/jeff/.gem/ruby/2.6.6/extensions/x86_64-darwin-20/2.6.0-static/mimemagic-0.3.8
RUBYLIBDIR\=/Users/jeff/.gem/ruby/2.6.6/extensions/x86_64-darwin-20/2.6.0-static/mimemagic-0.3.8
rake aborted!
Could not find MIME type database in the following locations:
["/usr/local/share/mime/packages/freedesktop.org.xml",

The steps are:

This error comes up because you don't have a manifest.js created. You need to create one, and add in a few lines to make sure things are working. In the old version of sprockets, they made big assumptions about which assets sprockets is taking care of (i.e. bundling and concatenating). Not anymore. Now you have to tell sprockets explicitly, what files you want taken care of: and you do this in your manifest.js file.

Create the manifest.js file

$ mkdir -p app/assets/config

$ touch app/assets/config/manifest.js (not the root rails directory)

Then copy and paste the following into the manifest.js file you just created:

//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css

If you have a precompile array in your app/config/ folder (see below for an example) e.g. app/config/production.rb then perhaps you should move them over to your manifest.js if they are not already accessed above.

config.assets.precompile = ["admin.js", "admin.css"]

Lastly, if you are using webpacker, you might want to decide what you want handled by the asset pipeline and what you want handled by webpacker. i.e. remove the link_directory to the javascripts file according to your own particular use cases.

i.e. is it possible these steps @waridrox copied in from @noi5e also solve the manifest issue? Just trying to coordinate around these various hiccups. Thanks all!

@jywarren I ran into the webpack problem after syncing my fork, and was able to resolve it with these commands -

bundle install
rails webpacker:install
rails webpacker:install:react
rails generate react:install

For now, you have to create a manifest.js file, following the steps shown here: https://stackoverflow.com/questions/58339607/why-does-rails-fails-to-boot-with-expected-to-find-a-manifest-file-in-?app-asse#answer-58370129:~:text=Easy%20Steps%20To%20Solve%20the%20Problem%3A

This I believe is for people trying to setup a new db altogether, with sqlite since they are running into problems with sql after the command db:setup
ERROR -

LoadError: Error loading the 'mysql2' Active Record adapter. Missing a gem it depends on? mysql2 is not part of the bundle. Add it to your Gemfile.

The workaround then is to do - cp config/database.yml.sqlite.example config/database.yml and some configuration required in manifest.js provided by the link above after running this command. Since I already had redis db setup, I didn't face the issue of creating a manifest.js file.

I just made an FTO at #9392 to update the installation docs for React & webpacker setup!

It's a distinct issue from this one, because as @RuthNjeri mentioned in the original post builds are failing over at stable. For that we'll need to ping @icarito, which I'll do in chat right now.

oh this is awesome. Thank you @noi5e!!!!!

On Tue, Mar 30, 2021 at 2:05 PM noi5e @.*> wrote:

I just made an FTO at #9392
https://github.com/publiclab/plots2/issues/9392 to update the
installation docs for React & webpacker setup!

It's a distinct issue from this one, because as @RuthNjeri
https://github.com/RuthNjeri mentioned in the original post builds are
failing https://jenkins.laboratoriopublico.org/job/Plots-Stable/ over
at stable. For that we'll need to ping @icarito
https://github.com/icarito, which I'll do in chat right now.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/9382#issuecomment-810466858,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAF6J56W7JRI7FGR6BYI3LTGIHHFANCNFSM4Z56NBAA
.

A quick search on StackOverflow provided me with these answers:

  1. bundle exec rails webpacker:install
  2. Upgrading the node version

Will any of these work?

A couple of weeks ago, webpacker was built correctly in our unstable staging instance.
https://jenkins.laboratoriopublico.org/job/Plots-Unstable/1098/console

I pushed unstable to a new branch and made a pull request to be able to compare the code:
https://github.com/publiclab/plots2/pull/9393/files

It looks to me like @anirudhprabhakaran3 is correct that the node version needs to be updated.

OK just noting that @icarito and i realized the GitHub diff is wrong - all those changes are already in our main branch. Also it seems to be building our stable branch fine in Jenkins, so something is odd with our main branch not building to stable.publiclab.org. Looking deeper...

Just noting that it seems to be written wrong in 3 places in the GitHub Actions config - webpack instead of webpacker:

https://github.com/publiclab/plots2/blob/999264ebe70d750f1836a4b4dcbdb7118595639b/.github/workflows/tests.yml#L49

I think stable.publiclab.org is building again!!!

Yup, I think #9395 did fix it.

Ah, great, I see. I put the commands in the wrong order. Thanks @icarito!

Just noting that it seems to be written wrong in 3 places in the GitHub Actions config - webpack instead of webpacker:

Oh yeah, I left a note about this in chat (but obviously it's easy to miss with all the activity lately):

It's meant to be rails webpacker:install:react instead of rails g webpack:install:react. 🤦 @jywarren You might want to take note, because we currently have 2 out of 3 wrong commands in the GitPod & test flows!

OK, i'll make that change in a pr, thanks @noi5e !!!

Thanks, everyone! 🎉
Closing the issue since PRs referencing it have been merged 🚀

Was this page helpful?
0 / 5 - 0 ratings