yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.43k stars 1.11k forks source link

[Bug] Git URL Resolve Regression #2240

Closed elmpp closed 3 years ago

elmpp commented 3 years ago

Describe the bug

As discussed on Discord, it seems a regression has occurred sometime prior to 2.4.0 when a git-style reference isn't handled correctly

To Reproduce

// package.json

dependencies: {
  ...
  "typeorm": "git@github.com:elmpp/typeorm.git#commit=610da48cd6d82c7adadf19dbca1a62ba2fdebf00"
}
○ → yarn
➤ YN0000: ┌ Resolution step
➤ YN0001: │ TypeError [ERR_INVALID_URL]: Invalid URL: git@github.com:elmpp/typeorm.git
    at onParseError (internal/url.js:258:9)
    at new URL (internal/url.js:334:5)
    at Module.d (/Users/matt/dev/org-repo/.yarn/releases/yarn-2.4.0.cjs:2:412670)
    at b (/Users/matt/dev/org-repo/.yarn/releases/yarn-2.4.0.cjs:2:136459)
    at v (/Users/matt/dev/org-repo/.yarn/releases/yarn-2.4.0.cjs:2:136973)
    at F.resolvers.getCandidates (/Users/matt/dev/org-repo/.yarn/releases/yarn-2.4.0.cjs:2:140649)
    at n.getCandidates (/Users/matt/dev/org-repo/.yarn/releases/yarn-2.4.0.cjs:2:336286)
    at n.getCandidates (/Users/matt/dev/org-repo/.yarn/releases/yarn-2.4.0.cjs:2:336286)
    at /Users/matt/dev/org-repo/.yarn/releases/yarn-2.4.0.cjs:2:357942
    at Module.w (/Users/matt/dev/org-repo/.yarn/releases/yarn-2.4.0.cjs:2:417413)
➤ YN0000: └ Completed in 0s 289ms
➤ YN0000: Failed with errors in 0s 299ms

Environment if relevant (please complete the following information):

ghost commented 3 years ago

If I do yarn add uNetworking/uWebSockets.js#v18.12.0 with Yarn 1 it works, just like npm install uNetworking/uWebSockets.js#v18.12.0 does (it downloads from GitHub).

In Yarn 2 I get

Internal Error: Invalid descriptor (uNetworking/uWebSockets.js#v18.12.0)
    at Module.x (/home/alexhultman/.yarn/releases/yarn-2.4.0.cjs:2:434115)
    at Promise.all.packages.map (/home/alexhultman/.yarn/releases/yarn-2.4.0.cjs:2:29878)
    at Array.map (<anonymous>)
    at M.execute (/home/alexhultman/.yarn/releases/yarn-2.4.0.cjs:2:29786)
merceyz commented 3 years ago

@alexhultman You need to give it a name yarn add uWebSockets.js@uNetworking/uWebSockets.js#v18.12.0