Location of tmp folder for netlify functions

I have a small project with a scheduled Netlify function updating a dynamic twitter banner.

The function is fetching my most recent 4 followers from the twitter API and adding their profile picture to my banner.

I am doing a bit of manipulation on the profile pictures, and overlaying them to the banner using the sharp library.
So I need to write a few files to the tmp folder (as I understand it, I can write to this on AWS - where the rest of the filesystem is read-only).

I am struggling a bit to debug this locally, as the Netlify CLI doesn’t have a read-only filesystem in the same way as on AWS Lambda.

My function is working just fine locally on my Windows machine (testing with the netlify functions:invoke command) - but is failing when deployed on Netlify with the error: unix error: Read-only file system

I am simply unsure of the exact placement of the tmp folder on AWS?

Should it be placed directly inside the functions folder, inside the subfolder of the function: eg.: functions/updateTwitterbanner/tmp or something completely different?

My code can be seen on:

I have tried some different paths to the tmp folder, but am struggling, as I haven’t found a way to debug this locally.

I changed the code a bit and finally figured out how to do it :partying_face:

Had to use an absolute path to the root directory. It took a few failed deploys - a bit cumbersome to debug when I couldn’t manage to do it locally.

If anybody else has a hard time figuring this out you, you can inspect my code on GitHub: LarsEjaas/TwitterBanner

1 Like

Hello @LarsEjaas - Welcome to our community! Thank you for coming back and sharing how you solved this one! Our community thanks you! :netliheart:

1 Like

Glad if I might be able to help someone with a similar issue :grinning: