Skip to content

CLI: supabase start fails with "must be a directory" when supabase/functions/.env contains a multi-line value #7603

Closed

Description

@mischah

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

supabase start (and supabase functions serve) fail when supabase/functions/.env contains a multi-line value, such as a PEM private key in double quotes:

failed to copy edge runtime main service into container: destination "supabase_edge_runtime_<project_id>:/" must be a directory

With single-line values only, the same project starts fine.

This looks like the same failure mode as supabase/supabase#50088 (the docker cp of the Edge Runtime main service, introduced in 2.116.0), but with a different trigger: the bind mount for multi-line env values.

To Reproduce

  1. mkdir repro && cd repro && supabase init
  2. supabase functions new hello
  3. printf 'FOO="line1\nline2"\n' > supabase/functions/.env
  4. supabase start
  5. See the error above

With printf 'FOO=bar\n' > supabase/functions/.env (or no .env at all), step 4 succeeds. For me this was consistent over several runs each.

What I found while debugging (by putting a logging wrapper for docker in front of PATH):

  • The CLI creates the Edge Runtime container with a bind mount -v <project>/supabase/.temp/start-secrets/supabase_edge_runtime_<project_id>/multiline-env:/root/.supabase/multiline-env:ro,Z, then runs docker cp - supabase_edge_runtime_<project_id>:/.
  • For that container, HEAD /containers/{id}/archive?path=/ returns 500 with error while creating mount source path '<project>/supabase/.temp/start-secrets/supabase_edge_runtime_<project_id>/multiline-env': mkdir .... docker cp then reports the misleading "must be a directory".
  • When I checked right before the docker cp, multiline-env on the host was a directory (drwx------), not a file.
  • With the wrapper slowing down the docker calls, the start sometimes succeeds, so this may be a race between writing the multiline-env file and creating the container.

Expected behavior

supabase start and supabase functions serve work with multi-line values in supabase/functions/.env, as they did before 2.116.0.

Screenshots

n/a

System information

  • OS: macOS 26.7.2 (arm64)
  • Supabase CLI: 3.1.0 (also reproduced with 2.122.0)
  • Docker Desktop 4.97.0, Docker Engine 29.9.2 (containerd image store)
  • Edge Runtime image: v1.78.1

Additional context

Workaround: keep all values in supabase/functions/.env on one line, e.g. a PEM key unquoted with literal \n, and replace \n with real line breaks in the function code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugsupabase/cli🐛 Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions