webpacker: Railtie yarn check --integrity fails running in development under docker
Software versions:
Docker for Mac: 18.03.1-ce-mac65 (24312)
ruby: 2.5.1
rails: 5.2.0
webpacker: 3.5.3
Expected behaviour:
I would expect a new containerised Rails 5.2 application to pass the yarn integrity check when starting the application.
Note: Running puma -C config/puma.rb
natively on the host Mac OS X does not trigger this issue.
Actual behaviour:
Same error as reported in #1374. When running the rails development server:
========================================
Your Yarn packages are out of date!
Please run `yarn install` to update.
========================================
Steps to reproduce:
- Create a new Rails 5.2 application, specifying --webpack (other options used in example to reduce the number of moving parts)
$ rails new webpacker-example --webpack --skip-active-record --skip-action-mailer --skip-active-storage --skip-action-cable --skip-turbolinks --skip-test --skip-system-test --no-rc
$ cd webpacker-example
$ yarn install
-
Add .dockerignore, Dockerfile, .env.docker and docker-compose.yml files as per this gist: https://gist.github.com/sauy7/d5c732faad876fde8b2d16672b29a992
-
Run:
docker-compose up --build
Note in the output that:
RUN yarn check --integrity
shows:
yarn check v1.7.0
success Folder in sync.
Done in 0.XXs.
-
Wait for Rails to try to fully start up.
-
Observe in server output:
========================================
Your Yarn packages are out of date!
Please run `yarn install` to update.
========================================
-
Note in config/environments/development.rb:
config.webpacker.check_yarn_integrity = true
-
Edit to:
config.webpacker.check_yarn_integrity = false
-
Re-run:
docker-compose up --build
-
Browse to http://localhost:3000 to see the default Rails home page.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 35
- Comments: 31 (2 by maintainers)
I had this problem but
config.webpacker.check_yarn_integrity = false
didn’t seem to fix it. For anyone else that’s an idiot like me, thecheck_yarn_integrity
config needs to be changed inconfig/environments/development.rb
, notconfig/webpacker.yml
. 🤦♂️The integrity failure comes because docker compose ignores
.dockerignore
for volume mount, which includesnode_modules
.yarn install
, anode_modules
folder is created according to the host environment.docker-compose up --build
, thenode_modules
folder inside docker container would be overlaid by the one from host machine, because of the volume mount:Error occurs this time since the node modules are not for container environment.
After you run
docker-compose run <service_name_here> yarn
, thenode_modules
on host machine would be updated according to the container environment since yarn is run inside container. The error would be gone when tryingdocker-compose up --build
again.A solution could be to avoid
node_modules
overlay by using anonymous volume:What have people done to solve this. It literally just showed up today and I have no idea what I should do!
Try:
docker-compose run <service_name_here> yarn
@mhbsti None, other than running with
config.webpacker.check_yarn_integrity = false
in development.rb as a workaround.@dmolesUC It often saved me already when running
bin/webpacker
orrails server
with outdated dependencies, so in general it makes sense to have it enabled on development.What worked for me is not to COPY the yarn.lock to the image by Dockerfile.
yarn.lock must be generate after Dockerfile execute “RUN yarn install”. Try remove yarn.lock from your project too and run the “docker-compose up --build” again.
Yes, you can’t guarantee the exactly version as in yarn.lock, but in package.json you have the lib versions with safe range.
But, then you install not the same Versions. Which may not be what you want.
Thanks @zhengpd! Your suggestion worked with rails
5.2.4.1
, docker19.03.8
, and yarn1.17.3
.~I put
/node_modules
into.dockerignore
file and the problem is gone. Not sure if this is a general solution.~Edited: not a solution since docker compose ignores
.dockerignore
for volume mount. The problem gone by coincidence at that time.Seems like the problem are different bindings for
node-sass
(and possibly other packages that depend on native libs).docker exec container yarn check --integrity
fails for me with the message “warning Integrity check: Linked modules don’t match”.Edit: Possible workarounds:
node_modules
before building (also delete relevant volumes, egdocker-compose down && docker volume prune
)If already onlinux-x64
, use matching node versions