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

lerna cannot locate packages after update from v7 to v8 #3964

Open
wasib-sureify opened this issue Mar 5, 2024 · 13 comments
Open

lerna cannot locate packages after update from v7 to v8 #3964

wasib-sureify opened this issue Mar 5, 2024 · 13 comments

Comments

@wasib-sureify
Copy link

Current Behavior

Cannot find packages after updating to lerna v8.
We have been using lerna with pnpm workspaces and everything used to work fine. Today I updated lerna to v8 and all of a sudden lerna stopped identifying any packages. Reverting lo lerna v7 makes everything run correctly again.

This is what it shows when I run lerna list
image

Expected Behavior

Steps to Reproduce

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs / Configuration

lerna.json

<!-- Please paste your `lerna.json` here -->

{ "$schema": "node_modules/lerna/schemas/lerna-schema.json", "npmClient": "pnpm", "version": "independent", "command": { "version": { "createRelease": "github", "conventionalCommits": true, "allowBranch": ["main", "*-hotfix"], "message": "chore(release): publish [skip ci]" } } }

lerna-debug.log

<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->

Environment

@apedroferreira

This comment was marked as off-topic.

@JamesHenry

This comment was marked as off-topic.

@JamesHenry
Copy link
Member

@wasib-sureify npx lerna info was requested in the issue template and would be helpful in figuring out what is going on, please kindly provide it or steps to reproduce the issue

@DannyS-Treetop
Copy link

We've experienced the same issue when upgrading Lerna from v6 to v7. Upgrading to v8 didn't work either. After the update from v6 to v7, Lerna was unable to find the packages. When building the project in a different folder (outside of the git repo), everything worked fine, so it appears to be related to either the folder structure or the repository.

After a lot of trial and error I tried to remove the .git folder from the original repo, which allowed Lerna to find the packages again. Maybe this helps pointing in the right direction. I've not been able to fix it yet.

  Binaries:
    Node: 20.11.1
  Utilities:
    Git: 2.44.0.
  npmPackages:
    lerna: ^8.1.2 => 8.1.2

@JamesHenry
Copy link
Member

@DannyS-Treetop did you try deleting all node_modules directories and recreating the lock file from scratch?

@DannyS-Treetop
Copy link

@DannyS-Treetop did you try deleting all node_modules directories and recreating the lock file from scratch?

Sorry for not including that. Yes I did remove all node_module directories, removed lock file, clone repo again, tried on different machines, etc. The only thing that really helps is moving the entire project to a different folder or removing the .git folder. We're using yarn by the way.

@apedroferreira

This comment was marked as off-topic.

@wasib-sureify
Copy link
Author

@wasib-sureify npx lerna info was requested in the issue template and would be helpful in figuring out what is going on, please kindly provide it or steps to reproduce the issue

Here is my response for npx lerna info

lerna notice cli v8.1.2
lerna info versioning independent

 Environment info:

  System:
    OS: macOS 14.2.1
    CPU: (12) arm64 Apple M3 Pro
  Binaries:
    Node: 20.10.0 - /usr/local/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
  Utilities:
    Git: 2.39.3 - /usr/bin/git
  npmPackages:
    lerna: 8.1.2 => 8.1.2 
    ```

@wasib-sureify
Copy link
Author

@DannyS-Treetop I also tried deleting the .git folder and it did not seem to help either. npx lerna list still does not list any packages.

What's strange is that pnpm install seems to see all the packages but none of the other commands work.

pnpm install output:

pnpm i
Scope: all 5 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +19
+++++++++++++++++++
Done in 936ms

npx lerna list output:

npx lerna list
lerna notice cli v8.1.2
lerna info versioning independent
lerna success found 0 packages

@JamesHenry
Copy link
Member

JamesHenry commented Mar 22, 2024

@apedroferreira FYI I have hidden all the comments related to your issue, as it is not related at all to the OP. Let's continue the discussion on the PR on your repo.

@wasib-sureify Thanks for confirming, nothing seems strange about your environment from what I can tell.

Please can you try creating a fresh lerna repo and see if you still have the same issue?

E.g. something like

mkdir lerna-issue-3964
cd lerna-issue-3964
npx lerna init
npx lerna create -y a
npx lerna create -y b
npx lerna list

And see if it returns any packages

@weiwei
Copy link

weiwei commented Apr 7, 2024

@wasib-sureify @JamesHenry I'm not sure if my issue is the same, but in my case the issue is triggered by a package exclusion rule in pnpm-package.yaml. I have a repo that could demonstrate the issue: https://github.com/weiwei/lrna

@wasib-sureify
Copy link
Author

wasib-sureify commented Apr 7, 2024

@weiwei Yes! That was exactly what was happening. I have the same line in my pnpm-package.yaml and commenting it resolves the issue.
@JamesHenry is this behavior intentional?

pnpm-package.yaml

  # all packages in direct subdirs of packages/
  - 'packages/*'
  # exclude packages that are inside test directories
  - "!**/test/**". <-----commenting this resolves the issue

Output of npx lerna list with or without commenting that exclusion line

Before:
npx lerna l
ist
lerna notice cli v8.1.2
lerna info versioning independent
lerna success found 0 packages

After commenting:
npx lerna list
lerna notice cli v8.1.2
lerna info versioning independent
lifetime-agent
lifetime-service
portals-common
sureui
lerna success found 4 packages

@weiwei
Copy link

weiwei commented Apr 9, 2024

So I did a bit of digging, and if I'm understanding correctly, it is caused by this line: https://github.com/nrwl/nx/blob/32144bb702b07eddf29ed70055dfbcbcc0f4b11c/packages/nx/src/plugins/package-json-workspaces/create-nodes.ts#L44

I changed it to the following and all the test went fine:

    if (negativePatterns.every((negative) => minimatch(p, negative))) {
      return createNodeFromPackageJson(p, workspaceRoot);
    }

I would like to submit a PR myself, but minimatch seems to have been used in a lot of places. I think it should be fixed by someone who knows better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants