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.02k stars 201 forks source link

`supabase start` fails on linked project #2494

Closed Aietes closed 2 months ago

Aietes commented 2 months ago

Describe the bug When trying to run supabase start or supabase db start on a linked project the command fails with:

2024/07/04 16:04:35 Send Done
2024/07/04 16:04:35 Recv First Byte
node:internal/modules/cjs/loader:1148
  throw err;
  ^

Error: Cannot find module '/app/dist/scripts/migrate-call.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.15.0
2024/07/04 16:04:35 Sent Header: Host [api.moby.localhost]
2024/07/04 16:04:35 Sent Header: User-Agent [Docker-Client/unknown-version (darwin)]
2024/07/04 16:04:35 Send Done
2024/07/04 16:04:35 Recv First Byte

To Reproduce Steps to reproduce the behavior:

  1. Run supabase start -> starts successfully
  2. Run supabase stop
  3. Run supabase link with brand new project
  4. Run supabase start, or supabase db start, and it will fail.

When linking the project I get the warning, although the config has been created with supabase init and not been altered or changed in any way.

Warning: Local config differs from linked project. Try updating supabase/config.toml
[api]
enabled = true
port = 54321
schemas = ["public", "graphql_public"]
extra_search_path = ["public", "extensions"]
max_rows = 1000

Expected behavior For supabase start to work when a project is linked.

Screenshots If applicable, add screenshots to help explain your problem.

System information Rerun the failing command with --create-ticket flag.

      SERVICE IMAGE      │      LOCAL       │  LINKED
    supabase/postgres      │ 15.1.1.73        │ 15.1.1.73
    supabase/gotrue        │ v2.154.2         │ v2.154.2
    postgrest/postgrest    │ v12.2.1          │ v12.2.1
    supabase/realtime      │ v2.28.32         │ -
    supabase/storage-api   │ v1.6.7           │ v1.6.7
    supabase/edge-runtime  │ v1.54.6          │ -
    supabase/studio        │ 20240422-5cf8f30 │ -
    supabase/postgres-meta │ v0.80.0          │ -
    supabase/logflare      │ 1.4.0            │ -
    supabase/supavisor     │ 1.1.56           │ -
    darthsim/imgproxy      │ v3.8.0           │ -

Additional context If applicable, add any other context about the problem here.

RobinGiel commented 2 months ago

supabase/cli/internal/db/start/start.go

image

sweatybridge commented 2 months ago

@fenos did we change the location of migrate script in recent storage version?

YA9 commented 2 months ago

I'm having the same issue

sweatybridge commented 2 months ago

The current workaround is to rm supabase/.temp/storage-version before supabase start. We will look into it more closely next week.

YA9 commented 2 months ago

Thank you so much! I was going crazy over this

Aietes commented 2 months ago

Thank you for looking into it. However, the workaround does not work for me. When I delete storage-version and run supabase start, I now get a different error:

Error response from daemon: failed to resolve reference "public.ecr.aws/supabase/postgrest:v12.2.1": public.ecr.aws/supabase/postgrest:v12.2.1: not found
techwizzdom commented 2 months ago

I have the same issue when running supabase db diff. I've tried with v1.150.0 and v1.178.2. supabase start worked well though.

But thanks for this rm supabase/.temp/storage-version - fixed it for now 🎊

sweatybridge commented 2 months ago

Thank you for looking into it. However, the workaround does not work for me. When I delete storage-version and run supabase start, I now get a different error:

Error response from daemon: failed to resolve reference "public.ecr.aws/supabase/postgrest:v12.2.1": public.ecr.aws/supabase/postgrest:v12.2.1: not found

This is due to a new postgrest release that we haven't mirrored to ECR. I've just completed the mirroring job so it should be resolved now. Could you try again?

Aietes commented 2 months ago

@sweatybridge Thank you, the workaround is now working.

RishabhPachori commented 2 months ago

@sweatybridge

I am running supabase db diff command to create migrations Node js version : 18.17.0 Supabase cli version: Tried with 1.183.5 and also with beta version 1.186.2 docker version: 27.0.3

after running npx supabase start command I run npx supabase db diff

error diffing schema: error running container: exit 1: Traceback (most recent call last): File "/usr/local/bin/migra", line 8, in sys.exit(do_command()) File "/usr/local/lib/python3.9/site-packages/migra/command.py", line 121, in do_command status = run(args) File "/usr/local/lib/python3.9/site-packages/migra/command.py", line 98, in run m.add_all_changes(privileges=args.with_privileges) File "/usr/local/lib/python3.9/site-packages/migra/migra.py", line 107, in add_all_changes self.add(self.changes.tables_only_selectables()) File "/usr/local/lib/python3.9/site-packages/migra/changes.py", line 496, in get_selectable_changes statements += get_table_changes( File "/usr/local/lib/python3.9/site-packages/migra/changes.py", line 233, in get_table_changes rls_alter = v.alter_rls_statement File "/usr/local/lib/python3.9/site-packages/schemainspect/pg/obj.py", line 228, in alter_rls_statement return self.alter_table_statement(self.alter_rls_clause) File "/usr/local/lib/python3.9/site-packages/schemainspect/pg/obj.py", line 145, in alter_table_statement raise NotImplementedError

could you please help me to fix this issue ??

sweatybridge commented 2 months ago

@RishabhPachori could you please open a new issue as it's unrelated?

line 145, in alter_table_statement raise NotImplementedError

That problem is due to a limitation of migra tool which doesn't support generating alter rls statement.