cli icon indicating copy to clipboard operation
cli copied to clipboard

Support installing via pnpm

Open vhpx opened this issue 3 years ago • 20 comments

Bug report

Describe the bug

Supabase CLI v1.38.7's postinstall script failed to run.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Install [email protected] via pnpm i
  2. See error at postinstall step

Expected behavior

It should install the package normally, upgrading from previous version or a clean installation does not fix this problem.

Screenshots

image

System information

  • OS: Windows 11 22H2 (Build 22621.1265)
  • supabase-js: v1.38.7
  • node.js: v19.6.0
  • pnpm cli: v7.27.1

vhpx avatar Feb 23 '23 08:02 vhpx

Same here. Running on macOS M1 pro.

npm ERR! code 1
npm ERR! path /Users/smd/Workspace/twodia-app/node_modules/supabase
npm ERR! command failed
npm ERR! command sh -c node scripts/postinstall.js
npm ERR! Downloading https://github.com/supabase/cli/releases/download/v1.38.7/supabase_darwin_arm64.tar.gz
npm ERR! node:events:490
npm ERR!       throw er; // Unhandled 'error' event
npm ERR!       ^
npm ERR! 
npm ERR! Error: incorrect header check
npm ERR!     at Zlib.zlibOnError [as onerror] (node:zlib:189:17)
npm ERR! Emitted 'error' event on Gunzip instance at:
npm ERR!     at Gunzip.onerror (node:internal/streams/readable:785:14)
npm ERR!     at Gunzip.emit (node:events:512:28)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
npm ERR!   errno: -3,
npm ERR!   code: 'Z_DATA_ERROR'
npm ERR! }
npm ERR! 
npm ERR! Node.js v19.6.0

sumardi avatar Feb 23 '23 08:02 sumardi

Thanks for pointing it out. This should be fixed now https://github.com/supabase/cli/actions/runs/4250737115/jobs/7392208839

sweatybridge avatar Feb 23 '23 08:02 sweatybridge

@sweatybridge getting a related error with a fresh install, Windows 11 in WSL2, Node 18 and 16, pnpm 7.28.0, supabase installed as dev-dep

WARN  Failed to create bin at /home/arpad/work/mvp/node_modules/.bin/supabase. The source file at /home/arpad/work/mvp/node_modules/supabase/bin/supabase does not exist.

And looking in node modules, it seems like the postinstall script was not executed as the bin folder is empty.

arpadgabor avatar Mar 01 '23 11:03 arpadgabor

I will try to reproduce with pnpm. In the mean time, are you able to use yarn or npm?

sweatybridge avatar Mar 01 '23 11:03 sweatybridge

I've managed to get it working with homebrew so it's not urgent. By the way, is the cli not usable if installed globally? Because I was getting weird issues even when installed globally or used directly with npx without installing in the repository

arpadgabor avatar Mar 01 '23 11:03 arpadgabor

The recommended way to install globally is via one of the supported system package managers.

or used directly with npx without installing in the repository Do you have the logs when running directly with npx?

sweatybridge avatar Mar 01 '23 11:03 sweatybridge

This was all I could get:

❯ npx supabase
Need to install the following packages:
  [email protected]
Ok to proceed? (y) 
sh: 1: supabase: not found

But it now works with homebrew 👍

The recommended way to install globally is via one of the supported system package managers.

Maybe it's useful to add a warning in the readme about this? I don't mind using another package manager, but as a CLI I kind of expect it to work even if installed globally.

arpadgabor avatar Mar 01 '23 11:03 arpadgabor

I managed to reproduce the warning on pnpm: https://github.com/supabase/cli/actions/runs/4312324665/jobs/7522749949

It's harmless to ignore it as the postinstall succeeded anyway. Subsequent npx supabase --version successfully finds the binary in path.

sweatybridge avatar Mar 02 '23 09:03 sweatybridge

I've been trying to install supabase through npm for a while: [email protected] Ok to proceed? (y) y npm http fetch GET 200 https://registry.npmjs.org/supabase 10ms (cache hit) .... npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 431ms npm info run [email protected] postinstall node_modules/supabase node scripts/postinstall.js npm info run [email protected] postinstall { code: 1, signal: null }
npm verb exit 1 npm verb unfinished npm timer reify 1710324795538 npm verb unfinished npm timer reify:build 1710324796370 npm verb unfinished npm timer build 1710324796371 npm verb unfinished npm timer build:deps 1710324796371 npm verb unfinished npm timer build:run:postinstall 1710324796381
npm verb unfinished npm timer build:run:postinstall:node_modules/supabase 1710324796382 npm verb code 1

and then it just ends. Idk why it isn't working

iwo9 avatar Mar 13 '24 10:03 iwo9

Important to note here: do not run pnpm install with with --ignore-scripts flag.

reubendrummond avatar May 23 '24 01:05 reubendrummond

npx supabase init

sh: supabase: command not found

khakimio avatar Jul 31 '24 10:07 khakimio

Similar to @khakimio, I'm still observing that npx supabase init command fails. Noting it rather than only thumb up-ing because it's been 8 months so worth noting this is still an issue. The docs for Generating Types ask that this command be run, so it's unexpected and prevents completing the type generation successfully.

michaelaflores avatar Apr 14 '25 15:04 michaelaflores

$ pnpm supabase init
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "supabase" not found

$ npx supabase
sh: 1: supabase: not found

Still a problem?

semiautomatix avatar Apr 25 '25 05:04 semiautomatix

 WARN  Failed to create bin at /node_modules/.pnpm/[email protected]/node_modules/supabase/node_modules/.bin/supabase. ENOENT: no such file or directory, open '/node_modules/.pnpm/[email protected]/node_modules/supabase/bin/supabase'
 WARN  Failed to create bin at /node_modules/.pnpm/[email protected]/node_modules/supabase/node_modules/.bin/supabase. ENOENT: no such file or directory, open '/node_modules/.pnpm/[email protected]/node_modules/supabase/bin/supabase'
 WARN  Failed to create bin at /node_modules/.bin/supabase. ENOENT: no such file or directory, open '/node_modules/.pnpm/[email protected]/node_modules/supabase/bin/supabase'
 WARN  Failed to create bin at /node_modules/.bin/supabase. ENOENT: no such file or directory, open '/node_modules/supabase/bin/supabase'

semiautomatix avatar Apr 25 '25 05:04 semiautomatix

This issue is still outstanding using pnpm v10.10.0 in a turborepo project.

 WARN  Failed to create bin at /var/home/.../Repos/.../apps/web/node_modules/.bin/supabase. ENOENT: no such file or directory, open '/var/home/.../Repos/.../node_modules/.pnpm/[email protected]/node_modules/supabase/bin/supabase'

KilianSL avatar Apr 30 '25 10:04 KilianSL

Try pnpm approve-builds

  • pnpm v10.8.1
  • supabase v2.22.12
$ pnpm approve-builds
✔ Choose which packages to build (Press <space> to select, <a> to toggle all, <i> to invert selection) · supabase
✔ The next packages will now be built: supabase.
Do you approve? (y/N) · true
node_modules/.pnpm/[email protected]/node_modules/supabase: Running postinstall script, done in 1.9s
$ pnpm supabase --version
2.22.12

It works! :tada:

inouetakuya avatar May 08 '25 10:05 inouetakuya

Have same issue

https://github.com/supabase/cli/issues/885#issuecomment-2829399450

obiscr avatar May 09 '25 04:05 obiscr

Try pnpm approve-builds

  • pnpm v10.8.1
  • supabase v2.22.12
$ pnpm approve-builds
✔ Choose which packages to build (Press <space> to select, <a> to toggle all, <i> to invert selection) · supabase
✔ The next packages will now be built: supabase.
Do you approve? (y/N) · true
node_modules/.pnpm/[email protected]/node_modules/supabase: Running postinstall script, done in 1.9s
$ pnpm supabase --version
2.22.12

It works! 🎉

Does not work for me with

$ pnpm --version
10.22.0

and

    "supabase": "^2.58.5",

gblikas avatar Nov 22 '25 21:11 gblikas

This worked for me!

rm -rf node_modules/.pnpm/supabase* && pnpm remove supabase && pnpm add -D supabase

sacsand avatar Dec 12 '25 19:12 sacsand

Confirming a combination of the last two resolved the issue for me.

Cleanup

rm -rf node_modules/.pnpm/supabase* # remove folder
pnpm remove supabase # remove from pnpm

Install

pnpm add -D supabase # install package as dev dependecy
pnpm approve-builds # allow the post install script to run

Validate

pnpm exec supabase --version # confirm installation

kalenmike avatar Mar 21 '26 12:03 kalenmike