Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Ambiguous use of user-defined command' error on specifically windows #25

Closed
5 tasks done
umutondersu opened this issue Jan 27, 2024 · 41 comments
Closed
5 tasks done
Labels
wontfix This will not be worked on

Comments

@umutondersu
Copy link

Describe the bug

I get the error I mention at the end of the description when I use any of the commands given the Readme. I believe it is only a windows error as in my Ubuntu WSL I have not received this error.

Error executing Lua callback: vim/_editor.lua:341: nvim_exec2(): Vim:E464: Ambiguous use of user-defined command: CopilotChat Explain how it works.
stack traceback:
[C]: in function 'nvim_exec2'
vim/_editor.lua:341: in function 'cmd'
...nvim-data/lazy/CopilotChat.nvim/lua/CopilotChat/init.lua:23: in function <...nvim-data/lazy/CopilotChat.nvim/lua/CopilotChat/init.lua:22>

Reproduction

Use the config given in the usage section on Windows. Try any command or keybindings.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
    Memory: 909.82 MB / 7.80 GB
  Binaries:
    Node: 20.10.0 - ~\.nvm\versions\node\v20.10.0\bin\node.EXE
    Yarn: 1.22.21 - ~\.nvm\versions\node\v20.10.0\bin\yarn.CMD
    npm: 10.2.3 - ~\.nvm\versions\node\v20.10.0\bin\npm.CMD
    pnpm: 8.12.1 - ~\.nvm\versions\node\v20.10.0\bin\pnpm.CMD
  Browsers:
    Chrome: 120.0.6099.225
    Edge: Chromium (121.0.2277.83)
    Internet Explorer: 11.0.19041.3636

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@jellydn jellydn added the bug Something isn't working label Jan 27, 2024
@jellydn jellydn changed the title ;Ambiguous use of user-defined command' error on specifically windows Ambiguous use of user-defined command' error on specifically windows Jan 27, 2024
@jellydn jellydn added the help wanted Extra attention is needed label Jan 27, 2024
@umutondersu
Copy link
Author

When I run :verb command Copilot, there is an extra command on linux, the top one on the screenshot
image
I think the problem stems from this. In windows this command is not correctly created.

@Espacio-root
Copy link

I momentarily faced the same issue on arch linux upon installation. It weirdly disappeared after a while. Still don't know what caused and fixed the issue.

@jellydn
Copy link
Owner

jellydn commented Jan 27, 2024

Could you run :healthcheck command and share the output here? Thanks.

@nolanking90
Copy link

@jellydn @umutondersu
I had the same error on macOS (using packer instead of lazy). However, when I ran verb command Copilot, I had no CopilotChat command listed. So, this may be a different issue.
Here's what I did to resolve the issue, it may work for your issue as well.

First, :healthcheck showed I was missing pynvim.
I installed that with pip, and :healthcheck no longer returned any error, but the Vim:E464 error was still happening.

I then ran :UpdateRemotePlugins and got errors telling me some modules were missing: python-dotenv, chardet, and prompt-toolkit. (Obviously, I had to run it multiple times until all dependencies were met; each run only revealed one missing dependency)
Installing these with pip, running :UpdateRemotePlugins (and getting no errors), and then reopening neovim resolved this for me.

@James-Darko
Copy link

I was running into the same issue. I realized I forgot to run :UpdateRemotePlugins before restarting. So it's working for me now.

@umutondersu
Copy link
Author

Could you run :healthcheck command and share the output here? Thanks.

This is the output

CopilotChat: require("CopilotChat.health").check()

CopilotChat.nvim health check ~
- OK Python version 3.9 is supported
- WARNING pynvim version Traceback (most recent call last):
  File "C:\Users\umuts\AppData\Local\Temp\selc.0.py", line 1, in <module>
  import pynvim; print(pynvim.__version__)
  ModuleNotFoundError: No module named 'pynvim' is not supported

Which is weird because I already have pynvim installed anu used UpdateRemotePlugins. I'm investigating the reason.

@jellydn
Copy link
Owner

jellydn commented Jan 29, 2024

Thanks @umutondersu I think you got the same issue with @nolanking90 You should install pynvim on your PC. You should find this command on readme. Could you please try again?

pip install python-dotenv requests pynvim==0.5.0 prompt-toolkit

@umutondersu
Copy link
Author

Thanks for the fast reply. I have run this command before my installation, so I do not think this is the issue. I have tried to run it again with the force flag but the result is still the same. For reference this is my pip show pynvim output.

Name: pynvim
Version: 0.5.0
Summary: Python client for Neovim
Home-page: http://github.com/neovim/pynvim
Author: Neovim Authors
Author-email:
License: Apache
Location: c:\python310\lib\site-packages
Requires: greenlet, msgpack
Required-by:

@Krujo
Copy link

Krujo commented Jan 29, 2024

I have the same issue, I have python installed, neovim finds my python installation, I have pynvim installed as well.

I get a: Warning Python 3 is required from the checkHealth of this plugin but later on it says python works fine.

@jellydn
Copy link
Owner

jellydn commented Jan 30, 2024

Hi all,

There are two new commands from @ziontee113 on canary Could you take a try and let us know if any issue?

@umutondersu
Copy link
Author

I have tried the canary branch but the problem still persists.

@Krujo
Copy link

Krujo commented Jan 31, 2024

Same for me

@jellydn
Copy link
Owner

jellydn commented Jan 31, 2024

FYI - There is a similar issue which was closed by the user due to his config. #38

Make sure that you do the following after installing the plugin.

3. Open up Neovim and run :UpdateRemotePlugins
4. Restart Neovim

@Krujo
Copy link

Krujo commented Jan 31, 2024

Should the plugin work with https://github.com/junegunn/vim-plug?

@jellydn
Copy link
Owner

jellydn commented Jan 31, 2024

Should the plugin work with https://github.com/junegunn/vim-plug?

I am not sure as I didn't use Plug but I guess it should work. You might refer to this commit to get the idea with Plug jellydn/lazy-nvim-ide@5128bc3

@jellydn jellydn added wontfix This will not be worked on and removed bug Something isn't working help wanted Extra attention is needed labels Feb 2, 2024
@jellydn jellydn closed this as completed Feb 2, 2024
@jinzhongjia
Copy link

oh, this issue is not solved

It still happens on windows. I tried to write a python file for testing. It seems that: the UpdateRemotePlugins command cannot recognize the python plug-in under windows, and the python plug-in registration result is empty.

@rossjaywill
Copy link

rossjaywill commented Feb 2, 2024

I'm seeing this issue on linux too, I have all of the pip dependencies installed and the :UpdateRemotePlugins command returns:

remote/host: python3 host registered plugins ['copilot-plugin.py']
remote/host: generated rplugin manifest: 1

:checkhealth CopilotChat
Does not show any errors/warnings either.

I've tried this with both copilot.lua and copilot.vim.

(edit: and tried both main and canary branches, as well as reverting to a previous commit from early January)

@jellydn
Copy link
Owner

jellydn commented Feb 2, 2024

I'm seeing this issue on linux too, I have all of the pip dependencies installed and the :UpdateRemotePlugins command returns:


remote/host: python3 host registered plugins ['copilot-plugin.py']

remote/host: generated rplugin manifest: 1

:checkhealth CopilotChat

Does not show any errors/warnings either.

I've tried this with both copilot.lua and copilot.vim.

(edit: and tried both main and canary branches, as well as reverting to a previous commit from early January)

Do you restart Neovim after run the update remote plug-in command?

@rossjaywill
Copy link

@jellydn yes, multiple times - no luck.

@jellydn jellydn reopened this Feb 2, 2024
@jellydn
Copy link
Owner

jellydn commented Feb 2, 2024

Could you share with me the output from :healtcheck command? @rossjaywill

@rossjaywill
Copy link

 ──────────────────────────────────────────────────────────────────────────────
 CopilotChat: require("CopilotChat.health").check()

 CopilotChat.nvim health check
 - OK Python version 3.8 is supported
 - OK pynvim version 0.5.0 is supported

