Fixing Yarn1 erroring with failed to replace env#7767
Merged
honeyankit merged 2 commits intomainfrom Aug 9, 2023
Merged
Conversation
Contributor
Author
|
I have test it with Dependabot CLI and it passes and creates the PR successfully |
Contributor
Author
|
Create a smoke test for the same: dependabot/smoke-tests#113 |
Contributor
There was a problem hiding this comment.
I assume this was breaking and not walking through the entire dirs right?
Contributor
Author
There was a problem hiding this comment.
Yes. If the subdir did not contain the .npmrc file then it was breaking out. In such case if the repo root dir still had .npmrc file then error was getting raised.
abdulapopoola
approved these changes
Aug 8, 2023
deivid-rodriguez
approved these changes
Aug 9, 2023
Contributor
deivid-rodriguez
left a comment
There was a problem hiding this comment.
Looks great, nice catch!
Just had a question, purely out of curiosity!
npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb
Outdated
Show resolved
Hide resolved
196e48d to
a5f61a9
Compare
a5f61a9 to
642c17b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
If a repo has multiple .npmrc files, Dependabot only rewrites one of them to remove variables. NPM doesn't have an issue but Yarn 1 is not ok and errors out.
This issue was fixed in the PR but one of the edge case was to leading to raise the issue again.
Edge case:
User root dir contained the
.npmrcfile with it's sub-dir (foo/bar/foo1/bar1/yarn.lock). The Dependabot npm job was failing for path/foo/bar/foo1/bar1with the below error:Approach
The modified code now checks all the parent directories for
.npmrc files, whereas the previous code used to stopped, if a directory did not have one. Now I have removed the break statement and continually performing dirs.pop in each iteration, the loop in the modified code advances up to the root directory. This modification make sures that all relevant.npmrc filesare addressed. Also a minor regex change was done in the gsub technique for non-greedy matching.