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

[Bug]: Windows related issue starting flutter #187

Closed
Tsuzat opened this issue Oct 1, 2022 · 9 comments
Closed

[Bug]: Windows related issue starting flutter #187

Tsuzat opened this issue Oct 1, 2022 · 9 comments

Comments

@Tsuzat
Copy link

Tsuzat commented Oct 1, 2022

Describe the bug
The same configuration is not working in windows that worked in Linux. I'm attaching a video for reference.
Video

To Reproduce
Steps to reproduce the behavior:

  1. Go to any flutter project using Powershell or Git Bash, Open it in NeoVim
  2. do run the command "FlutterRun" or "FlutterDevices"
  3. See error

Error is somewhat like this

Error executing Lua callback: ...\site\pack\packer\start\plenary.nvim/lua/plenary/job.lua:405: Failed to spawn process:

stack traceback:
        ...\site\pack\packer\start\plenary.nvim/lua/plenary/job.lua:405: in function '_execute'
        ...\site\pack\packer\start\plenary.nvim/lua/plenary/job.lua:448: in function 'start'
        ...r\start\flutter-tools.nvim/lua/flutter-tools/devices.lua:198: in function 'callback'
        ...tart\flutter-tools.nvim/lua/flutter-tools/executable.lua:157: in function 'get'
        ...tart\flutter-tools.nvim/lua/flutter-tools/executable.lua:156: in function 'flutter'
        ...r\start\flutter-tools.nvim/lua/flutter-tools/devices.lua:190: in function 'list_devices'
        ...ck\packer\start\flutter-tools.nvim/lua/flutter-tools.lua:31: in function <...ck\packer\start\flutter-tools.nvim/lua/flutter-tools.lua:30>

Expected behavior
The expected behavior (that it does in Linux) is to run flutter or show a list of devices.

Screenshots
image
image

System information

  • OS: Windows 11
  • Flutter version: 3.3.3 Channel Stable
  • Is flutter in $PATH: Yes it is in C:\Development\flutter\bin\flutter.bat
  • neovim version: 0.8.0

Additional context
I'm using the default configuration in both my machine Linux and Windows. It works smoothly in Linux but not in Windows.

@akinsho
Copy link
Owner

akinsho commented Oct 1, 2022

@Tsuzat I don't use Windows, so there's no chance I'll be able to fix this for you, as I don't know anything about changing the paths or whatever else is required. If you are able to point in the direction of what might not be working, that might be useful. Otherwise, as a Windows user you will have to do some more debugging

@akinsho akinsho changed the title [Bug]: [Bug]: Windows related issue starting flutter Oct 1, 2022
@akinsho
Copy link
Owner

akinsho commented Oct 1, 2022

@Tsuzat it's important to clarify that you might need to change your config to work with windows and vice versa I've never guaranteed that this would work automatically as I do not use or test on Windows, so I definitely cannot guarantee that. Other Windows users are able to use this plugin successfully, so I doubt this is an issue with the plugin and more likely you need to tweak your configuration using some conditional logic when running on Windows.

@Tsuzat
Copy link
Author

Tsuzat commented Oct 2, 2022

I appreciate the hard work you putting in. I don't want to put an extra burden on you. I'll try to debug it by myself. But can you give me an idea of what could have gone wrong with the configuration?

@akinsho
Copy link
Owner

akinsho commented Oct 3, 2022

@Tsuzat I'm not really sure what is going wrong but it seems like it's trying to run the command to list the users devices and it cannot find flutter. You seem to have indicated that your flutter path is \\C:Development etc. I would try and run that command i.e. the full path that is in your error message plus the command devices and see if that actually works in your system

@Tsuzat
Copy link
Author

Tsuzat commented Oct 27, 2022

I guess I'll use this tool in Linux then. Thanks for the help.

@Tsuzat Tsuzat closed this as completed Oct 27, 2022
@akriese
Copy link

akriese commented Nov 13, 2022

@Tsuzat I dont know, if you're still interested in developing flutter on Windows, but I just had the same error as you. Turns out, that explicitly setting the flutter_path to <path_to_flutter_installation>\bin\flutter.bat seems to solve the issue. There is also an executable in that bin folder called <path_to_flutter_installation>\bin\flutter. This is the one used by the plugin, when not setting the flutter path at all. So @akinsho, it might be good for the windows community to change this to use the .bat instead of the actual executable. I'll see if I can find the exact lines of code to adapt in plugin and report back :)

@akriese
Copy link

akriese commented Nov 13, 2022

Turns out, the fn.exepath("flutter") call returns <path_to_flutter_installation>\bin\flutter, which is not the same as Powershell's Get-Command flutter (which returns the bat). So it rather is an error on Vim's side. The same error occurs in dap, as it is also using the vim.fn.exepath() function.
EDIT: exepath seems to be a problematic function for windows altogether, looking at all the issues on vim's and NeoVim's githubs...

@Tsuzat
Copy link
Author

Tsuzat commented Dec 24, 2022

I would like to add this solution that I got on Reddit. https://www.reddit.com/r/neovim/comments/xt234i/comment/j1hkdwa/?utm_source=share&utm_medium=web2x&context=3

So, turns out that the plugin uses the flutter binary rather than flutter.bat. The solution is to provide the exact location of the flutter.bat in the setup.

e.g.

local status_ok, flutter_tools = pcall(require, "flutter-tools")

if not status_ok then
  return
end

flutter_tools.setup {
  flutter_path = "C:/Development/flutter/bin/flutter.bat",
}

Now it is working fine.

@akriese
Copy link

akriese commented Dec 24, 2022

Yes, that is the thing I was proposing in my first comment ;)
Anyways, this issue should be fixed as soon as neovim/neovim#21175 gets merged. Then, the workaround should not be necessary anymore.

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

3 participants