Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents infinite loops with --cwd #373

Merged
merged 2 commits into from
Aug 22, 2019
Merged

Prevents infinite loops with --cwd #373

merged 2 commits into from
Aug 22, 2019

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Aug 22, 2019

What's the problem this PR addresses?

Yarn was running in an infinite loop when the --cwd option was pointing to the /tmp folder on OSX, which is a symlink to /private/tmp. I'm not 100% sure why it was doing that as we were doing a chdir to /tmp, not /private/tmp, so I'd have expected process.cwd() to return the same path, but it's not what happens (reproduced in the Node repl).

How did you fix it?

We'll now compare the realpath'd cwds rather than the virtual ones. This isn't a big deal anyway as this will only affect the few commands that use --cwd.

Which packages would need a new release (if any)?

berry-cli

Have you run yarn version [major|minor|patch] --deferred in those packages?

  • Yes

@arcanis arcanis merged commit 5a1318f into master Aug 22, 2019
@arcanis arcanis deleted the mael/infinite-cwd-loops branch August 22, 2019 15:08
arcanis added a commit that referenced this pull request Jul 28, 2023
**What's the problem this PR addresses?**
<!-- Describe the rationale of your PR. -->
<!-- Link all issues that it closes. (Closes/Resolves #xxxx.) -->

The `--cwd` argument is currently resolved using `realpathSync`.
This behavior was introduced in
#373 as a workaround for a bug
caused by symlinks and the recursive `--cwd` logic.

**How did you fix it?**
<!-- A detailed description of your implementation. -->

Removed the unnecessary `realpath` calls. They are no longer needed due
to the removal of the recursive logic in
#5600.

I've also added a few tests, I'll add the rest from
#5595 in a future PR.

**Checklist**
<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [X] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [X] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [X] I will check that all automated PR checks pass before the PR gets
reviewed.

---------

Co-authored-by: Maël Nison <nison.mael@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant