supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.03k stars 202 forks source link

Error parsing /app/package.json #2661

Closed tommedema closed 2 weeks ago

tommedema commented 2 weeks ago

Describe the bug When I run commands related to the database, I get this cryptic error about app/package.json being malformed. I don't have a file like that so I'm thinking it's a file inside docker?

To Reproduce Steps to reproduce the behavior:

  1. Run npx supabase db reset --debug
  2. See error: Error parsing /app/package.json (full log below)

Expected behavior Database resets without errors

Log

tommedema@Toms-MacBook-Air nobleze-v1 % SUPABASE_WORKDIR=src npx supabase db reset --debug
Using workdir src
Supabase CLI 1.191.3
Resetting local database...
2024/09/07 01:44:46 Sent Header: Host [api.moby.localhost]
...
Recreating database...
2024/09/07 01:44:47 Sent Header: Host [api.moby.localhost]
2024/09/07 01:44:47 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/09/07 01:44:47 Send Done
2024/09/07 01:44:47 Recv First Byte
...
2024/09/07 01:44:57 Connect Start: tcp 127.0.0.1:54322
2024/09/07 01:44:57 Connect Done: tcp 127.0.0.1:54322
2024/09/07 01:44:57 PG Send: {"Type":"StartupMessage","ProtocolVersion":196608,"Parameters":{"database":"postgres","user":"postgres"}}
2024/09/07 01:44:57 PG Recv: {"Type":"AuthenticationSASL","AuthMechanisms":["SCRAM-SHA-256"]}
2024/09/07 01:44:57 PG Send: {"Type":"SASLInitialResponse","AuthMechanism":"SCRAM-SHA-256","Data":"n,,n=,r=flklEhtxWdbvl2iKku+SWTOu"}
2024/09/07 01:44:57 PG Recv: {"Type":"AuthenticationSASLContinue","Data":"r=flklEhtxWdbvl2iKkuxxxBY/dDJSjYgY81jjV3Wg==,i=4096"}
2024/09/07 01:44:57 PG Send: {"Type":"SASLResponse","Data":"c=biws,r=flklEhtxWdbvl2iKku+SWTxxxxIcXxvgj2JD,p=pYnuTWOmlLnRK6ZIXeBkIgn1fnRzOBnpEOktek8+YzY="}
2024/09/07 01:44:57 PG Recv: {"Type":"AuthenticationSASLFinal","Data":"v=pnbdIXYxYMxxxxhVZ9OWKg="}
2024/09/07 01:44:57 PG Recv: {"Type":"AuthenticationOK"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"application_name","Value":""}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"client_encoding","Value":"UTF8"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"DateStyle","Value":"ISO, MDY"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"default_transaction_read_only","Value":"off"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"in_hot_standby","Value":"off"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"integer_datetimes","Value":"on"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"IntervalStyle","Value":"postgres"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"is_superuser","Value":"off"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"server_encoding","Value":"UTF8"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"server_version","Value":"15.6"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"session_authorization","Value":"postgres"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"standard_conforming_strings","Value":"on"}
2024/09/07 01:44:57 PG Recv: {"Type":"ParameterStatus","Name":"TimeZone","Value":"UTC"}
2024/09/07 01:44:57 PG Recv: {"Type":"BackendKeyData","ProcessID":198,"SecretKey":3020470721}
2024/09/07 01:44:57 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"}
Setting up initial schema...
2024/09/07 01:44:57 Sent Header: Host [api.moby.localhost]
2024/09/07 01:44:57 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/09/07 01:44:57 Send Done
..
2024/09/07 01:44:57 Sent Header: Host [api.moby.localhost]
2024/09/07 01:44:57 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/09/07 01:44:57 Send Done
2024/09/07 01:44:57 Recv First Byte
+ ulimit -n
+ '[' '!' -z 10000 ']'
+ echo 'Setting RLIMIT_NOFILE to 10000'
+ ulimit -Sn 10000
+ export ERL_CRASH_DUMP=/tmp/erl_crash.dump
+ ERL_CRASH_DUMP=/tmp/erl_crash.dump
+ '[' false = true ']'
+ echo 'Running migrations'
+ sudo -E -u nobody /app/bin/migrate
+ '[' true = true ']'
+ echo 'Seeding selfhosted Realtime'
+ sudo -E -u nobody /app/bin/realtime eval 'Realtime.Release.seeds(Realtime.Repo)'
+ echo 'Starting Realtime'
+ ulimit -n
+ exec /app/bin/realtime eval '{:ok, _} = Application.ensure_all_started(:realtime)
{:ok, _} = Realtime.Tenants.health_check("realtime-dev")'
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
[os_mon] memory supervisor port (memsup): Erlang has closed
2024/09/07 01:45:02 Sent Header: Host [api.moby.localhost]
2024/09/07 01:45:02 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/09/07 01:45:02 Send Done
2024/09/07 01:45:02 Recv First Byte
...
2024/09/07 01:45:02 Sent Header: Host [api.moby.localhost]
2024/09/07 01:45:02 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/09/07 01:45:02 Sent Header: Content-Length [0]
2024/09/07 01:45:02 Send Done
2024/09/07 01:45:02 Recv First Byte
2024/09/07 01:45:02 Sent Header: Host [api.moby.localhost]
2024/09/07 01:45:02 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/09/07 01:45:02 Send Done
2024/09/07 01:45:02 Recv First Byte
node:internal/modules/package_json_reader:93
        throw error;
        ^

SyntaxError: Error parsing /app/package.json: Unexpected end of JSON input
    at parse (<anonymous>)
    at read (node:internal/modules/package_json_reader:80:16)
    at readPackage (node:internal/modules/package_json_reader:141:10)
    at readPackageScope (node:internal/modules/package_json_reader:164:19)
    at shouldUseESMLoader (node:internal/modules/run_main:81:15)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:161:24)
    at node:internal/main/run_main_module:28:49 {
  path: '/app/package.json'
}

Node.js v20.17.0
2024/09/07 01:45:02 Sent Header: Host [api.moby.localhost]
2024/09/07 01:45:02 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/09/07 01:45:02 Send Done
2024/09/07 01:45:03 Recv First Byte
2024/09/07 01:45:03 PG Send: {"Type":"Terminate"}
error running container: exit 1

System information

tommedema commented 2 weeks ago

the issue seems to disappear when I remove .branches and .temp but then later re-appears, this time when I ran npx supabase db pull

tommedema commented 2 weeks ago

tried using the beta version, but same issue persists :(

tommedema commented 2 weeks ago

knocking on wood, the problem seems to have disappeared after running docker system prune --all