netlify / build-image

This is the build image used for running automated builds
MIT License
496 stars 197 forks source link

fix: ensure that .netlify is a directory and not a file or broken symlink #890

Closed danez closed 1 year ago

danez commented 1 year ago

Summary

Fixes https://app.bugsnag.com/netlify/netlify-build/errors/63b6daab56c5cf00082ee11f?event_id=63b6daab00a2f84cc76b0000&i=sk&m=nw

Also in the build log of the affected build I can see:

3:10:59 PM: mkdir: cannot create directory ‘/opt/build/repo/.netlify’: File exists
3:10:59 PM: Started restoring cached build plugins
3:10:59 PM: mv: failed to access '/opt/build/repo/.netlify/plugins': Not a directory
3:10:59 PM: Finished restoring cached build plugins

It seems some repos have .netlify as a file. For example: https://github.com/MailTape/MailTape.github.io/blob/master/.netlify Is this an old format of the config file? What is that? To me this looks like the CLI global config file.

This change ensures that if .netlify is not a directory we remove it before we try to create it.

Alternatively, we could also error the build if the file is present?


For us to review and ship your PR efficiently, please perform the following steps:

A picture of a cute animal (not mandatory, but encouraged)