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

Issue: failure to run with combinedDependencies: true on a monorepo #947

Open
asfaltboy opened this issue Jul 13, 2024 · 5 comments
Open
Labels
bug something is not working as expected

Comments

@asfaltboy
Copy link

Expected Behavior

I'm using yarn workspaces, and I expect it to work out of the box

Current Behavior

whenever I turn on the combinedDependencies: true option, I get an error

ERROR: Extracting dependencies ran afoul of...

pWorkspace.endsWith is not a function
... in e2e/playwright.config.ts

Without the option it runs ok, but reports packages as missing, where they are specified at the top level workspace package.json file

Possible Solution

I would love to see a more descriptive error, and ideally it would just work...

Steps to Reproduce (for bugs)

  1. Create a yarn workspaces project
  2. Add number of packages in different locations
  3. Run depcruise --init wizard, choose the defaults
  4. Set the option combinedDependencies: true
  5. Run depcruise .

Context

Just trying dependency-cruiser out, as an alternative to circular dependency lint rule of eslint-plugin-import (see rule definition of import/no-cycle)

I would also accept a workaround that disables the missing dependency check, if circular deps can be checked independently.

Your Environment

  • Version used: 16.3.6
  • Node version: 20.9
  • Operating System and version: macOS Sonoma 14.5 (23F79)
  • Link to your project: private
@github-actions github-actions bot added the stale label Jul 23, 2024
@sverweij sverweij removed the stale label Jul 23, 2024
Repository owner deleted a comment from github-actions bot Jul 23, 2024
Copy link

github-actions bot commented Aug 3, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Aug 3, 2024
@github-actions github-actions bot closed this as completed Aug 6, 2024
@sverweij sverweij removed the stale label Aug 6, 2024
@sverweij sverweij reopened this Aug 6, 2024
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@sverweij
Copy link
Owner

IRL I've seen this happen when dependency-cruiser is run not in the root of the monorepo but instead in one of its sub folders (workaround then typically: run from the root).

Labeled as bug because dependency-cruiser either (1) needs to behave or (2) explain what's going on.

@sverweij
Copy link
Owner

Looking at the error message again it seems that the yarn workspaces in use in the project at hand has an unexpected non-string entry in the workspaces array (for yarn 2 and up workspaces is always supposed to be an array of strings, same with npm workspaces f.t.m.). I've adapted the code to deal with that (see #955).

The generic issue mentioned in my previous comment still exists, but seems unrelated to the current issue.

sverweij added a commit that referenced this issue Aug 31, 2024
…gs (instead of throwing) (#955)

## Description

- ignore entries in 'workspaces' arrays that aren't strings, instead of
throwing an exception


Yarn workspaces is an array of strings according to [its
documentation](https://yarnpkg.com/configuration/manifest#workspaces).
Apparently is possible (and accepted?) to have other types than strings
as well. Not sure whether that is _valid_, but at least it's happening
in the field, witnessing #947, so we deal with it.

## Motivation and Context

Addresses the error mentioned in #947 (and likely fixes it)

## How Has This Been Tested?

- [x] green ci
- [x] additional automated non-regression tests

## Types of changes

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Documentation only change
- [ ] Refactor (non-breaking change which fixes an issue without
changing functionality)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist

- [x] 📖

  - My change doesn't require a documentation update, or ...
  - it _does_ and I have updated it

- [x] ⚖️
- The contribution will be subject to [The MIT
license](https://github.com/sverweij/dependency-cruiser/blob/main/LICENSE),
and I'm OK with that.
  - The contribution is my own original work.
- I am ok with the stuff in
[**CONTRIBUTING.md**](https://github.com/sverweij/dependency-cruiser/blob/main/.github/CONTRIBUTING.md).
@sverweij
Copy link
Owner

sverweij commented Sep 1, 2024

The fix mentioned above has shipped with [email protected] (release notes: v16.4.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something is not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants