Skip to content

replpad refuses to re-read files once they're saved #7

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

Open
toddself opened this issue Sep 26, 2013 · 17 comments
Open

replpad refuses to re-read files once they're saved #7

toddself opened this issue Sep 26, 2013 · 17 comments

Comments

@toddself
Copy link
Contributor

OS: Mac 10.8.4
iTerm2
replpad v0.11.1

node v0.10.18 | Calvin | 8 cpus | darwin platform | v8 v3.14.5.9 | uv v0.10.15

Editors tried: Sublime Text 3 and vim

Issue:

Launching replpad . enumerates the .js files in the directory. Opening and saving one of them causes replpad to correctly re-read the file.

Making more changes and saving it does not ever cause replpad to re-save.

replpadbug

@thlorenz
Copy link
Owner

I'm about to close this since no one else ever reported this issue or added comments to this one.

Is this working better for you now?

@toddself
Copy link
Contributor Author

Nope :).

Brand new machine -- same issue.

replpad v0.11.8

node v0.10.28 | NewOSX | 8 cpus | darwin platform | v8 v3.14.5.9 | uv v0.10.27

I'll try to look at it one day.

@thlorenz
Copy link
Owner

really friggin weird is all I can say

@benrhughes
Copy link

FWIW I'm seeing exactly the same behavior. The first save of any monitored file is detected, but no further changes are.

For me it seems to be related to vim. I can echo into a file (or even just touch it), and replpad picks it up just fine. However with vim, it only ever picks up the first save. Once it stops picking up changes, it never starts again. So, if I edit in vim, then touch the file, replpad doesn't trigger.

replpad v0.11.8
node v0.10.29 | xps | 8 cpus | linux platform | v8 v3.14.5.9 | uv v0.10.27

@thlorenz
Copy link
Owner

Interesting find, does it work with other editors?
Maybe your vim setup is different somehow.

I installed mine via brew install macvim --override-system-vim.

Overall seems to be a vim issue though since somehow it doesn't trigger the file change event that replpad depends on.

@toddself
Copy link
Contributor Author

Doesn't matter what editor - vim, sublime, atom, emacs -- all the same result.

@benrhughes
Copy link

I don't imagine vim is particularly unusual in how it writes files, but I
can try some other editors tomorrow to confirm.

From a quick glance at your dependencies I'm not sure how you're doing the
file watching, but I've successfully used watchr in the past. It certainly
works with vim IME.

Cheers,

Ben
On 13 Jun 2014 00:12, "Thorsten Lorenz" [email protected] wrote:

Interesting find, does it work with other editors?
Maybe your guy's vim setup is different somehow.

I installed mine via brew install macvim --override-system-vim.

Overall seems to be a vim issue though since somehow it doesn't trigger
the file change event that replpad depends on.


Reply to this email directly or view it on GitHub
#7 (comment).

@thlorenz
Copy link
Owner

The watcher stuff is here.

I'm open to have that swapped out with a dependency however. The key is though that it needs to be able to pick up newly created files as well and not fire too often, i.e. twice per save (which some of them do).

@benrhughes
Copy link

Watchr seems to behave well in those regards (I use it to trigger cache
invalidation when a new file is created).

I'll see if I can find some time to swap it in, and if it fixes my problem
I'll send you a PR.
On 13 Jun 2014 00:34, "Thorsten Lorenz" [email protected] wrote:

The watcher stuff is here
https://github.com/thlorenz/replpad/blob/master/lib/watcher.js.

I'm open to have that swapped out with a dependency however. The key is
though that it needs to be able to pick up newly created files as well and
not fire too often, i.e. twice per save (which some of them do).


Reply to this email directly or view it on GitHub
#7 (comment).

@thlorenz
Copy link
Owner

Would love a PR @benrhughes. Feel free to reach out if you have any questions and/or even submit a semi working PR that we can improve on.

@benrhughes
Copy link

OK, after a bit of investigation, this seems to be a problem with fs.watch, not your watch code specifically. This bare-bones code appears to have the same issue:

var fs = require('fs');
fs.watch('a.js', {persistent: false}, console.log);
process.openStdin().addListener('data', process.exit);

It appears to still be a problem in 0.11.xx too.

I did some testing and it seems that watchr has the same issue (presumably because it uses fs.watch) - I didn't notice before because I'm using it to detect new files, not updates.

@benrhughes
Copy link

According to nodejs/node-v0.x-archive#3172, this is a vim issue (or at least partially a vim issue).

Setting the vim option backupcopy=yes appears to "fix" things, although it leads to the change being detected (and hence the file being loaded) twice.

@thlorenz
Copy link
Owner

Thanks for digging into this. So seems like this can't be fixed in replpad then?
I'm just wondering why @toddself also experiences this with other editors or is it just that the backup=yes is just a hack that makes it work in vim and other editors would need another hack?

Also peculiar why I don't have that problem (and I assume it works for lots of others since I haven't heard about this bug from many).
FWIW here is my vimrc maybe I have a setting in there that happens to make it work, although I did turn off swapfiles (not sure how that relates to backupcopy).

@toddself
Copy link
Contributor Author

In sublime if you set: "atomic_save": false in your user preferences it fixes this issue as well in this editor. Perhaps updating the documentation to explain?

@thlorenz
Copy link
Owner

Yeah including this in the docs would be nice indeed.
We could document how to configure specific editors to play nice with replpad.

@wildeyes
Copy link

wildeyes commented Aug 6, 2014

I tried setting all the various backup options in various combinations, still can't make replpad eval once via Vim. :(

@dylnb
Copy link

dylnb commented Sep 26, 2014

I just came across replpad today, installed it, and was experiencing the same issue that @toddself originally reported: replpad would pipe over whatever it found the very first time I saved a file (actually it would pipe it over twice), but would not react to anything after that. Adding backupcopy=yes to my vimrc seems to have solved the problem.

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 a pull request may close this issue.

5 participants