nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.68k stars 2.36k forks source link

Failed to parse bun lockfile #26565

Closed jimlloyd closed 5 months ago

jimlloyd commented 5 months ago

Current Behavior

The following error occurs for a variety of bun nx ... commands. For example:

bun nx run @memento-ai/memento-agent:lint

Note that I am in the process of migrating an existing bun monorepo project to use nx. After a few false starts I was able to get to the point where I could run lint on each package. I had not been running eslint previously so I found and fixed many warnings and errors, and in particular found and fixed multiple instances of cyclic dependencies (which made me very happy).

But oddly, I got to the point where all packages passed lint (i.e. bun nx run-many --target=lint --all=true --with-deps=true was successful), and then committed about a dozen different files that had been modified with my last set of changes, and that somehow caused this problem.

 NX   Failed to parse bun lockfile

Please open an issue at `https://github.com/nrwl/nx/issues/new?template=1-bug.yml` and provide a reproduction.

Original error: Expected double-quoted property name in JSON at position 219 (line 11 column 3)

SyntaxError: Expected double-quoted property name in JSON at position 219 (line 11 column 3)
    at JSON.parse (<anonymous>)
    at getHoistedPackageVersion (/Users/jim.lloyd/hub/Memento/node_modules/nx/src/plugins/js/lock-file/utils/package-json.js:13:21)
    at getHoistedVersion (/Users/jim.lloyd/hub/Memento/node_modules/nx/src/plugins/js/lock-file/yarn-parser.js:191:65)
    at findHoistedNode (/Users/jim.lloyd/hub/Memento/node_modules/nx/src/plugins/js/lock-file/yarn-parser.js:120:28)
    at getNodes (/Users/jim.lloyd/hub/Memento/node_modules/nx/src/plugins/js/lock-file/yarn-parser.js:109:29)
    at getYarnLockfileNodes (/Users/jim.lloyd/hub/Memento/node_modules/nx/src/plugins/js/lock-file/yarn-parser.js:30:12)
    at getLockFileNodes (/Users/jim.lloyd/hub/Memento/node_modules/nx/src/plugins/js/lock-file/lock-file.js:51:59)
    at exports.createNodes (/Users/jim.lloyd/hub/Memento/node_modules/nx/src/plugins/js/index.js:47:64)
    at /Users/jim.lloyd/hub/Memento/node_modules/nx/src/project-graph/plugins/utils.js:47:33
    at Array.map (<anonymous>)

Expected Behavior

No error.

GitHub Repo

https://github.com/memento-ai/Memento

Steps to Reproduce

  1. Clone the repo
  2. git checkout nx-try-3
  3. bun install
  4. bun nx run @memento-ai/memento-agent:lint

I also tried to rollback to prior commits where nx lint was working, but I had been working with multiple modified files. The problem only occurred after committing all files. I did this with a series of commits, but did not run nx lint again during the process of committing, and was unable to figure out if there was a particular commit that caused the breakage.

My efforts to rollback and fix were done in the branch temp-1a2e107. The commit 1a2e107 is in the history of nx-try-3.

Nx Report

NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.

Failure Logs

No response

Package Manager Version

bun: 1.1.12 or 1.1.13

Operating System

Additional Information

Probably related to #26053

jimlloyd commented 5 months ago

I was able to diagnose and fix the primary problem. My method was to simply try to use yarn to install and the discover that it reported errors that clearly should be fixed. After fixing all of those errors, bun nx ... commands are working.

@Jordan-Hall no need to follow up. Thanks for doing this integration, it would be painful to have to give up bun.

github-actions[bot] commented 3 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.