Hello, I know this is not a new issue and I've checked multiple sources to see if the solutions are helpful but it yields no positive outcome, it works perfect locally but receive this error during pipelines running with CI/CD in test stage when it's deployed to the Gitlab:
Webpacker::Manifest::MissingEntryError: Webpacker can't find application in /app/public/packs/manifest.json. Possible causes: 1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. webpack has not yet re-run to reflect updates. 3. You have misconfigured Webpacker's config/webpacker.yml file. 4. Your webpack configuration is not creating a manifest. Your manifest contains: { }Here are few lines from the application.html file:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>and my stylesheets are .scss files and there's no .css file in the project.
This is my webpacker.yml :
default: &default source_path: app/javascript source_entry_path: packs public_root_path: public public_output_path: packs cache_path: tmp/cache/webpacker check_yarn_integrity: false webpack_compile_output: true # Additional paths webpack should lookup modules # ['app/assets', 'engine/foo/app/assets'] resolved_paths: [ ] # Reload manifest.json on all requests so we reload latest compiled packs cache_manifest: false # Extract and emit a css file extract_css: true static_assets_extensions: - .jpg - .jpeg - .png - .gif - .tiff - .ico - .svg - .eot - .otf - .ttf - .woff - .woff2 extensions: - .mjs - .js - .sass - .scss - .css - .module.sass - .module.scss - .module.css - .png - .svg - .gif - .jpeg - .jpg development: <<: *default compile: true # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules check_yarn_integrity: true # Reference: https://webpack.js.org/configuration/dev-server/ dev_server: https: false host: localhost port: 3035 public: localhost:3035 hmr: false # Inline should be set to true if using HMR inline: true overlay: true compress: true disable_host_check: true use_local_ip: false quiet: false pretty: false headers: "Access-Control-Allow-Origin": "*" watch_options: ignored: "**/node_modules/**" test: <<: *default compile: true # Compile test packs to a separate directory public_output_path: packs-test production: <<: *default # Production depends on the precompilation of packs prior to booting for performance. compile: false # Extract and emit a css file extract_css: true # Cache manifest.json for performance cache_manifest: trueAm I missing anything?
@Sakshi1305 Is this error happening in your tests? If so, does precompiling assets _before_ the tests are run help, i.e.: RAILS_ENV=test bin/rake assets:precompile?
@Sakshi1305 Is this error happening in your tests? If so, does precompiling assets _before_ the tests are run help, i.e.:
RAILS_ENV=test bin/rake assets:precompile?
Thanks @rossta but this also gave me the same error. I already tried this. This error happens during ci/cd autodevops pipeline on GitLab
@Sakshi1305 This error happened to me as well when trying to run request spec in gitlab ci.
This can be fixed by rails webpacker:compile but to run this in gitlab-ci, you need to configure gitlab.ci.yml (basically to support node and yarn/npm)
Following is the snippet for my gitlab.ci.yml
.test_app:
image: "ruby:2.6.5"
cache:
paths:
- vendor/ruby
- node_modules
services:
- postgres:latest
variables:
RAILS_ENV: test
POSTGRES_HOST_AUTH_METHOD: trust
before_script:
- export APT_CACHE_DIR=`pwd`/apt-cache && mkdir -pv $APT_CACHE_DIR
# Install node and dependencies
- curl -sL https://deb.nodesource.com/setup_12.x | bash -
- apt-get update -yq
- apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y apt-transport-https build-essential cmake nodejs software-properties-common unzip
# Install yarn
- wget -q -O - https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
- apt-get update -yq
- apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y yarn
- yarn install
# Bundler and bundle install
- gem install bundler --no-document
- bundle install --jobs $(nproc) "${FLAGS[@]}" --path vendor
# App setup
- cp config/database.yml.gitlab config/database.yml
- bundle exec rake db:setup
- bundle exec rails webpacker:compile
test:rspec:
extends: .test_app
stage: test
artifacts:
name: coverage_report
paths:
- coverage/
script:
- bundle exec rspec
@BlackRabbitt : Thanks, this is worked but really i faced problem in autodevops ci deployment so i want to know how webpacker worked in autodevops ci deployment or this is not supported yet.
I run into this bug with a newly generated project on rails 6.0.3.2 upgrading all dependencies (including JS) to current.
By debugging this, the problem seems to be in @rails/webpacker 5.2.X Javascript package as downgrading to 5.1.1 fixed the problem. Running rails with and without webpack-dev-server works fine. But if I try to run bin/rails test he doesn't generate pubic/packs-test resulting in an empty manifest file error you described.
@Sakshi1305 : did you manage to fix this issue?
@fa11enangel also seeing this mysterious issue with the missing packs-test directory on circleci since upgrading from webpacker 5.1.1 to 5.2.1. downgrading appears to fix the issue. working around it currently by running rake webpacker:compile in circleci prior to running the tests.
Most helpful comment
I run into this bug with a newly generated project on rails 6.0.3.2 upgrading all dependencies (including JS) to current.
By debugging this, the problem seems to be in
@rails/webpacker 5.2.XJavascript package as downgrading to 5.1.1 fixed the problem. Running rails with and without webpack-dev-server works fine. But if I try to runbin/rails testhe doesn't generate pubic/packs-test resulting in an empty manifest file error you described.