npm-install icon indicating copy to clipboard operation
npm-install copied to clipboard

Using yarn but ignoring lockfile

Open simonihmig opened this issue 3 years ago • 6 comments

Given a project with a yarn.lock and calling the action with useLockFile: false, I was surprised that it actually runs npm install, instead of yarn --no-lockfile. I would have expected the latter.

This seems to be intentional, looking at this code, but I wonder why?

simonihmig avatar May 20 '21 16:05 simonihmig

@bahmutov - is this by design or can I open an MR to address this?

YenHub avatar Jun 20 '21 14:06 YenHub

Ughh it seems like a bug

Sent from my iPhone

On Jun 20, 2021, at 10:37, Ian Gilkes @.***> wrote:

 @bahmutov - is this by design or can I open an MR to address this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

bahmutov avatar Jun 20 '21 20:06 bahmutov

I have opened a pull request which hopefully addresses this issue.

Let me know how it goes!

https://github.com/bahmutov/npm-install/pull/102

YenHub avatar Jun 21 '21 20:06 YenHub

@YenHub Thanks for tackling this! I have finally tried this, but still see the same (wrong) behavior (see https://github.com/kaliber5/ember-stargate/pull/322/checks?check_run_id=3905655494#step:4:40).

However it seems to me the action is not actually using the latest code, as the dist/index.js files has been last updated 9 month ago! @bahmutov seems your automated publishing workflow isn't compiling the action automatically, so how is this supposed to work?

Another point: I think for the lockfile to be ignored, yarn has to run with the --no-lockfile option. So shouldn't this line be like follows?

const args = shouldUsePackageLock ? ['--frozen-lockfile'] : ['--no-lockfile']

simonihmig avatar Oct 15 '21 12:10 simonihmig

Thanks @simonihmig for your update

RE:

const args = shouldUsePackageLock ? ['--frozen-lockfile'] : ['--no-lockfile']

Where an empty array is passed into exec as args, no args are presented, therefore Yarn will run with it's default behaviour, that is, no lock file behaviour.

You effectively end up with:-

return exec.exec(quote(yarnPath), [], options)

YenHub avatar Oct 15 '21 13:10 YenHub

Where an empty array is passed into exec as args, no args are presented, therefore Yarn will run with it's default behaviour, that is, no lock file behaviour.

I understand that, but the default behavior of yarn is to take the lockfile into account!? (at least that is for yarn v1)

simonihmig avatar Oct 15 '21 13:10 simonihmig