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

Server extract fails on Windows 11 Powershell because it tries to use gzip #206

Open
dyskette opened this issue Jul 10, 2024 · 2 comments · May be fixed by #231
Open

Server extract fails on Windows 11 Powershell because it tries to use gzip #206

dyskette opened this issue Jul 10, 2024 · 2 comments · May be fixed by #231

Comments

@dyskette
Copy link

Hi 👋

It looks like my installation of codeium in neovim cannot extract the downloaded server gzip file. I saw in another issue that it is supposed to find out if it's currently using powershell and in that case use a script to extract the downloaded archive, but in my case it just fails with the following message:

Error executing vim.schedule lua callback: ...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:108:
gzip: Executable not found                                                                                                                                    stack traceback:
...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:108: in function 'job'
...ata/Local/nvim-data/lazy/codeium.nvim/lua/codeium/io.lua:305: in function 'gunzip'
...Local/nvim-data/lazy/codeium.nvim/lua/codeium/update.lua:130: in function 'unpack'
...Local/nvim-data/lazy/codeium.nvim/lua/codeium/update.lua:149: in function 'callback'
...ata/Local/nvim-data/lazy/codeium.nvim/lua/codeium/io.lua:395: in function 'fn'
vim/_editor.lua:351: in function <vim/_editor.lua:350>
stack traceback:
[C]: in function 'error'
...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:108: in function 'job'
...ata/Local/nvim-data/lazy/codeium.nvim/lua/codeium/io.lua:305: in function 'gunzip'
...Local/nvim-data/lazy/codeium.nvim/lua/codeium/update.lua:130: in function 'unpack'
...Local/nvim-data/lazy/codeium.nvim/lua/codeium/update.lua:149: in function 'callback'
...ata/Local/nvim-data/lazy/codeium.nvim/lua/codeium/io.lua:395: in function 'fn'
vim/_editor.lua:351: in function <vim/_editor.lua:350>

I am using Windows 11 and Powershell Core 7.4.3

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.3
PSEdition                      Core
GitCommitId                    7.4.3
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

I checked if maybe I had some gzip command, and it looks like that is not the case:

Get-Command gzip
Get-Command: The term 'gzip' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I checked in neovim's cmdline trying to find gzip :lua print(vim.fn.executable("gzip")) and it returns 0.

My installation is pretty straightforward, it's basically the same as in the README with the cmp source configured.

return {
	"Exafunction/codeium.nvim",
	dependencies = {
		"nvim-lua/plenary.nvim",
		"hrsh7th/nvim-cmp",
	},
	config = function()
		require("codeium").setup({})
	end,
}

For now, in my local installation I did a small change to fix it.

diff --git a/lua/codeium/io.lua b/lua/codeium/io.lua
index 9f447df..8b1796d 100644
--- a/lua/codeium/io.lua
+++ b/lua/codeium/io.lua
@@ -301,7 +301,8 @@ function M.generate_uuid()
 end

 function M.gunzip(path, callback)
-       if M.executable("gzip") then
+       local gzipAvailable = vim.fn.executable("gzip") == 1
+       if gzipAvailable then
                M.job({
                        "gzip",
                        "-d",

Cheers

@dyskette
Copy link
Author

dyskette commented Jul 10, 2024

BTW, while I'm not too familiar with lua and vim functions, I was testing in the cmdline how lua evaluates vim.fn.executable in an if. It looks like it results in a unintuitive result on Windows, because when vim.fn.executable returns 0 it gets evaluated as true and 1 gets evaluated as false. I think it's necessary to force the comparison to the expected result, e.g. vim.fn.executable("gzip") == 1.

If I'm wrong, just ignore my comment, but I saw others if statements relying on vim.fn.executable as well that probably need some review.

@wr9dg17
Copy link

wr9dg17 commented Aug 4, 2024

I solved it by enabling gzip as executable from CMD. You can install cygwin and add to PATH. Also you can install it with following command: choco install cygwin

@Borwe Borwe linked a pull request Sep 26, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants