dylanirlbeck / tailwind-ppx

A Reason/OCaml Pre-Processor eXtension (PPX) that validates your Tailwind classes at compile-time.
MIT License
152 stars 15 forks source link

Postinstall _export not handling existing directory #130

Closed JakubMarkiewicz closed 4 years ago

JakubMarkiewicz commented 4 years ago

Hey, Sometimes when i deploy app to vercel it happens to crash due to postinstall script not checking, if _export directory is already present.


17:00:25.082 | error /vercel/583d5351/node_modules/@dylanirlbeck/tailwind-ppx: Command failed.
-- | --
17:00:25.082 | Exit code: 1
17:00:25.083 | Command: node ./postinstall.js
17:00:25.083 | Arguments:
17:00:25.083 | Directory: /vercel/583d5351/node_modules/@dylanirlbeck/tailwind-ppx
17:00:25.083 | Output:
17:00:25.083 | Could not create _export folder
17:00:25.083 | error: Error: EEXIST: file already exists, mkdir '/vercel/583d5351/node_modules/@dylanirlbeck/tailwind-ppx/3'
try {
  fs.mkdirSync('_export');
} catch (e) {
  console.log('Could not create _export folder');
}

Maybe we could handle this case by checking if said directory exists and if so, just replacing the binary inside. I could make a PR

vdanchenkov commented 4 years ago

Builds started to fail 3 days ago with exactly the same error.

Local reproduction:

cd ./node_modules/@dylanirlbeck/tailwind-ppx/
node ./postinstall.js

Probably they added/changed the way to cache resources. Currently node_modules from previous builds is restored before yarn install run.

dylanirlbeck commented 4 years ago

Yeah we did change the build process recently. @JakubMarkiewicz I think the fix you mentioned should work, so a PR would be much appreciated!

cc @tatchi since I believe you made these changes.

JakubMarkiewicz commented 4 years ago

I've got the working fix but there is one more thing. I've never encountered it during deployment, can't really tell if this is an issue but it definitely is when building locally. It's the same thing but during esyInstallRelease

error: Error: EEXIST: file already exists, mkdir '/app/node_modules/@dylanirlbeck/tailwind-ppx/3'

Removing the file fixes the directory, but I guess there is no way for us to change the behavior of esyInstallRelease?

EDIT: It actually was in vercel logs, my fault, didn't notice it

I could just delete a directory that has a name made out of single digit but it's a dirty solution. Probably the best course of action is to hit folks at esy

JakubMarkiewicz commented 4 years ago

Esy maintainer confirmed that they are able to make a fix for second problem. I believe this issue can be closed now

dylanirlbeck commented 4 years ago

@JakubMarkiewicz Can you try the latest version I released (v0.8.3)? It should include the changes from your latest PR. If that doesn't fix this issue I'll re-open.

JakubMarkiewicz commented 4 years ago

I'll key an eye on builds, so far after 2 builds no issue despite having like 4 failed builds earlier today.

vdanchenkov commented 3 years ago

Still seeing following build error quite often:

error: Error: EEXIST: file already exists, mkdir '/vercel/workpath0/node_modules/@dylanirlbeck/tailwind-ppx/3'