Skip to content

Home directory is absolute #1

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

Closed
mikedfunk opened this issue Apr 4, 2022 · 10 comments
Closed

Home directory is absolute #1

mikedfunk opened this issue Apr 4, 2022 · 10 comments

Comments

@mikedfunk
Copy link

local userdata = vim.fn.json_decode(vim.api.nvim_eval("readfile('/home/zach/.config/github-copilot/hosts.json')"))

image

@zbirenbaum
Copy link
Owner

oops one sec

@zbirenbaum
Copy link
Owner

Should be fixed. Packersync and let me know if it works.

@mikedfunk
Copy link
Author

mikedfunk commented Apr 4, 2022

Related problem:

I ran :Copilot setup and it worked

image

But I have no $XDG_CONFIG_HOME/github-copilot/ directory:

image


Edit: ran setup again just to be sure, the directory is still not there :/

@zbirenbaum
Copy link
Owner

zbirenbaum commented Apr 4, 2022

Are you on windows? If so try the patch I just sent out a second ago.

If you are on linux or osx, try going to ~/.config and see if github-copilot is there. It should be.

@mikedfunk
Copy link
Author

No, I'm on MacOS.

Looks like it's in ~/.config, which is probably what $XDG_CONFIG_HOME is intended for.

@mikedfunk
Copy link
Author

I exported $XDG_CONFIG_HOME and now it's timing out after 10 seconds :/

image

@zbirenbaum
Copy link
Owner

No, I'm on MacOS.

Looks like it's in ~/.config, which is probably what $XDG_CONFIG_HOME is intended for.

I just pushed an update a second ago that should default to ~/.config if XDG_CONFIG_HOME is not defined and user isn't on windows. If thats not working let me know.

I'm not sure why the request isn't working. It seems the error is in here:

local function oauth_user(token)
   local response = request({
      url = "https://api.github.com/user",
      headers = {
         Authorization = "Bearer " .. token,
      },
   })
   return json_body(response)
end

But that works fine for me.

If the latest commit fixes pathing stuff on packersync, can you open a new issue for the timeout?

@annenpolka
Copy link

@zbirenbaum Sorry for replying from a closed issue, but I found some problems in find_config_path().

expand('$VARIABLE') will return the literal '$VARIABLE' when the envvar is not defined.
expand($VARIABLE) works as you intended, but there seems no way to do this from Lua vim.fn.expand().

expand("~/AppData/Local") won't check if path exists. It just returns /home/username/AppData/Local even in Linux.

@zbirenbaum
Copy link
Owner

@zbirenbaum Sorry for replying from a closed issue, but I found some problems in find_config_path().

expand('$VARIABLE') will return the literal '$VARIABLE' when the envvar is not defined.

expand($VARIABLE) works as you intended, but there seems no way to do this from Lua vim.fn.expand().

expand("~/AppData/Local") won't check if path exists. It just returns /home/username/AppData/Local even in Linux.

Thanks for the info, I'll add a check to make sure that the dir exists.

I think I could run filereadable on the hosts file using that as the relative path, but I'd prefer to check if the dir actually exists so that it still works once I no longer rely on copilot.vim for the pre-authentication step.

@zbirenbaum
Copy link
Owner

@annenpolka I just pushed a fix using the info you provided. I did a bunch of isdirectory checks and I added a print statement to indicate when none of the above locations were directories, so hopefully it behaves a bit more predictably now. Thanks for the catch!

zbirenbaum pushed a commit that referenced this issue Mar 20, 2025
* feat: update to latest copilot.vim/dist

language server now expects to be run directly through language-server.js

* fix: missing copilot.lua version
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