rubyforgood / shelter-assist

Software to help foster-based animal rescues keep track of their animals and people.
14 stars 13 forks source link

Sets yarn to specific version - 1.22.17 for now. #98

Closed chriszimmerman closed 2 years ago

chriszimmerman commented 2 years ago

When opening PRs or deploying to Heroku, I noticed a problem when the build tried to install yarn. Here is an example:

https://github.com/rubyforgood/shelter-assist/runs/6885776407?check_suite_focus=true

The output:

Run sergioramos/yarn-actions/install@v6
yarn --non-interactive --frozen-lockfile install
yarn install v1.22.18
[1/5] Validating package.json...
error shelter-assist@0.1.0-alpha: The engine "yarn" is incompatible with this module. Expected version "1.22.17". Got "1.22.18"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Command failed with exit code 1 (EPERM): yarn --non-interactive --frozen-lockfile install
    at makeError (/home/runner/work/_actions/sergioramos/yarn-actions/v6/node_modules/execa/lib/error.js:58:1)
    at handlePromise (/home/runner/work/_actions/sergioramos/yarn-actions/v6/node_modules/execa/index.js:112:1)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at module.exports.module.exports (/home/runner/work/_actions/sergioramos/yarn-actions/v6/src/handler.js:69:37) {
  command: 'yarn --non-interactive --frozen-lockfile install',
  exitCode: 1,
  exitCodeName: 'EPERM',
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false,
  signal: undefined
}

And there's similar log output related to this issue when deploying to Heroku:

-----> Installing yarn-v1.22.17

-----> Detecting rake tasks

-----> Preparing app for Rails asset pipeline

       Running: rake assets:precompile

       yarn install v1.22.17

       [1/5] Validating package.json...

       error shelter-assist@0.1.0-alpha: The engine "yarn" is incompatible with this module. Expected version "1.22.18". Got "1.22.17"

       error Found incompatible module.

       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

       rake aborted!

       jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors

       /tmp/build_1c90142f/vendor/bundle/ruby/3.0.0/gems/jsbundling-rails-0.1.9/lib/tasks/jsbundling/build.rake:5:in `block (2 levels) in <main>'

       Tasks: TOP => assets:precompile => javascript:build

       (See full trace by running task with --trace)

There seems to be an issue with a yarn version mismatch. I believe yarn-actions is just getting the latest version of yarn that it can find, which may be different from the version of yarn specified in our package.json.

Running the yarn set version command sets yarn to a particular version and adds the files in this commit. I think as we upgrade yarn in the future, we can re-run yarn set version to update the .yarnrc files.

freestylebit commented 2 years ago

Any chance we can add the yarn version to the package.json file, as well? I think that will enforce the version we use.

Don't know if it's relevant, but a .node_version file at the root can help with this, too.

https://medium.com/productboard-engineering/one-yarn-to-rule-them-all-2d950127ee6f

chriszimmerman commented 2 years ago

Any chance we can add the yarn version to the package.json file, as well? I think that will enforce the version we use.

Don't know if it's relevant, but a .node_version file at the root can help with this, too.

https://medium.com/productboard-engineering/one-yarn-to-rule-them-all-2d950127ee6f

It looks like it's in there under the engine property (which should now show up in the diff) in the package.json.

In the article you posted, there is the suggestion to run yarn policies set-version to set the yarn version and enforce it, so I ran that. The CI check still looks good