Thanks for taking a look!

@jinzhongjia
Copy link

It's strange. I use UpdateRemotePlugins under both wsl and windows. wsl can be registered normally, but windows is empty.
the result for windows:
image
Even the python script I wrote based on the neovim documentation doesn't work. I'm trying to find out why.

@jellydn
Copy link
Owner

jellydn commented Feb 2, 2024

Hi all,

I've marked this as won't fix as I can't reproduce this on Windows. I am a Mac user and it's tricky for me to investigate the issue.

cc @gptlang How about you?

@gptlang
Copy link
Collaborator

gptlang commented Feb 2, 2024

I'm a Linux user. Don't have Windows available to test.

@rossjaywill
Copy link

I'm seeing this issue on linux too (red hat 9), though - so I don't believe this is windows specific.

What version of python are you all running the backend with?

❯ python -V
Python 3.8.8

@jellydn
Copy link
Owner

jellydn commented Feb 2, 2024

Just FYI

CopilotChat: require("CopilotChat.health").check()

CopilotChat.nvim health check ~
- OK Python version 3.11 is supported
- OK pynvim version 0.5.0 is supported

@jinzhongjia
Copy link

I don’t know if it can be modified to a plugin like leaderf that does not require rplugin.

@jinzhongjia
Copy link

python : 3.12.1 (I have also tested on 3.10, nothing changes)
pynvim: 0.5.0

@jellydn
Copy link
Owner

jellydn commented Feb 2, 2024

A user faced a similar issue; here is how he fixed it. #43 (comment) I think this is a common issue so I've added to readme the usage, installation, etc but might be not enough. Any suggestions?

@jinzhongjia
Copy link

A user faced a similar issue; here is how he fixed it. #43 (comment) I think this is a common issue so I've added to readme the usage, installation, etc but might be not enough. Any suggestions?

Has no effect on windows

@rossjaywill
Copy link

No effect on my linux instance either

@jellydn
Copy link
Owner

jellydn commented Feb 2, 2024

Wow, how about this? #45 (comment)

@waynebowie99
Copy link

I'm also running into this. I had a couple things run with my install

  1. I had Python 3.9 installed through choco and Python 3.11 installed through another means
    • Neovim was only recognizing 3.9 and was thinking pynvim was not installed
  2. Python 3.11 did not include a python3.exe which the plugin was expecting
    • I fixed this by creating a sym link using New-Item -Path 'C:\Program Files\Python311\python3.exe' -ItemType SymbolicLink -Value 'C:\Program Files\Python311\python.exe'

With these changes, my checkhealth is all green (exactly the same as #25 (comment)) but I am still getting an ambiguous error.

I'm willing to provide help in any way I can

@gptlang
Copy link
Collaborator

gptlang commented Feb 2, 2024

btw from the initial error message: E464

https://superuser.com/questions/1322471/vim-e464-ambiguous-use-of-user-defined-command

Are there multiple commands being registered for the same thing?

@waynebowie99
Copy link

For me, CopilotChat is not registered at all. Here is everything in my command list related to copilot

!   Copilot           ?            <Lua function> <Lua 130: ~/AppData/Local/nvim-data/lazy/copilot.lua/plugin/copilot.lua:8>
    CopilotChatExplain *   .                   <Lua 460: ~/AppData/Local/nvim-data/lazy/CopilotChat.nvim/lua/CopilotChat/init.lua:28>
                                               CopilotChat.nvim CopilotChatExplain
    CopilotChatTests  *    .                   <Lua 461: ~/AppData/Local/nvim-data/lazy/CopilotChat.nvim/lua/CopilotChat/init.lua:28>
                                               CopilotChat.nvim CopilotChatTests

@gptlang
Copy link
Collaborator

gptlang commented Feb 2, 2024

@waynebowie99 Looks like the Python script didn't get loaded.

This is what mine looks like:

    CopilotChat       1                        call remote#define#CommandBootstrap("python3", "/var/home/acheong/.local/sha 
    CopilotChatAutocmd *                       call remote#define#CommandBootstrap("python3", "/var/home/acheong/.local/sha 
    CopilotChatExplain *   .                   <Lua 7: ~/.local/share/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/init.lua:33

Did you :UpdateRemotePlugins? Check ~/.local/share/nvim/rplugin.vim

It should look something like this:

" python3 plugins
call remote#host#RegisterPlugin('python3', '~/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-agent.py', [
      \ {'sync': v:false, 'name': 'CopilotChatVsplit', 'type': 'command', 'opts': {'nargs': '1'}},
      \ {'sync': v:false, 'name': 'CopilotChatVsplitVisual', 'type': 'command', 'opts': {'nargs': '1', 'range': ''}},
      \ {'sync': v:false, 'name': 'CopilotChatInPlace', 'type': 'command', 'opts': {'nargs': '*', 'range': ''}},
      \ {'sync': v:false, 'name': 'CopilotChatAutocmd', 'type': 'command', 'opts': {'nargs': '*'}},
      \ {'sync': v:false, 'name': 'CopilotChatMapping', 'type': 'command', 'opts': {'nargs': '*'}},
     \ ])
call remote#host#RegisterPlugin('python3', '~/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-plugin.py', [
      \ {'sync': v:false, 'name': 'CopilotChat', 'type': 'command', 'opts': {'nargs': '1'}},
     \ ])

@edward-s
Copy link

edward-s commented Feb 3, 2024

I have been trying to get this working on osx for the past 2 hours, tried everything :UpdateRemotePlugins, :checkhealth, ~/.local/share/nvim/rplugin.vim, all good

restarted neovim / OS multiple times

but still getting "Ambiguous use of user-defined command error"

@edward-s
Copy link

edward-s commented Feb 3, 2024

ok I think I have the same issue with @waynebowie99 of CopilotChat not registered in command

this is my ~/.local/share/nvim/rplugin.vim

" python3 plugins
call remote#host#RegisterPlugin('python3', '/Users/edward/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-agent.py', [
      \ {'sync': v:false, 'name': 'CopilotChatVsplit', 'type': 'command', 'opts': {'nargs': '1'}},
      \ {'sync': v:false, 'name': 'CopilotChatVsplitVisual', 'type': 'command', 'opts': {'nargs': '1', 'range': ''}},
      \ {'sync': v:false, 'name': 'CopilotChatInPlace', 'type': 'command', 'opts': {'nargs': '*', 'range': ''}},
      \ {'sync': v:false, 'name': 'CopilotChatAutocmd', 'type': 'command', 'opts': {'nargs': '*'}},
      \ {'sync': v:false, 'name': 'CopilotChatMapping', 'type': 'command', 'opts': {'nargs': '*'}},
     \ ])
call remote#host#RegisterPlugin('python3', '/Users/edward/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-plugin.py', [
      \ {'sync': v:false, 'name': 'CopilotChat', 'type': 'command', 'opts': {'nargs': '1'}},
     \ ])

Update: still no go, I guess I'll stop for now and try again in the future, still, thanks for the plugin

@edward-s
Copy link

edward-s commented Feb 3, 2024

omg it's working now, turns out my rplugin is disabled in lazy config
apparently, it is also disabled in a few neovim distros, i.e: nvchad https://github.com/NvChad/NvChad/blob/8214d4e8589aa6625c6db077b8eb199e7ebc1929/lua/plugins/configs/lazy_nvim.lua#L37

hope this helps someone else!

@jellydn
Copy link
Owner

jellydn commented Feb 3, 2024

omg it's working now, turns out my rplugin is disabled in lazy config apparently, it is also disabled in a few neovim distros, i.e: nvchad NvChad/NvChad@8214d4e/lua/plugins/configs/lazy_nvim.lua#L37

hope this helps someone else!

That's why I pinned 2 other issues. NVChad maintainer also left comment there. #38 (comment)

@edward-s
Copy link

edward-s commented Feb 3, 2024

i completely missed out that other pinned thread, thanks anyways! great plugin!

@jellydn jellydn closed this as completed Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests