Seemingly edge case of not being able to `include` while inside an `if` condition inside a loop.

So if I run this to re-include a file when it changes:

fname = "/full/path/to/changingfile.jl"

t1 = 0
  if t1 != mtime(fname)
    t1 = mtime(fname)

And the changingfile.jl is actually changed I get could not open file. Just wanted to know if this is normal behaviour? It does not happen when it’s inside either an if or it is just a loop.

I was impressed by Django server reloading the files I’m working on so decided to implement it in my Julia server( at least not in production ).

Thanks in advance

(aside, you could do this with Revise.jl)

1 Like

Some editors back buffer their writes — write to a temp file, unlink the existing file inode, then rename the temp file. To avoid file corruption I think. Since you are basically polling the file constantly, if your editor does this then the file might not exist for a brief moment exactly when you are looking for it.

1 Like

Ah that could be it then. Thanks. I was using Neovim to edit it.

Will try that out.

Nope, doesn’t work.

Did you do Revise.track(filename)?

Irrespective, you should still use Revise.jl for your “normal” Julia life!


Yep. I use Revise mainly in the REPL and it’s a pleasure there. But no luck with this.

The problem seemed to be exactly that. I put sleep(.1) and it worked. Thank you very much.