fix: use relative path for functions folder #7729
Merged
+10
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When running netlify init to set up a new project (one that hasn't been configured in your Netlify account yet), the CLI was sending an absolute path for the functions directory to Netlify's API instead of a relative path.
If you initialized a project on your local machine at:
/Users/foo/Projects/Work/project-1/The functions directory would be sent to Netlify as:
/Users/foo/Projects/Work/project-1/netlify/functionsInstead of the correct relative path:
netlify/functionsRoot Cause
The issue was in src/utils/init/utils.ts where the config.build.functions value (which comes from @netlify/config package and is resolved to an absolute path) was being used directly without converting it to a relative path before sending it to the Netlify API. The fix ensures that any absolute paths are converted to paths relative to the repository root before being sent to the API, so they work correctly in any build environment.
For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)