I was trying to build a Serverless application with Knative while using Rust. The program run well locally after calling cargo build. However before deploying the project, I keep ending with the error below.
Installing function v0.1.0 (/workspace)
error: failed to get `actix-http` as a dependency of package `function v0.1.0 (/workspace)`
Caused by:
failed to load source for dependency `actix-http`
Caused by:
Unable to update registry `crates-io`
Caused by:
usage of sparse registries requires `-Z sparse-registry`
unable to invoke layer creator
unable to contribute application layer
unable to install single
unable to build
exit status 101
ERROR: failed to build: exit status 1
Error: failed to build the function: executing lifecycle: failed with status code: 51
Error: exit status 1
I've been looking for solutions to solve this without any luck. Can someone help me figure out how to resolve this issue.
It looks like you are trying to use the sparse registry feature of cargo, which is still unstable. Unstable features can only be used with nightly rust. Try disabling sparse registry.
AFAICT from sifting through the func repo, I'm quite sure functions uses this rust buildpack from the paketo community for creating the container for your function (based on this manifest file from the Rust function templates). That buildpack depends on the cargo buildpack, which enables sparse registries by default. AFAICT they don't offer an environment variable for changing that. Maybe raise an issue with the cargo buildpack? I'm not that good at reading Go and I have no experience with knative functions nor buildpack, so better fact-check my research .