Curl not found?

Any idea why curl cannot be found? From info I’ve seen elsewhere on this forum it appears it should be in the image?

site: animated-baklava-d06246

Apr 5, 06:34:11 PM: INIT_START Runtime Version: nodejs:18.v26	Runtime Version ARN: arn:aws:lambda:us-east-2::runtime:0cdcfbdefbc5e7d3343f73c2e2dd3cba17d61dea0686b404502a0c9ce83931b9Apr 5, 06:34:12 PM: 108f07a1 ERROR  exec error: Error: Command failed: bash /var/task/checker.sh https://github.com/Matthews3301/the-garden-front-end
/var/task/checker.sh: line 30: curl: command not found
Error: Failed to fetch the URL.Apr 5, 06:34:12 PM: 108f07a1 ERROR  Invoke Error 	{"errorType":"Error","errorMessage":"[object Object]","stack":["Error: [object Object]","    at Object.intoError (file:///var/runtime/index.mjs:46:16)","    at Object.textErrorLogger [as logError] (file:///var/runtime/index.mjs:684:56)","    at postError (file:///var/runtime/index.mjs:801:27)","    at done (file:///var/runtime/index.mjs:833:11)","    at fail (file:///var/runtime/index.mjs:845:11)","    at file:///var/runtime/index.mjs:872:20","    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"]}Apr 5, 06:34:12 PM: 108f07a1 Duration: 32.57 ms	Memory Usage: 69 MB	Init Duration: 213.48 ms	

You’re running curl in Netlify Functions. It doesn’t exist there.

Oh, how do I install it in there? Or otherwise make connections out? wget? Or something similar?

-Matt

You don’t.

Use the built-in fetch()

I’m working in a shell script. Is there a way to get the build process to install curl? Or maybe wget?

No. Netlify Functions are meant to run Node.js scripts, not shell scripts.

I am calling the shell script from a node.js wrapper. Is it not possible to get curl or wget somehow?

No, it’s not possible.

Oh, that is a shame.

Are there plans to make the local build and test environments better match production so that people don’t get stuck on stuff like this in the future?

It’s easier said than done. Locally, these tools and scripts exist, so Node.js is able to execute those scripts. The only way to reliably cause this to break locally is by somehow hooking into the child process call, check the binary being invoked and then judge whether or not it’s possible. If that binary is a custom binary, we again can’t tell for sure.

The only way would be to use Docker, though I’m not sure if the vast majority of the user base would be familiar to setup and use that.

You can potentially get this to work if absolutely required by downloading the curl binary for Linux and bundling it with the function. However, curl might depend on additional dependencies so it could also fail.

Thanks, yeah I was thinking on including a portable compiled curl. Seems also a bunch of other usual tools, find, tar, etc are also missing. I’m perfectly comfortable using docker if there is a way to tell these functions to run on a more standard docker image?

You’d have to refer to: Deploy Node.js Lambda functions with container images - AWS Lambda (amazon.com), specifically:

those 2 steps. The required handler file can be generated by CLI using netlify build --offline and the Functions would be generated in .netlify folder.