DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
18.49k stars 703 forks source link

`dx serve` prints "Failed to parse file: No such file or directory" and starts rebuild sometime on static string change (Neovim) #2312

Open Andrew15-5 opened 2 weeks ago

Andrew15-5 commented 2 weeks ago

Problem

dx serve (I guess starting from 0.5.x) now gives an error:

2024-04-15T14:10:04.619499Z ERROR dioxus_cli::server: Failed to parse file: No such file or directory (os error 2)

when changing a static string in the rsx block (or probably anything else). In rare cases, it triggers a rebuild.

After some debugging, I tried VSCodium and after each save absolutely nothing happened, and at that point I realized, it's https://github.com/typst/typst/issues/2633#issuecomment-1837183367 all over again. And, of course, the workaround is the same:

local rust_group = vim.api.nvim_create_augroup("rust_group", {})
vim.api.nvim_create_autocmd({ "FileType" }, {
  pattern = "rust",
  callback = function()
    vim.opt_local.backupcopy = "yes"
  end,
  group = rust_group,
})

I think it is also caused by notify crate (same as with Typst). So either some configuration must be changed for the watcher to work better, or the upstream crate should accommodate the "fix" of the default when saving files in Neovim. Some new option or something. Otherwise, I think this won't be resolved (there is probably no chance Neovim will change its default behavior).

Steps To Reproduce

Expected behavior

No errors or rebuilds.

Environment:

Questionnaire

JustSimplyKyle commented 6 days ago

This is also present in helix, do you know any workarounds for that?

Andrew15-5 commented 6 days ago

I don't.

FelipeFTN commented 2 days ago

I'm having the same issue here. Environment: Dioxus version: 0.5.4, main Rustc version: 1.80.0-nightly OS info: Manjaro-i3 App platform: web Neovim version: v0.9.5

The workaround from https://github.com/typst/typst/issues/2633 seems to work fine on my neovim lua files:

-- Rust dioxus workaround
vim.opt_local.backupcopy = "yes"

But I'm still getting the error message when trying to set up the tailwind: image

Andrew15-5 commented 2 days ago

This is most likely an unrelated error. Try changing public to assets (depending on the value of the asset_dir in the Dioxus.toml) or removing the line completely (and using the path directly in the link element, see default template with dx new for example).