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

Recompilation via require fails silently #131

Closed
bR3iN opened this issue Mar 9, 2024 · 3 comments
Closed

Recompilation via require fails silently #131

bR3iN opened this issue Mar 9, 2024 · 3 comments

Comments

@bR3iN
Copy link

bR3iN commented Mar 9, 2024

Hi. First of all, thank you for your work on the plugin, it has worked great so far for me. However, I recently noticed that errors during recompilation of previously compiled modules are no longer shown.

Steps to reproduce:

  • Create a file ~/.config/nvim/fnl/test.fnl with valid content, e.g. (print :hello)
  • Require it via :=require'test'<CR>
  • Create a syntax error in test.fnl, e.g. by removing the closing parenthesis.
  • Unload the modul via :lua package.loaded['test'] = nil
  • Rerequire it via :=require'test'<CR>

Until recently, the last require would've produced an error displaying the error description produced by fennel. But now it just fails silently, loading the last succesfully compiled Lua file. When changing test.fnl without any syntax erros, the last require correctly picks up the changes.

I'll have to admit that I haven't read all the API documentation yet, so I can't say for sure if this is the intended way to do this, I only noted the regression; if there is another more "correct" way to recompile a module, I'd appreciate a pointer in the right direction.

@rktjmp
Copy link
Owner

rktjmp commented Mar 9, 2024

Thanks for the report. I'm pretty sure I have already fixed this in an upcoming release which I just need some time to tidy up.

For now you could use this global function to unrequire a module, which also clears the cache.

(fn _G.__unrequire [...]
  (let [hotpot (require :hotpot)]
    (hotpot.api.cache.clear-cache))
  (each [module _ (pairs package.loaded)]
    (for [i 1 (select :# ...)]
      (let [unreq (select i ...)]
        (if (string.match module unreq)
          (do
            (print :unreq module)
            (tset package.loaded module nil)))))))
:=__unrequire("my.mod") -- unrequires my.mod my.mod.x my.mod.y etc etc

It will ask for confirmation to clear the cache and it clears the whole cache so its a pretty blunt instrument, but I will add an option in the upcoming to skip the prompt too.

@rktjmp
Copy link
Owner

rktjmp commented Mar 19, 2024

Should be fixed in 87d2c34 with according regression test in ebc9bfc.

@rktjmp rktjmp closed this as completed Mar 19, 2024
@bR3iN
Copy link
Author

bR3iN commented Mar 20, 2024

Hi. Sorry for not coming back to you earlier. It now works again as expected. Thanks!

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

No branches or pull requests

2 participants