webpacker: Railtie yarn check --integrity fails on development

just updated to 3.4.0 and I get this:

========================================
  Your Yarn packages are out of date!
  Please run `yarn install` to update.
========================================


To disable this check, please add `config.webpacker.check_yarn_integrity = false`
to your Rails development config file (config/environments/development.rb).


yarn check v1.5.1
warning package.json: No license field
warning No license field
warning Integrity check: Flags don't match
error Integrity check failed
error An unexpected error occurred: "Found 1 errors.".
info If you think this is a bug, please open a bug report with the information provided in "/Users/markus/svn/caseman-events/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

If I run it manually, everything is fine:

→   yarn check --integrity                                                                                                                                                                       [demo/develop]
yarn check v1.5.1
warning package.json: No license field
warning No license field
success Folder in sync.
   Done in 0.10s.

If I use NODE_ENV=production I can reproduce it:

→   NODE_ENV=production yarn check --integrity                                                                                                                                                   [demo/develop]
yarn check v1.5.1
warning package.json: No license field
warning No license field
warning Integrity check: Flags don't match
error Integrity check failed
error An unexpected error occurred: "Found 1 errors.".
info If you think this is a bug, please open a bug report with the information provided in "/Users/markus/svn/caseman-events/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

If I install with production …

NODE_ENV=production yarn install

… I can use rails again and the rails integrity check works. But of course I want to use my development yarn packages, so this is no solution.

The problems seems to be that yarn check --integrity is run with NODE_ENV=producion, even locally when developing.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 64 (11 by maintainers)

Commits related to this issue

Most upvoted comments

For me restarting spring fixed it: spring stop

Why was this issue closed? What is the solution? What’s happening that causes this?

just updated to 3.4.0 and I get this:

========================================
  Your Yarn packages are out of date!
  Please run `yarn install` to update.
========================================


To disable this check, please add `config.webpacker.check_yarn_integrity = false`
to your Rails development config file (config/environments/development.rb).


yarn check v1.5.1
warning package.json: No license field
warning No license field
warning Integrity check: Flags don't match
error Integrity check failed
error An unexpected error occurred: "Found 1 errors.".
info If you think this is a bug, please open a bug report with the information provided in "/Users/markus/svn/caseman-events/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

If I run it manually, everything is fine:

→   yarn check --integrity                                                                                                                                                                       [demo/develop]
yarn check v1.5.1
warning package.json: No license field
warning No license field
success Folder in sync.
   Done in 0.10s.

If I use NODE_ENV=production I can reproduce it:

→   NODE_ENV=production yarn check --integrity                                                                                                                                                   [demo/develop]
yarn check v1.5.1
warning package.json: No license field
warning No license field
warning Integrity check: Flags don't match
error Integrity check failed
error An unexpected error occurred: "Found 1 errors.".
info If you think this is a bug, please open a bug report with the information provided in "/Users/markus/svn/caseman-events/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

If I install with production …

NODE_ENV=production yarn install

… I can use rails again and the rails integrity check works. But of course I want to use my development yarn packages, so this is no solution.

The problems seems to be that yarn check --integrity is run with NODE_ENV=producion, even locally when developing.

I had a yarn.lock file in the root directory of my rails app. Deleting that solved my issue!

i have solve

config/webpacker.yml

-  check_yarn_integrity: true
+  check_yarn_integrity: false

Getting the same issue. Followed these upgrade instructions -https://github.com/rails/webpacker#upgrading

$ node --version
v8.11.3

$ yarn --version
1.7.0

$ yarn install
yarn install v1.7.0
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.54s.

$ yarn check --integrity
yarn check v1.7.0
success Folder in sync.
✨  Done in 0.10s.

$ rails --version
Rails 5.2.0

$ ruby --version
ruby 2.5.1p57

Issue:

$ rails c

========================================
  Your Yarn packages are out of date!
  Please run `yarn install` to update.
========================================


To disable this check, please add `config.webpacker.check_yarn_integrity = false`
to your Rails development config file (config/environments/development.rb).


yarn check v1.7.0
warning Integrity check: System parameters don't match
error Integrity check failed
error Found 1 errors.
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

