pkgxdev / pkgx

run anything
https://pkgx.sh
Apache License 2.0
8.95k stars 1.36k forks source link

Crash on yarn patch #892

Closed GauBen closed 8 months ago

GauBen commented 9 months ago

It seems that yarn patch does not work because of something related to pkgx:

Reproduction

  1. Clone any js repo with yarn as default package manager (e.g. https://github.com/GauBen/gautier.dev)
  2. Run dev, which should show something like env +nodejs.org@20.9.0 +yarnpkg.com +git-scm.org
  3. Run yarn patch <any dep> with any dep being any js dependency of the project (e.g. yarn patch svelte)
  4. Run yarn patch-commit -s /tmp/anything given by the previous command

This last step should fail with this error:

Internal Error: Unable to diff directories. Make sure you have a recent version of 'git' available in PATH.
The following error was reported by 'git':
error: Uncaught Error: invalid absolute path: 
      throw new Error(`invalid absolute path: ${input}`);
            ^
    at new Path (https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts:41:13)
    at Function.home (https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts:24:12)
    at ConfigDefault (https://deno.land/x/libpkgx@v0.15.0/src/hooks/useConfig.ts:13:77)
    at useConfig (https://deno.land/x/libpkgx@v0.15.0/src/hooks/useConfig.ts:57:34)
    at usePantry (https://deno.land/x/libpkgx@v0.15.0/src/hooks/usePantry.ts:35:18)
    at file:///tmp/pkgx-20231204-4895-1n0h1c3/pkgx-1.1.1/src/prefab/install.ts:29:12
error: Uncaught Error: invalid absolute path: 
      throw new Error(`invalid absolute path: ${input}`);
            ^
    at new Path (https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts:41:13)
    at Function.home (https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts:24:12)
    at ConfigDefault (https://deno.land/x/libpkgx@v0.15.0/src/hooks/useConfig.ts:13:77)
    at useConfig (https://deno.land/x/libpkgx@v0.15.0/src/hooks/useConfig.ts:57:34)
    at usePantry (https://deno.land/x/libpkgx@v0.15.0/src/hooks/usePantry.ts:35:18)
    at file:///tmp/pkgx-20231204-4895-1n0h1c3/pkgx-1.1.1/src/prefab/install.ts:29:12

The following error was reported by 'git':
error: Uncaught Error: invalid absolute path: 
      throw new Error(`invalid absolute path: ${input}`);
            ^
    at new Path (https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts:41:13)
    at Function.home (https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts:24:12)
    at ConfigDefault (https://deno.land/x/libpkgx@v0.15.0/src/hooks/useConfig.ts:13:77)
    at useConfig (https://deno.land/x/libpkgx@v0.15.0/src/hooks/useConfig.ts:57:34)
    at usePantry (https://deno.land/x/libpkgx@v0.15.0/src/hooks/usePantry.ts:35:18)
    at file:///tmp/pkgx-20231204-4895-1n0h1c3/pkgx-1.1.1/src/prefab/install.ts:29:12
error: Uncaught Error: invalid absolute path: 
      throw new Error(`invalid absolute path: ${input}`);
            ^
    at new Path (https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts:41:13)
    at Function.home (https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts:24:12)
    at ConfigDefault (https://deno.land/x/libpkgx@v0.15.0/src/hooks/useConfig.ts:13:77)
    at useConfig (https://deno.land/x/libpkgx@v0.15.0/src/hooks/useConfig.ts:57:34)
    at usePantry (https://deno.land/x/libpkgx@v0.15.0/src/hooks/usePantry.ts:35:18)
    at file:///tmp/pkgx-20231204-4895-1n0h1c3/pkgx-1.1.1/src/prefab/install.ts:29:12

    at TG (/home/gautier/gauben/gautier.dev/.yarn/releases/yarn-4.0.2.cjs:707:1425)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async z0.execute (/home/gautier/gauben/gautier.dev/.yarn/releases/yarn-4.0.2.cjs:709:4273)
    at async z0.validateAndExecute (/home/gautier/gauben/gautier.dev/.yarn/releases/yarn-4.0.2.cjs:94:787)
    at async as.run (/home/gautier/gauben/gautier.dev/.yarn/releases/yarn-4.0.2.cjs:98:3250)
    at async oPt (/home/gautier/gauben/gautier.dev/.yarn/releases/yarn-4.0.2.cjs:734:11269)
    at async sk (/home/gautier/gauben/gautier.dev/.yarn/releases/yarn-4.0.2.cjs:734:11625)

I investigated a bit to see what could cause that, but no luck so far

For some reason, Deno.env.get("HOME") is an empty string (but not undefined) and causes this line to throw

https://deno.land/x/libpkgx@v0.15.0/src/utils/Path.ts?source=#L69

$ env | grep HOME                            
HOME=/home/gautier
HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
HOMEBREW_CELLAR=/home/linuxbrew/.linuxbrew/Cellar
HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew
jhheider commented 9 months ago

looks like yarn requires git. if you do pkgx +git +yarn yarn patch ...whatever does it work?

GauBen commented 9 months ago

The error is the same:

$ pkgx +git yarn patch-commit -s /tmp/xfs-feb2eeb4/user
Internal Error: Unable to diff directories. Make sure you have a recent version of 'git' available in PATH.
The following error was reported by 'git':
error: Uncaught Error: invalid absolute path: 
      throw new Error(`invalid absolute path: ${input}`);
jhheider commented 9 months ago

that's strange, since pkgx +git will have a path with git on it. if you do pkgx install git, does the yarn command work?

GauBen commented 9 months ago

It does not work either. Can you reproduce the bug? It may be shell specific (zsh) or something else. In any case, thank you for your help

GauBen commented 8 months ago

This appears to be solved on current versions, closing

jhheider commented 8 months ago

accidentally fixing stuff is the best, maybe.