Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy error 'Is a directory (os error 21)' occurs when special char in project path #2897

Open
rpock opened this issue Nov 17, 2024 · 1 comment

Comments

@rpock
Copy link

rpock commented Nov 17, 2024

Describe the bug
The Supabase CLI fails to deploy Edge Functions when the project path contains special characters (#). The error message suggests a directory issue, but the actual problem is the special characters in the path.

To Reproduce
Steps to reproduce the behavior:

  1. Create a project directory containing special characters (e.g., /Users/username/Documents/#project/#app/)
  2. Initialize a Supabase project in this directory
  3. Create an Edge Function: supabase functions new my-function
  4. Create a simple Edge Function in index.ts
  5. Try to deploy using: supabase functions deploy my-function --project-ref [your-project-ref]
  6. Observe the deployment error

Expected behavior
Either:

  • The deployment should work correctly with special characters in the path
  • Or the CLI should provide a clear error message indicating that special characters in the path are not supported

Screenshots
Error output:
image

Error output searchable:

supabase functions deploy [my-function] --no-verify-jwt --project-ref [my-project-ref]
Bundling Function: [my-function]
Error 'Is a directory (os error 21)' contains boxed error of unknown type:
  Os { code: 21, kind: IsADirectory, message: "Is a directory" }
Error: failed to create the graph

Caused by:
    Is a directory (os error 21)
error running container: exit 1
Try rerunning the command with --debug to troubleshoot the error.

System information

  • OS Version: macOS
  • CLI Version: 1.219.2
  • Docker Version: Latest

Additional context

  • Moving the project to a path without special characters resolves the issue
  • The error occurs in the Deno bundler when trying to access the function's index.ts file
  • This is a path handling issue that affects deployments on macOS when the project path contains '#' characters
@avallete
Copy link
Member

avallete commented Nov 18, 2024

I can confirm I've been able to reproduce, but with only two specials chars so far: # and ?, but other specials characters such as $ or % work well. Which lead me to think there is something on with shell path escaping.

The binding to the container that run the edge-runtime for bundling seems correct so the issue might actually come from the path normalization within the container bundling logic. I'm suspecting that maybe this is where things goes wrong: https://github.com/supabase/edge-runtime/blob/main/crates/sb_core/util/fs.rs#L208

Digging in, I've added debug logs to the edge-runtime and can confirm this is a bug with some "url" characters within deno path utils, I've setup a branch with some debug logs locally: supabase/edge-runtime@26c55e4#diff-d8f56ede5ccc2924ccf7a18b57eb0e3867fc7804abbb922021bac99e64355d1b

And the actual issue arise within the fetch_local function, this is the kind of debug output I got:

WARN: no seed files matched pattern: supabase/seed.sql
Bundling Function: my-function
DEBUG Opening cache /root/.cache/deno/dep_analysis_cache_v1...
DEBUG Opening cache /root/.cache/deno/node_analysis_cache_v1...
DEBUG Starting fetch_no_follow_with_options
DEBUG Input specifier: file:///Users/avallete/Programming/Supa/#cli/supabase/functions/my-function/index.ts
DEBUG Validating scheme
DEBUG Scheme is: file
DEBUG Checking permissions
DEBUG Permissions check passed
DEBUG Checking memory cache
DEBUG Not found in memory cache
DEBUG Handling file:// URL
DEBUG Starting fetch_local
DEBUG Input specifier: file:///Users/avallete/Programming/Supa/#cli/supabase/functions/my-function/index.ts
DEBUG Converting specifier to file path
DEBUG File path: "/Users/avallete/Programming/Supa/" <--- here we loose our proper path after to_file_path() is called
DEBUG Reading file bytes
DEBUG Failed to read file: Is a directory (os error 21)
Error 'Is a directory (os error 21)' contains boxed error of unknown type:
  Os { code: 21, kind: IsADirectory, message: "Is a directory" }
Error: failed to create the graph

Caused by:
    Is a directory (os error 21)
error running container: exit 1
Try rerunning the command with --debug to troubleshoot the error.
exit status 1

@avallete avallete transferred this issue from supabase/cli Nov 18, 2024
@laktek laktek transferred this issue from supabase/edge-runtime Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants