-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
tailwindcss in watch mode doesn't refresh outupt when files are changed using vim #7759
Comments
Hey! Have you tried to set |
Yes, indeed - Yet, there is still this the possibility that source files get changed in some way that |
I have had a similar problem while developing a Ghost theme with Tailwind, and solved it by tweaking the watchers in my gulpfile. In my gulpfile, the line that configured the watcher for my Handlebars (HBS) templates looked like this:
This would execute the HBS task when I saved a change to my front end code. However, it did not execute the CSS task, which meant that my CSS file in which I was importing Tailwind was not re-processed properly. See below:
I solved it by adding the CSS task into the callback of the HBS watcher:
|
@javornikolov Am having trouble reproducing this in vim on a fresh install of Ubuntu 22. Could you provide some more detail about OS version and what not? I can't imagine hardware details would be relevant but are you perhaps editing files on an externally mounted drive — not sure if relevant but just looking for as much detail as I can get. I get rebuilds every time from your cloned project — at least in a virtual machine. I don't even have to set nobackupcopy to work around it. I had the file system events and logs streaming while editing and nothing was out of the ordinary as far as I could tell. Vim was doing it's whole move, create, write, delete dance and the changes were picked up as expected. |
@thecrypticace, it was ubuntu 21.10 by the time I reported the issue. |
I don't pretend to know details about how npx and tailwind work together, but I ran into this when launching tailwindcss via npx but not when it was installed to the system path. I'm on macos/m1, and |
@thecrypticace , Issue is reproduced with stock vim options - i.e. I removed my custom By tweaking the vim backup settings as I described above - the output file seems to be updated OK. In case that matters, I open and edit the files in separate tabs in vim. |
Shouldn't that be |
I don't think so. My understanding is that in this case the backup copy yes/no refers to copying the original file as opposed to moving it; the backup happens nonetheless. |
My experience was that From the vim docs:
|
I am having the same or similar issue. Rails 7 initially generated without css. Decided to switch to tailwind via tailwindcss-rails gem. I run a docker container that mounts my local version of the app as a volume, so changes are reflected in both, but the watcher seems to have issues after its been running for some time. Initially it will detect remote or local changes to either the config or the css file, but after some time it just stops noticing changes to the config. It works locally, so I'm not sure whether this is some weird docker issue. I do use alpine and I did add gcompat but I never had the no such file issue. I do have It's hard to replicate. I can never tell how long it has to be running before it happens. Sometimes its right after the initial build, and it won't notice anything at all. Other times it works for hours before suddenly stopping, which is infuriating because it initially took me some time to realize the problem. It doesn't seem to matter if it's being saved by an editor or |
I'm too am currently struggling with 3.1.8 CLI on Windows just quietly stopping recognising updates - it does seem to make some difference using the -p polling option, but it still breaks every so often. My suspicion (guess) is that it's occasionally failing to read modified files, because something else briefly locks them (there is lots of file-watching hot-reload stuff going on outside Tailwind which means several processes race to read modified files), and then once it's had that kind of error the file-watcher is permanently broken. This has not been a problem on the much, much larger project I started using TW on, which adds to my suspicion that it's timing-related. On the tiny project I'm working on right now it's verging on the unusable, because one has to constantly keep checking that the TW cli is still working. I cannot find any kind of logging / verbose mode which gives any evidence to support this theory. |
|
Thanks @thecrypticace
I discovered after my last message that I could set DEBUG=* as an environment variable which prints out some more stuff from TW, but no errors when it stops watching. I could log file-system activity (with Procmon) and see if I can see some contention - it might be more efficient for me to try that here than for you to spend ages trying to repro this. If there is any other diagnostics I can enable in Node/TW do let me know - I am not a Node person at all so may be overlooking some very obvious stuff. |
Yeah there aren't any more diagnostics other than I'll look over the code and stuff though to see if anything stands out at me. |
I just merged a fix that may help here but I'm not certain if it will. Could someone give the insiders build a try to see if it works reliably ( |
This was sending me relatively mad until I stumbled across this. Thanks so much for reporting it. I am using tailwind 3.2.0 and still seeing this issue. I used to have backupcopy set but have recently trimmed down my vim config. I've reinstated it so I'm fine but, gosh, that was deeply puzzling. |
@michaeljones Are you on Tailwind v3.2.2? |
@thecrypticace I was on 3.2.0 through the Elixir/Phoenix tailwind set up. From a quick test, it still fails with 3.2.2 though unless I have |
This drove me up the wall. It's good that I found this thread. I would like to report that this issue is still occurring in 3.2.2. (was fine in 3.1.8 for me). I also tried |
@n1ghtmare What OS/editor are you using? |
Hi sorry, I use Neovim |
Also having this issue, using any editor (including
Minimal reproduction here: https://github.com/carderne/tailwind-watch-issue |
@carderne Thanks! Will take another look today! |
@carderne Yep, I can reproduce this in Linux — but not macOS. I think there's a difference in the order of events that still causes the bug to happen in some cases. |
@carderne I merged in another fix. It appears to work for me on Linux. Would you mind giving the insiders build a test? |
Yup, works for me! |
I know this is old news but wanted to confirm that it's also working for me too. 3.2.1 never updated with |
This is based on #7679 - the versions being used are listed there.
I ended up setting up test-case project here: https://github.com/javornikolov/tailwindcss-issue-7679
There is Github Actions CI job which outlines the changes I do to reproduce the issue. However the issue does't occur when running the automated scripts. It occurs when I manually edit the file using
vim
editor (doing the same changes).vim
version is 8.2template/*
to src.gedit
. Or if I also touch files (usingtouch -m
). (Sometimes touch doesn't help either - that's more subtle, I am not sure how to consistently reproduce yet.)Sometimes refresh of output.css happens when I use
vim
too but it's quite rare (and is after some modifications of file outside of vim as well).Steps to reproduce - based on the GithHub repo above:
npx pm2 start ecosystem.config.js
)src/tailwind.css
copy-pasting the content oftemplates/tailwind.css.2
usingvim
.src/index.html
(using index.html.2)btn-cool-1
but notbtn-cool-2
. I uploaded the state of the files to branchtopic/after-change-using-vim
in the same github repo. I included somestat
outputs in case that matters.If I switch the order of modifying
tailwind.css
andindex.html
and I editindex.html
first - then norbtn-cool-1
, norbtn-cool-2
are includedHypothesys
I suspect that the way
vim
saves files has specifics which are not yet recognized as changes to source files. Perhaps it can be reproduced outside vim, I am just not fully aware in what exactly way yet. Some insights might be possibly found e.g. here: https://vi.stackexchange.com/questions/25030/vim-not-firing-inotify-events-when-writing-fileThe text was updated successfully, but these errors were encountered: