Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vite3 postcss statSync not found #9032

Merged

Conversation

jardenliu
Copy link
Contributor

image

I use tailwind+vite3+tauri to build my application, and I will get the above error. It seems to be `cwd()` has changed when fs.Statsync is called. Using an absolute address can better ensure the correct path of the files

@thecrypticace thecrypticace self-assigned this Aug 5, 2022
@thecrypticace
Copy link
Contributor

I haven't had a chance to play with Tauri yet so I used this as an excuse to fiddle around a bit. It seems super neat! That said, I can't reproduce this. Do you maybe have a repo I can look at? Tailwind and Vite both detect changes and don't throw errors:

Screen Shot 2022-08-05 at 09 58 27

@thecrypticace
Copy link
Contributor

Okay I've got a reproduction from the linked issue in the Tauri/solid/ts/tailwind starter repo. Gonna see if I can boil it down to a simpler repro so we can add a test for it and get this merged.

@thecrypticace
Copy link
Contributor

Okay, so I tracked this down and it appears that Tauri is actively changing the current working directory of the node process outside of node. This is a problem because the OS and Node disagree on what the current working directory for the process actually is:

Screen Shot 2022-08-08 at 10 32 22

I produced the above by tweaking the Tailwind CSS source:

Screen Shot 2022-08-08 at 10 32 58

We can sorta fix this by making sure resolvedChangeFiles always uses absolute paths but this has other implications. It can potentially break other things, even in Node JS, that assume that the current working directory of the node process is accurately returned by process.cwd() when it is not.

@thecrypticace
Copy link
Contributor

One of the problems with this is that this fix may not even work in the future if the internals of fast-glob change and step outside of node at all to resolve paths. But at least for now it seems generally fine.

@thecrypticace thecrypticace merged commit fbbe3c0 into tailwindlabs:master Aug 8, 2022
@jardenliu
Copy link
Contributor Author

First of all, thank you for merge my PR. Originally, I planned to create a new repo to show this situation. But because I'm busy recently, I don't have time to do it.

Fortunately, you have found the cause of the problem. That's pretty great.

@Lastofthefirst
Copy link

@thecrypticace I've run into this issue, how can I make use of the merged fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants