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

Fail to load packages installed from Git repo with pnpm v9 #17459

Closed
7 tasks done
kong-dev opened this issue Jun 13, 2024 · 10 comments · Fixed by pnpm/pnpm#8557
Closed
7 tasks done

Fail to load packages installed from Git repo with pnpm v9 #17459

kong-dev opened this issue Jun 13, 2024 · 10 comments · Fixed by pnpm/pnpm#8557
Labels
p4-important Violate documented behavior or significantly improves performance (priority)

Comments

@kong-dev
Copy link

Describe the bug

Since upgrading to pnpm v9, Vite has failed to load packages installed from Git repo.

Error like this
  vite:load 5.98ms [fs] /main.js +0ms
  vite:resolve 6.61ms uuid-mirror -> /Users/kongdev/Workspace/demo/vite-issue/node_modules/.pnpm/uuid@git+https+++gitee.com+kongdev+uuid.git#da189d1792993d0da4b5008ea98c5ef48896739c/node_modules/uuid/dist/esm-browser/index.js +29ms
  vite:import-analysis 15.07ms [1 imports rewritten] main.js +0ms
  vite:transform 24.05ms /main.js +0ms
3:06:02 PM [vite] Pre-transform error: Failed to load url /node_modules/.pnpm/uuid@git+https+++gitee.com+kongdev+uuid.git?import#da189d1792993d0da4b5008ea98c5ef48896739c/node_modules/uuid/dist/esm-browser/index.js (resolved id: /Users//kongdev/Workspace/demo/vite-issue/node_modules/.pnpm/uuid@git+https+++gitee.com+kongdev+uuid.git#da189d1792993d0da4b5008ea98c5ef48896739c/node_modules/uuid/dist/esm-browser/index.js) in /Users//kongdev/Workspace/demo/vite-issue/main.js. Does the file exist?

Repos on Github or Gitlab exhibit no issues, yet those on self-hosted services or other Git providers encounter problems.

It seems there is # in the file path that may be causing the issue. logic here

Reproduction

https://github.com/kong-dev/vite-issue

Steps to reproduce

The repository above is a minimal reproduction including 2 dependencies:

  • 'uuid' from the npm registry
  • 'uuid-mirror' from the mirrored Git repo

Steps:

  • Install pnpm v9
  • Clone the repo above
  • Run pnpm install
  • Start the dev server by running pnpm run dev
  • Access in the browser

System Info

System:
    OS: macOS 14.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 418.56 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
    pnpm: 9.3.0 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 126.0.6478.57
    Safari: 17.5
  npmPackages:
    vite: ^5.2.13 => 5.2.13

Used Package Manager

pnpm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Jun 13, 2024

Yeah it's likely that the # is messing with the resolving. We perhaps miss an edgecase with this, but it's hard and less-performant to resolve with #.

@bluwy bluwy added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Jun 13, 2024
@brachkow
Copy link

brachkow commented Jun 15, 2024

Same issue there. I don't thinks that is very «edgecase» stuff. In small-to-medium projects it is much easier to use git, then private packages, which are coming with overhead from publish flow of public packages.

@juanjiejie

This comment was marked as spam.

@kran6a
Copy link

kran6a commented Jul 8, 2024

I don't think this is a minor bug unless there is a workaround for using packages hosted on private repos.

@dcaillibaud
Copy link

I also don't think it's a minor bug, it forbids to use vite with pnpm9 on all of our projects (public and open source, with dependencies on our own gitlab).

@XinChou16
Copy link

also breaks in pnpm 9, we have to use pnpm v8 because of this

@bluwy bluwy added p4-important Violate documented behavior or significantly improves performance (priority) and removed p3-minor-bug An edge case that only affects very specific usage (priority) labels Aug 14, 2024
@benmccann
Copy link
Collaborator

I believe this happens specifically when you want to install a specific branch, sub-directory, etc.

E.g. I ran pnpm add -D "github:sveltejs/svelte#path:packages/svelte&sibling-dce" followed by pnpm build on https://github.com/benmccann/interactive-blogs-benchmark/tree/upgrade/sveltekit_mdsvex because I wanted to test out an in-progress PR to the Svelte repo and got:

[vite]: Rollup failed to resolve import "esm-env" from "node_modules/.pnpm/svelte@https+++codeload.github.com+sveltejs+svelte+tar.gz+155775a7acf51673ebb1b74dd87e65185e55bba0#path+packages+svelte/node_modules/svelte/src/internal/server/index.js".

This makes it difficult for us to manually test PRs we receive in our projects.

@benmccann
Copy link
Collaborator

I filed an issue in the pnpm repo asking if they might be able to change this on their side: pnpm/pnpm#8437

@asppsa
Copy link

asppsa commented Sep 3, 2024

Setting resolve.preserveSymlinks to true seems to fix this for me - I think that makes sense, as the # is only in the "real" path.

@hi-ogawa hi-ogawa changed the title Fail to load packages installed from Git repo Fail to load packages installed from Git repo with pnpm v9 Sep 23, 2024
@hi-ogawa
Copy link
Collaborator

Pnpm plans to escape # character in v10 so it won't cause issues on Vite. I tested the local build of v10 branch and verified it fixed the reproduction here https://github.com/hi-ogawa/reproductions/tree/main/vite-17459-pnpm-gitea

@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants