GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-nodejs

Build error when deploying from gcloud cli with local file dependencies

Open
#591 3 comments 1 reaction 0 assignees View on GitHub
gcf bug P2
Dominant language
TypeScript
Stars
1.4k
Forks
181
PR merge metrics
No merged PRs in 30d

Description

Deploying from local source with `gcloud functions deploy` seems unable to include local file dependencies.

When setting `--set-build-env-vars GOOGLE_VENDOR_NPM_DEPENDENCIES=true` and `package.json` is referencing something like `"app-common": "file:./localpath"` builds fail and throw the following build error:
```
"Step #2 - "build": panic: runtime error: invalid memory address or nil pointer dereference"
```

Was expecting this should work:
```
gcloud functions deploy my-function \
--entry-point=create \
--trigger-http \
--set-build-env-vars GOOGLE_VENDOR_NPM_DEPENDENCIES=true
```

But I was able to work around by building a docker image locally and manually pushing:

```
pack build \
--builder gcr.io/buildpacks/builder:v1 \
--env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \
--env GOOGLE_FUNCTION_TARGET=create \
--env GOOGLE_VENDOR_NPM_DEPENDENCIES=true \
my-function
```

If I try the `gcloud functions deploy` command minus the build env var, it pushes an image to the cloud function that is missing dependencies. It would be great if this could deploy from local source in one step and have it correctly include dependencies, instead of manually having to build a docker image and push.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with package.json containing a local file dependency and the shown gcloud functions deploy command, then compare it with the working pack build invocation. Trace the build path for GOOGLE_VENDOR_NPM_DEPENDENCIES=true and the local dependency, using entry point create. Done means deployment from local source succeeds with dependencies included and the nil-pointer build error is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, google-cloud, nodejs
Domain
backend, build-system, cli, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.