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

(Windows10) FileNotFoundError #4

Open
auwsmit opened this issue Oct 26, 2017 · 6 comments
Open

(Windows10) FileNotFoundError #4

auwsmit opened this issue Oct 26, 2017 · 6 comments
Labels

Comments

@auwsmit
Copy link

auwsmit commented Oct 26, 2017

Here's what happens when I try to run gvim from the command-line:

X:\Desktop>vim-profiler.py gvim
Running gvim to generate startup logs...Traceback (most recent call last):
  File "X:\Desktop\vim-profiler.py", line 327, in <module>
    main()
  File "X:\Desktop\vim-profiler.py", line 318, in main
    analyzer = StartupAnalyzer(args)
  File "X:\Desktop\vim-profiler.py", line 205, in __init__
    for i in range(self.runs)]
  File "X:\Desktop\vim-profiler.py", line 205, in <listcomp>
    for i in range(self.runs)]
  File "X:\Desktop\vim-profiler.py", line 80, in __init__
    self.generate(check_system)
  File "X:\Desktop\vim-profiler.py", line 86, in generate
    self.__run_vim()
  File "X:\Desktop\vim-profiler.py", line 178, in __run_vim
    subprocess.call(full_cmd, shell=False)
  File "C:\Python34\lib\subprocess.py", line 535, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Python34\lib\subprocess.py", line 848, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1104, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

And regular vim isn't detected:

X:\Desktop>vim-profiler.py vim
Running vim to generate startup logs... done.
Loading and processing logs...
No plugin found. Exiting.

I have 32-bit vim 8 from this repo, with Python 2.7.0 and Python 3.4.0 installed

@bchretien
Copy link
Owner

This tool was made with Linux/OS X in mind, so making it work on Windows might require some modifications.

It seems that subprocess.call cannot find gvim: does running gvim in your shell alone works?
As for vim, it seems that the script could not find your plugin directory. Could you provide more information on your setup (e.g. where are the plugins located)?

@bchretien bchretien added the bug label Oct 28, 2017
@auwsmit
Copy link
Author

auwsmit commented Oct 28, 2017

This tool was made with Linux/OS X in mind, so making it work on Windows might require some modifications.

It's cool and somewhat expected, Windows always gets the short end of the foss-stick :P

does running gvim in your shell alone works?

Yeah, both it and regular vim are in my PATH environment variable

Could you provide more information on your setup (e.g. where are the plugins located)?

The vim folder in Windows is located at $HOME/vimfiles, and I used vim-plug, so they're under the plugged folder. However, it probably isn't related to plugin location because I was able to use the profiler just fine on Debian with my same vim setup.

Either way, thanks for the useful tool!

@auwsmit
Copy link
Author

auwsmit commented Oct 28, 2017

Figured out the gvim error! The Windows installer uses .bat files to launch the executable files, so by using the direct path, I don't get all the errors anymore:

X:\Desktop>vim-profiler.py "C:\Program Files (x86)\Vim\vim80\gvim.exe"
Running C:\Program Files (x86)\Vim\vim80\gvim.exe to generate startup logs... done.
Loading and processing logs...
No plugin found. Exiting.

X:\Desktop>vim-profiler.py "C:\Program Files (x86)\Vim\vim80\vim.exe"
Running C:\Program Files (x86)\Vim\vim80\vim.exe to generate startup logs... done.
Loading and processing logs...
No plugin found. Exiting.

However, it still can't find plugins

@bchretien
Copy link
Owner

If you're familiar with Python, you can take a look at the __guess_plugin_dir method. This is probably where something goes wrong (user plugin directory detection fails). Can you try to run the profiler with the -s option? It will take system plugins into account as well.

@bchretien
Copy link
Owner

We could probably add appveyor support as well, that would allow ensuring continuous support for Windows.

@icylogic
Copy link

It is because all regex search are written as
"sourcing (.+?)/(?:[^/]+/)(?:%s)/[^/]+" which should be
r"sourcing (.+?)\\(?:[^\\]+\\)(?:%s)\\[^\\]+" for Windows.
Delimiters are hard-coded as /.
Also, self.system_dirs = ["/usr", "/usr/local"] makes no sense for Windows. I simply give it an empty list.

After fixing these problems, it runs successfully on Windows for both vim and gvim.

PS R:\vim-profiler-master> python win.py D:\Vim\vim80\gvim.exe
Running D:\Vim\vim80\gvim.exe to generate startup logs... done.
Loading and processing logs... done.
Plugin directory: D:\\Vim\\vimfiles\\plugged
=======================================================================
Top 10 plugins slowing D:\Vim\vim80\gvim.exe's startup
=======================================================================
1         6.000   base16-vim
2         5.000   nerdcommenter
3         4.000   vim-airline
4         3.000   fencview
5         2.000   vim-airline-themes
6         1.000   vim-toml
7         1.000   auto-pairs
8         1.000   vim-expand-region
9         0.000   vim-json
10        0.000   vim-stylus

However, instead of using regex on full paths, pathlib.Path.parts or os.path.split should be more elegant and predicable. These built-in libraries are designed for cross-platform and complex environments (Network drives, UNC, symbol links, etc.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants