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

No GitHub token found. #409

Closed
mvds314 opened this issue Sep 13, 2024 · 7 comments · Fixed by #410
Closed

No GitHub token found. #409

mvds314 opened this issue Sep 13, 2024 · 7 comments · Fixed by #410
Labels
bug Something isn't working

Comments

@mvds314
Copy link

mvds314 commented Sep 13, 2024

I am using this plugin under Windows 11 (Neovim 0.10.1) and the copilot.vim plugin.

I keep gettting the following error:

No GitHub token found, please use :Copilot auth to set it up from copilot.lua or :Copilot setup for copilot.vim

Copilot itself works.
On my Linux machine, the plugin does work with this config.

I use the following config for the plug:

{
    "CopilotC-Nvim/CopilotChat.nvim",
    branch = "canary",
    dependencies = {
      -- { "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
      { "github/copilot.vim" },
      { "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
    },
    -- build = "make tiktoken", -- Only on MacOS or Linux
    -- build = vim.fn.has("win32") == 1 and "powershell -ExecutionPolicy Bypass -File Build-LuaTiktoken.ps1" or "make"
    -- opts = {
    -- debug = true, -- Enable debugging
    -- See Configuration section for rest
    -- },
    config = function()
      require("CopilotChat").setup {
        debug = true, -- Enable debugging
        -- See Configuration section for rest
      }
    end,
    lazy = false,
    -- See Commands section for default commands if you want to lazy load on them
},

My complete config can be found here .

I tried a couple of things:

  • enable/disable the tiktoken
  • Reinstall the plugin
  • Reinstall copilot.vim

Anyone any ideas on how I can make this plugin work?

@deathbeam deathbeam added the bug Something isn't working label Sep 13, 2024
@acheong08
Copy link

Does ~/.config/github-copilot/hosts.json exist?

@mvds314
Copy link
Author

mvds314 commented Sep 13, 2024

Yes, on my windows machine it's located under: c:\Users\MyUsername\AppData\Local\github-copilot\hosts.json

It has the following content:

{"github.com":{"user":"<my_github_username>","oauth_token":""}}

Only my linux machine it looks the same, only the token is different.

@acheong08
Copy link

acheong08 commented Sep 13, 2024

https://github.com/CopilotC-Nvim/CopilotChat.nvim/blob/d43fab67c328946fbf8e24fdcadfdb5410517e1f/lua/CopilotChat/copilot.lua#L78C16-L114

Could it be how the paths are separated? Your setup looks about right to me.

@mvds314
Copy link
Author

mvds314 commented Sep 13, 2024

I don't know, my programming knowledge within the neovim infrastructure is limited.
What I do know is that, under windows, ~ does not redirect to the home folder. Maybe it does if you use it in lua when writing neovim plugins.

To test it, can I call this function in Neovim like this?

:lua require("CopilotChat.copilot").find_config_path()

@mvds314
Copy link
Author

mvds314 commented Sep 13, 2024

Okay, slowly getting there... I just manually changed the line 83 config = vim.fn.expand('~/AppData/Local')
Copilot thinks it should be this ;-)
config = vim.fn.expand('$LOCALAPPDATA')

Now I'm getting another error:

Failed to get response: {
exit = 35,
message = 'get https://api.github.com/copilot_internal/v2/token - curl error exit_code=35 stderr={ "curl: (35) schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate." }',
stderr = '{ "curl: (35) schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate." }'
}

@mvds314
Copy link
Author

mvds314 commented Sep 15, 2024

Solution to the curl problem can be found here.
Just set: allow_insecure = true

This means replacing line 83, as described in the previous post, indeed solves this bug.

deathbeam added a commit to deathbeam/CopilotChat.nvim that referenced this issue Sep 15, 2024
Also use $HOME instead of ~ as its more friendly for expansion on different OS.

Fixes CopilotC-Nvim#409

Signed-off-by: Tomas Slusny <[email protected]>
@deathbeam
Copy link
Collaborator

Alright, created PR for the fix (with fallback to original value when not found)

deathbeam added a commit to deathbeam/CopilotChat.nvim that referenced this issue Sep 16, 2024
Also use $HOME instead of ~ as its more friendly for expansion on different OS.

Fixes CopilotC-Nvim#409

Signed-off-by: Tomas Slusny <[email protected]>
deathbeam added a commit that referenced this issue Sep 16, 2024
Also use $HOME instead of ~ as its more friendly for expansion on different OS.

Fixes #409

Signed-off-by: Tomas Slusny <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants