DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
21.63k stars 832 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

Closed Andrew15-5 closed 1 month ago

Andrew15-5 commented 7 months 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 7 months ago

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

Andrew15-5 commented 7 months ago

I don't.

FelipeFTN commented 6 months 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 6 months 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).

Andrew15-5 commented 4 months ago

I can no longer reproduce it. At least with new template and 79e18c2d62166f388641cd6e20a82bef2506535a. The latest commit is broken as it panics on asset optimization step and has a fancy UI that is definitely isn't complete. I had backupcopy=auto. Maybe I should use April 16th commit.

jkelleyrtp commented 4 months ago

If you're using nix we have a bug report on manganis where we're looking for the wrong "sh" and optimization fails - looks like there's a simple fix.

Andrew15-5 commented 4 months ago

using nix how?

jkelleyrtp commented 1 month ago

The original issue here should be fixed now. We have much more intelligent filtering in #2779

yanshay commented 1 day ago

I'm trying dioxus and using Neovim and get ERROR dioxus_cli::server: Failed to parse file: No such file or directory (os error 2) quite frequently. Was this solved as @jkelleyrtp wrote? or was it solved with some configuration required for Neovim? Or not solved?

Andrew15-5 commented 23 hours ago

It works with latest Dioxus.

yanshay commented 23 hours ago

It works with latest Dioxus.

By latest you mean unreleased yet? I installed as in the instructions yesterday.

Andrew15-5 commented 21 hours ago

I just built dx from 31d72db and used dx new web -t DogeDark/dioxus-template --revision c7b8c5a --subtemplate Bare-Bones + 7 Enters (see https://github.com/DioxusLabs/dioxus-template/pull/50#issuecomment-2495981169).

image

CSS and rsx hot reloading works. I even tried nvim --clean. No issues, other than viewport flashes during hot reloading.