nvim-flutter / flutter-tools.nvim

Tools to help create flutter apps in neovim using the native lsp
MIT License
1.04k stars 83 forks source link

[BUG] fvm not working on windows #343

Open Azkarell opened 7 months ago

Azkarell commented 7 months ago

Is there an existing issue for this?

Current Behavior

Running :FlutterRun with fvm enabled throws ENOENT: no such file or directory in windows grafik although path is detected correctly

Expected Behavior

Running :FlutterRun in windows should run flutter

Steps To Reproduce

my conifg with lazy: { 'akinsho/flutter-tools.nvim', lazy = false, dependencies = { 'nvim-lua/plenary.nvim' }, config = function() require('flutter-tools').setup { fvm = true, -- debugger = { -- enabled = true, -- run_via_dap = true, -- register_configurations = function(paths) -- local file = io.open('.vscode/launch.json', 'r') -- if file ~= nil then -- io.close(file) -- require('dap.ext.vscode').load_launchjs() -- end -- end, -- }, } require('telescope').load_extension 'flutter' end, },

Environment

- OS: Windows 11 Pro
- Flutter version: fvm mit flutter 3.13.9
- Is flutter in $PATH: yes
- neovim version: 0.9.5

Anything else?

I tried to find out what is happening and it might not even be the fault of this tool but i am quite new to neovim and just evaluating if i want to continue using it. what i found that just the line :lua =vim.uv.spawn("C:\\\fvm\versions\3.13.9\bin\flutter", { { "run" }}) already fails

just running "C:\\\fvm\versions\3.13.9\bin\flutter" in pwsh or cmd or even with Start-Process is working.

sidlatau commented 7 months ago

Does it work if you run fvm outside neovim: fvm flutter run?

Azkarell commented 7 months ago

yes everything works as expected outside of neovim. only this plugin/neovim can't start it.

sidlatau commented 2 months ago

Please check the latest plugin version,https://github.com/akinsho/flutter-tools.nvim/commit/d8f2eac1734e0e68050bc57600e5f2ba775b1ec4 commit may help. If there is still a problem, please reopen the issue.

AyushUlric commented 2 months ago

Facing this issue on windows with latest commits. This happens when I set fvm = true. However I've noticed that if i set fvm = false and add flutterpath = 'C:\Users\daban\fvm\versions\3.19.5\bin\flutter.bat' everthing works fine. Maybe change fvm path from ..\flutter to ..\flutter.bat. Any thoughts? image

sidlatau commented 2 months ago

Yea, it looks like missing .bat suffix is a problem. I will reopen this case to fix it.

sidlatau commented 2 months ago

I do not have Windows, so I am not sure if the path is the same as in macOS. @AyushUlric, if you have time please check if this works for you https://github.com/akinsho/flutter-tools.nvim/pull/386? The setup would be:

return {
  "akinsho/flutter-tools.nvim",
  branch = "fvm-on-windows",
...
}
AyushUlric commented 2 months ago

@sidlatau, didn't work, same error. I hope I didn't mess up the setup as I am fairly new to nvim so attaching my setup code below.

image

image

I then updated all my plugins from the Lazy menu and restarted nvim.

I think on windows flutter and flutter.bat will always be in the same directory and the current path correctly points to the flutter file, hope that helps.

sidlatau commented 1 month ago

@AyushUlric thanks for testing. I see you are using a global path to fvm flutter. But there should be a local one in your project, in .fvm directory:

image

Plugin constructs path .fvm/flutter_sdk/bin/flutter.bat. Does this file exist in your project? Did you run fvm use <flutter version> in your project directory?

AyushUlric commented 1 month ago

@sidlatau Yes I did run the fvm use command and I have the .fvm directory in my project root. But I noticed that flutter_sdk directory is actually a shotcut which points to the global fvm path. I checked all my fvm projects and it seems to be common in all of them.

image image

Maybe that's how it is on Windows?

BTW I added the global path because thats what showed up in error logs with path not found.

image