cli icon indicating copy to clipboard operation
cli copied to clipboard

Failed to read env file: stat ./.env: no such file or directory

Open seanc opened this issue 1 year ago • 1 comments

Describe the bug The --env-file flag is failing to read any .env files.

To Reproduce Steps to reproduce the behavior:

  1. Open a terminal
  2. Run npx supabase functions serve --env-file ./.env --no-verify-jwt --debug
  3. See error Failed to read env file: stat ./supabase/.env.local: no such file or directory

Expected behavior It should read the .env file

Screenshots image

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

  • Ticket ID: a1f90d5168d84d55af08bd37ded81312
  • OS: MacOS
  • Version of CLI: 1.146.1
  • Versions of services:

  
        SERVICE IMAGE      │        LOCAL         │  LINKED
  ─────────────────────────┼──────────────────────┼───────────
    supabase/postgres      │ 15.1.0.103           │ 15.1.1.5
    supabase/gotrue        │ v2.92.1              │ v2.143.0
    postgrest/postgrest    │ v11.1.0              │ v12.0.2
    supabase/realtime      │ v2.25.50             │ -
    supabase/storage-api   │ v0.48.2              │ v0.48.2
    supabase/edge-runtime  │ v1.36.7              │ -
    supabase/studio        │ 20240205-b145c86     │ -
    supabase/postgres-meta │ v0.78.2              │ -
    supabase/logflare      │ 1.4.0                │ -
    bitnami/pgbouncer      │ 1.20.1-debian-11-r39 │ -
    darthsim/imgproxy      │ v3.8.0               │ -

Run supabase link to sync your local image versions with the linked project.

Additional context

  • Version of Node.js [v20.11.0]
  • PWD [/Users/sean/Projects/alqen/apps/rhino/rhino-backend/supabase/supabase/functions]
  • ls -al:
(base) ➜  functions git:(main) ✗ ls -al
total 88
drwxr-xr-x  11 sean  staff    352 Mar  1 02:49 .
drwxr-xr-x   9 sean  staff    288 Mar  1 02:49 ..
-rw-r--r--@  1 sean  staff   6148 Feb 11 19:39 .DS_Store
-rw-r--r--   1 sean  staff   1994 Mar  1 00:33 .env
-rw-r--r--   1 sean  staff    946 Feb 29 12:03 .example.env
-rw-r--r--@  1 sean  staff     39 Feb 11 18:34 deno.jsonc
-rw-r--r--   1 sean  staff  17235 Nov 23 21:58 deno.lock
drwxr-xr-x   3 sean  staff     96 Feb 25 23:42 gpt-api-proxy
-rw-r--r--   1 sean  staff    910 Feb 23 02:29 import_map.json
drwxr-xr-x   8 sean  staff    256 Feb 25 23:42 rhino-api
drwxr-xr-x   4 sean  staff    128 Feb 29 12:03 stripe-webhook-handler

seanc avatar Mar 01 '24 11:03 seanc

We have a slight inconsistency in path handling when passing in the env file. Currently the path accepted by --env-file flag is relative to supabase directory instead of workdir. So I believe using --env-file ../.env should work, ie.

npx supabase functions serve --env-file ../.env --no-verify-jwt

It might be difficult to fix this without breaking existing CI pipelines so the proper will will have to wait until v2.

sweatybridge avatar Mar 13 '24 08:03 sweatybridge