The deal is that many things need to be in sync on the same node.js version. They can be out of sync when you have a default node version, create a Rails project, and then switch to a different version, for example, via nvm use. I didn’t check every permutation, but node version can affect:

  • Rails’ spring preloader. spring stop
  • node_modules rm -rf node_modules
  • yarn.lock rm yarn.lock
  • Rails server. Ctrl-C rails s

yarn install --check-files 🤞

Why was this issue closed? What is the solution? What’s happening that causes this?

@kulte I found that running sudo yarn install works.
Thanks to: https://stackoverflow.com/questions/50078826/rubymine-and-yarn

spring stop or DISABLE_SPRING=1 rails c were the only solutions that worked for me (and it seems like several others). Why doesn’t spring play nicely with yarn here? Anybody have an idea what’s going on?

For me it was:

rm -rf node_modules

Just dropping a note here to share my experience.

I’ve encountered the exact same issue. For my case, just restarting my terminal fixed the problem.

I had changed few configuration for NVM, which would have done something related.

Same problem here using docker.

Starting myapp_db_1 ... done
Creating myapp_web_1 ... done
Attaching to gymintel_db_1, gymintel_web_1
db_1   | 2018-07-08 03:55:23.713 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1   | 2018-07-08 03:55:23.713 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db_1   | 2018-07-08 03:55:23.719 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1   | 2018-07-08 03:55:23.894 UTC [22] LOG:  database system was interrupted; last known up at 2018-07-08 03:27:33 UTC
db_1   | 2018-07-08 03:55:27.237 UTC [22] LOG:  database system was not properly shut down; automatic recovery in progress
db_1   | 2018-07-08 03:55:27.306 UTC [22] LOG:  invalid record length at 0/1633A70: wanted 24, got 0
db_1   | 2018-07-08 03:55:27.306 UTC [22] LOG:  redo is not required
db_1   | 2018-07-08 03:55:27.548 UTC [1] LOG:  database system is ready to accept connections
web_1  | => Booting Puma
web_1  | => Rails 5.2.0 application starting in development
web_1  | => Run `rails server -h` for more startup options
web_1  |
web_1  |
web_1  | ========================================
web_1  |   Your Yarn packages are out of date!
web_1  |   Please run `yarn install` to update.
web_1  | ========================================
web_1  |
web_1  |
web_1  | To disable this check, please add `config.webpacker.check_yarn_integrity = false`
web_1  | to your Rails development config file (config/environments/development.rb).
web_1  |
web_1  |
web_1  | yarn check v1.7.0
web_1  | error Couldn't find an integrity file
web_1  | error Found 1 errors.
web_1  | info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.
web_1  |
web_1  |
web_1  | Exiting
myapp_web_1 exited with code 1

My dockerfile:

FROM ruby:2.5.1
ADD https://dl.yarnpkg.com/debian/pubkey.gpg /tmp/yarn-pubkey.gpg
RUN apt-key add /tmp/yarn-pubkey.gpg && rm /tmp/yarn-pubkey.gpg
RUN echo 'deb http://dl.yarnpkg.com/debian/ stable main' > /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -qq -y --no-install-recommends build-essential libpq-dev curl
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get update && apt-get install -qq -y --no-install-recommends nodejs yarn
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
RUN yarn install
COPY . /myapp

rm yarn.lock && sudo yarn install solved the problem for me

For me restarting spring fixed it: spring stop

@pawurb’s solution works for me!

Docker

I kept running into this issue while in Docker. The problem was that I was precompiling my app after I copied the entire app in. I.e., my Dockerfile contained the following:

# Copy the Gemfile as well as the Gemfile.lock and install
# the RubyGems. This is a separate step so the dependencies
# will be cached unless changes to one of those two files
# are made.
COPY Gemfile Gemfile.lock package.json yarn.lock ./
RUN bundle install --verbose --jobs 20 --retry 5 && \
    yarn install --check-files

# Copy the main application.
COPY . ./

# precompile assets
RUN bundle exec rake assets:precompile

This essentially overwrote the dependencies yarn installed in Docker with the ones on my local computer, and hence the errors.

Solution

Add the node_modules/ folder in your .dockerignore file:

node_modules

You’re welcome.

@gauravtiwari Nope. Did not help. It appears when I want to create a model:

rails g model TestModel

Output:

========================================
  Your Yarn packages are out of date!
  Please run `yarn install` to update.
========================================


To disable this check, please add `config.webpacker.check_yarn_integrity = false`
to your Rails development config file (config/environments/development.rb).


env: node: No such file or directory

Running sudo yarn install also didn t work. It was giving the same error.

After disabling the yarn integrity check (config.webpacker.check_yarn_integrity = false) it worked. But I don t think this is the proper solution.

I encountered this when upgrading to v4.

None of the above solutions worked for me.

It turned out that even though I had disabled the integrity check in config/webpacker.yml, this was getting overridden by the earlier style of config in config/environments/development.rb

Seems that the canonical location for this config got moved from development.rb to webpacker.yml, but that older installations of Webpacker might still have the old config.

Removing the following two lines did the trick for me.

--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,6 +1,4 @@
 Rails.application.configure do
-  # Verifies that versions and hashed value of the package contents in the project's package.json
-  config.webpacker.check_yarn_integrity = true
   # Settings specified here will take precedence over those in config/application.rb.
 
   # In the development environment your application's code is reloaded on

Try just yarn install

For me restarting spring fixed it: spring stop

This works for me

@puneetpandey Have you run yarn install as suggested in the error? Does the error go away after that?

yarn --update-checksums worked for me!

couple of things about docker installation, which sort of works. try

  • to run yarn install after copying your folder. yarn needs a few files in your app to run
  • make sure nodejs is a newer copy. default node installations do not have npm. you can use :

RUN curl -sL https://deb.nodesource.com/setup_11.x | bash RUN apt-get install -qq -y nodejs

  • installing yarn using npm:

RUN npm install -g yarn

This is happening to me on a fresh install:

created a new app (this step seemed to work fine):

rails new install_test --webpack

created databases:

rails db:create

then tried starting server

rails server

output:

=> Booting Puma
=> Rails 5.1.5 application starting in development
=> Run `rails server -h` for more startup options


========================================
  Your Yarn packages are out of date!
  Please run `yarn install` to update.
========================================


To disable this check, please add `config.webpacker.check_yarn_integrity = false`
to your Rails development config file (config/environments/development.rb).


yarn check v1.5.1
warning Integrity check: Flags don't match
error Integrity check failed
error An unexpected error occurred: "Found 1 errors.".
info If you think this is a bug, please open a bug report with the information provided in "/Users/kurt/Sites/install_test/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.


Exiting

yarn-error.log trace

Trace: 
  Error: Found 1 errors.
      at MessageError.Error (native)
      at new MessageError (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:186:110)
      at /usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:59470:13
      at next (native)
      at step (/usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:98:30)
      at /usr/local/Cellar/yarn/1.5.1/libexec/lib/cli.js:109:13

Same thing - rails 5.1 with ruby 2.5.3 … nvm installs vuejs fine, yarn seems to work till I go to start server up.

Sudo install yarn doesn’t work.

Closing / reopening terminal as well as shutting down complete - no fix.

yarn --verify-tree was more helpful …

mirv:~/workspace $ yarn --verify-tree
yarn install v1.13.0
[1/4] Resolving packages...
[2/4] Fetching packages...
error @rails/webpacker@4.0.2: The engine "node" is incompatible with this module. Expected version ">=6.14.4". Got "6.11.2"
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

@afuno Could you please run yarn just to make sure yarn is run in development mode and then create model?

BTW, this is still an issue: https://github.com/rails/webpacker/issues/1374#issuecomment-375891562 so if you do assets:precompile make sure to run yarn again to re-install deps.

I followed the @mirageglobe 's suggestion that using npm install -g yarn fixed my project.

The same problem (rails webpacker:install). Downgrading to 3.3.1 resolved that.

For anyone using nvm to manage Node versions, make sure you’re on the correct Node version before installing. This may apply to Docker as well if your image defaults a different version of Node than you used to install things originally.

  1. nvm use to use the version defined in .nvmrc
  2. yarn install --check-files with the correct Node version
  3. nvm use in any other shell you want to run commands in
  4. Now the integrity checks will pass

please check webpacker.yml i have found that i wrote check_yarn_integrity twice and one of the was true after removing that the issue get fixed

I’m using nvm to control the version of node for projects, my projects don’t have spring.

I try a lot of solution above, for examples:

yarn --update-checksums
yarn install --check-files
yarn install
rm -rf node_module && yarn install

But it doesn’t work

This is how I solved the problem:

rm -rf yarn.lock
yarn install

spring stop worked here as well

For me restarting spring fixed it: spring stop

Thank you very much. You help me too much. AH. My mac was almost broken by me. You saved it.

Deleting yarn.lock also fix the issue in my rails 6.0 project … had issue after upgraded system node from 10 to 12 -v

Update: Unfortunately deleting yarn.lock didnt fix the issue in total the message disappears but also I lost the sass on my site (styling was of because some js error). So I reverted the version of node in nvm from 12.0.0 to 10.xx and it worked okay.

I had this issue, but my real problem was node-sass failing to install connected to incompatability with nodejs 12. I removed node and installed node 10.12 and the problem was solved.

[ONLY for people using nvm lazy loading]

Be sure to run $ node -v to trigger nvm to load before trying other solution.

P.s. For me, forgetting to load nvm always results in this error, but sometimes even with nvm loaded the problem persists, that’s when I’ll do $ spring stop (proposed by @pawurb).

Screen Shot 2019-06-30 at 2 27 49 PM

Left: Failed because node is actually not available (I am using NVM_LAZY_LOAD=true from zsh-nvm)

Right: Ensured node is available first and fixed.

Did anyone find a fix for this? I am facing the same issue with JRuby-9.2.6.0 / Rails-5.0.7.2

config.webpacker.check_yarn_integrity = false

Seems to work but doesn’t look like a good solution

  * 2019-03-16 08:13:12 executing `deploy:assets:precompile'
  * executing "cd /data/recruiters/releases/20190316024255 && RAILS_ENV=staging_internal bundle exec rake assets:precompile"
    servers: ["192.168.1.206"]
    [192.168.1.206] executing command
 ** [out :: 192.168.1.206] jruby: warning: unknown property jruby.cext.enabled
 ** [out :: 192.168.1.206] Loading Vger
 ** [out :: 192.168.1.206] Adding at_exit handler to close RabbitMQ Connection
 ** [out :: 192.168.1.206] Subscribing to RabbitMQ Queues
 ** [out :: 192.168.1.206] Loading Her Configuration
 ** [out :: 192.168.1.206] 
 ** [out :: 192.168.1.206] 
 ** [out :: 192.168.1.206] ========================================
 ** [out :: 192.168.1.206] Your Yarn packages are out of date!
 ** [out :: 192.168.1.206] Please run `yarn install` to update.
 ** [out :: 192.168.1.206] ========================================
 ** [out :: 192.168.1.206] 
 ** [out :: 192.168.1.206] 
 ** [out :: 192.168.1.206] To disable this check, please add `config.webpacker.check_yarn_integrity = false`
 ** [out :: 192.168.1.206] to your Rails development config file (config/environments/development.rb).
 ** [out :: 192.168.1.206] 
 ** [out :: 192.168.1.206] 
 ** [out :: 192.168.1.206] yarn check v1.13.0
 ** [out :: 192.168.1.206] warning package.json: No license field
 ** [out :: 192.168.1.206] warning No license field
 ** [out :: 192.168.1.206] error Couldn't find an integrity file
 ** [out :: 192.168.1.206] error Found 1 errors.
 ** [out :: 192.168.1.206] info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

@gauravtiwari NODE_ENV was missing from my environment variables. Now added that and set it to development. I am now running eb deploy again to see, if I encounter any issue/s. Will keep posting here. Thanks for the help!

I’m running into the same thing with a new Rails 5.2 RC2 app. For me it happened when running bundle exec active_storage:install, but it sounds like there is something behind the scenes that multiple things are hitting causing this issue.

Downgrading to 3.3.1 resolves the issue, FYI.