supermaven-inc / supermaven-nvim

The official Neovim plugin for Supermaven
https://supermaven.com/
MIT License
305 stars 16 forks source link

[lazy.nvim] Failed to run `config` for supermaven-nvim - downloadUrl #19

Closed jakevollkommer closed 2 weeks ago

jakevollkommer commented 1 month ago

Using the default config for the lazy setup. Getting this stack trace:

Failed to run `config` for supermaven-nvim

{"downloadUrl":"https://supermaven-public.s3.amazonaws.com/sm-agent/22/darwin/arm64/sm-agent","version":22,"sha256Hash":"3295027da01c41caefcd153f025241e2c9a4da038483baefd6729fa99e9feed7"}

# stacktrace:
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_fetcher.lua:41 _in_ **discover_binary_url**
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_fetcher.lua:63 _in_ **fetch_binary**
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_handler.lua:9
  - /supermaven-nvim/lua/supermaven-nvim/init.lua:1
  - ~/.config/nvim/lua/jake/lazy/supermaven.lua:5 _in_ **config**
  - ~/.config/nvim/lua/jake/lazy_init.lua:14
  - ~/.config/nvim/lua/jake/init.lua:3
  - ~/.dotfiles/config/nvim/init.lua:1
sm-victorw commented 1 month ago

Seems to be erroring out on local json = vim.fn.json_decode(response), where response is the string containing downloadUrl. Could you include the Neovim version and operating system this occurred on?

jakevollkommer commented 1 month ago

NVIM v0.9.5 MacOS Sonoma 14.4.1 (23E224) (ARM Silicon chip)

AlejandroSuero commented 1 month ago

@jakevollkommer I made the changes for this issue in #22.

I also use MacOS 14.4.1 and Neovim v0.9.5 so I tested it.

AlejandroSuero commented 1 month ago

@jakevollkommer How have you installed Neovim? Because I can't reproduce the same issue as you, and how is your lazy.nvim setup? I want to be able to try and reproduce it.

-- ~/.config/nvim/init.lua or in a minimal.lua and run:
-- nvim --clean -u minimal.lua
local lazypath = "/tmp/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
    {
      "supermaven-inc/supermaven-nvim",
      config = function()
          require("supermaven-nvim").setup({})
      end,
    },
}, {})

You can use this minimal setup to test if it works for you this way.

jakevollkommer commented 1 month ago

my setup is a bit complicated: init.lua is just

require("jake")

lua/jake/init.lua

require("jake.lazy_init")

lua/jake/lazy_init.lua

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    spec = "jake.lazy",
    change_detection = { notify = false }
})

and finally lua/jake/lazy/supermaven.lua

return {
    {
      "supermaven-inc/supermaven-nvim",
      config = function()
        require("supermaven-nvim").setup({})
      end,
    },
}
jakevollkommer commented 1 month ago

at the end of the day, though, the setup is quite the same

AlejandroSuero commented 1 month ago

@jakevollkommer I am guessing that require("lazy").setup({ spec = "..." }) works the same as to use require("lazy").setup({ import = "..." }).

I tested it in my end with the kind of setup that you have an couldn't get the error to show.

I have this Neovim version built from source if it helps:

NVIM v0.9.5
Build type: RelWithDebInfo
LuaJIT 2.1.1692716794
Compilation: /Library/Developer/CommandLineTools/usr/bin/cc -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -I/Users/aome/neovim/.deps/usr/include/luajit-2.1 -I/opt/homebrew/opt/gettext/include -I/Users/aome/neovim/.deps/usr/include -I/Users/aome/neovim/build/src/nvim/auto -I/Users/aome/neovim/build/include -I/Users/aome/neovim/build/cmake.config -I/Users/aome/neovim/src -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include -I/Users/aome/neovim/.deps/usr/include -I/Users/aome/neovim/.deps/usr/include -I/Users/aome/neovim/.deps/usr/include -I/Users/aome/neovim/.deps/usr/include -I/Users/aome/neovim/.deps/usr/include -I/Users/aome/neovim/.deps/usr/include
jakevollkommer commented 1 month ago

Oh sorry, nvim was installed with homebrew. I'll try your min config tomorrow

AlejandroSuero commented 1 month ago

@jakevollkommer I was going to try installing from homebrew but they just updated to Neovim v0.10.0 and brew install neovim@0.9.5 doesn't work, with v0.10.0 I didn't have any problems so far.

jakevollkommer commented 1 month ago

Just upgraded to v0.10.0 and changed my init.lua to this:

-- ~/.config/nvim/init.lua or in a minimal.lua and run:
-- nvim --clean -u minimal.lua
local lazypath = "/tmp/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
    {
      "supermaven-inc/supermaven-nvim",
      config = function()
          require("supermaven-nvim").setup({})
      end,
    },
}, {})

but I still get the error

Failed to run `config` for supermaven-nvim

{"downloadUrl":"https://supermaven-public.s3.amazonaws.com/sm-agent/22/darwin/arm64/sm-agent","version":22,"sha256Hash":"32905027da01c41caefcd153f025241e2c9a4da038483baefd6729fa99e9feed7"}

# stacktrace: 
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_fetcher.lua:41 _in_ **discover_binary_url**
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_fetcher.lua:63 _in_ **fetch_binary**
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_fetcher.lua:9
  - /supermaven-nvim/lua/supermaven-nvim/init.lua:1
  - init.lua:20 _in_ **config**
  - init.lua:16
jakevollkommer commented 1 month ago
nvim --version

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info
sw_vers

ProductName:            macOS
ProductVersion:         14.4.1
BuildVersion:           23E224
AlejandroSuero commented 1 month ago

@jakevollkommer can you test the following (from the vim command mode :lua ...):

local json = '{"downloadUrl":"https://supermaven-public.s3.amazonaws.com/sm-agent/22/darwin/arm64/sm-agent","version":22,"sha256Hash":"32905027da01c41caefcd153f025241e2c9a4da038483baefd6729fa99e9feed7"}'
print(vim.inspect(vim.fn.json_decode(json))) -- if this fails try the next one
print(vim.inspect(vim.json.decode(json)))

[!NOTE]

You can create a .lua file with this and run it with :luafile % or :source %, if you think is more convenient than trying it directly in command mode :lua ....

it should result in a table like:

{
  downloadUrl = "https://supermaven-public.s3.amazonaws.com/sm-agent/22/darwin/arm64/sm-agent",
  sha256Hash = "32905027da01c41caefcd153f025241e2c9a4da038483baefd6729fa99e9feed7",
  version = 22
}

I found this issue that may be the solution to the problem.

[!NOTE]

I changed vim.fn.json_decode(response) with vim.json.decode(response) in my end and still works as expected, so maybe this fixes it.

romeovs commented 1 month ago

I'm not @jakevollkommer but I'm running into the same issues.

I'm on:

$ nvim --version
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info

# sw_vers
ProductName:        macOS
ProductVersion:     14.2.1
BuildVersion:       23C71

Running

local json = '{"downloadUrl":"https://supermaven-public.s3.amazonaws.com/sm-agent/22/darwin/arm64/sm-agent","version":22,"sha256Hash":"32905027da01c41caefcd153f025241e2c9a4da038483baefd6729fa99e9feed7"}'
print(vim.inspect(vim.fn.json_decode(json))) -- if this fails try the next one
print(vim.inspect(vim.json.decode(json)))

works (both versions work for me).

And yet I get the same error @jakevollkommer gets:

Failed to run `config` for supermaven-nvim

Vim:E474: Unidentified byte: ^[[3g^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H
 ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[
H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H^M{"downloadUrl":"https://supermaven-publi
c.s3.amazonaws.com/sm-agent/23/darwin/arm64/sm-agent","version":23,"sha256Hash":"9746c9acaea5
7d2b08ae2360bae4775d32abef6ac30c682570bd7162daaf9f56"}

# stacktrace:
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_fetcher.lua:52 _in_ **discover_binary_
url**
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_fetcher.lua:74 _in_ **fetch_binary**
  - /supermaven-nvim/lua/supermaven-nvim/binary/binary_handler.lua:9
  - /supermaven-nvim/lua/supermaven-nvim/init.lua:1
  - lua/plugin/supermaven.lua:4 _in_ **config**
  - init.lua:5

I think it is because:

:lua print(vim.fn.system("curl -s 'https://supermaven.com/api/download-path?platform=macosx&arch=aarch64&editor=neovim'"))

returns

^M^[[3g^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^
[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H
 ^[H  ^[H  ^[H  ^[H  ^[H^M{"downloadUrl":"https://supermaven-public.s3.amazonaws.com/sm-agent
/23/darwin/arm64/sm-agent","version":23,"sha256Hash":"9746c9acaea57d2b08ae2360bae4775d32abef6
ac30c682570bd7162daaf9f56"}

There are some leading weird bytes in there for some reason.

The same thing happens with

:lua print(vim.fn.system("echo hello"))

as it prints

^M^[[3g^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^
[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H  ^[H
 ^[H  ^[H  ^[H  ^[H  ^[H^Mhello

This one does work:

:lua print(vim.fn.system({"echo", "hello"}))

prints

hello
claudeloba commented 1 month ago

NvChad user here, running into the same issue. Using NVIM v0.9.5.

"Failed to run config for supermaven-nvim

Vim:E474: Unidentified byte: ....

Windows 11 Home - v. 23H2 12th Gen Intel(R) Core(TM) i7-12700H

AlejandroSuero commented 1 month ago

@jakevollkommer @claudeloba With the merge of #34 is this issue resolved?

jakevollkommer commented 1 month ago

@AlejandroSuero are there any config changes to make to include this PR? From the default config, still having the error.

jakevollkommer commented 1 month ago

using :lua print(vim.fn.system("curl -s 'https://supermaven.com/api/download-path?platform=macosx&arch=aarch64&editor=neovim'")) I do get {"downloadUrl":"https://supermaven-public.s3.amazonaws.com/sm-agent/24/darwin/arm64/sm-agent","version":24,"sha256Hash":"ff756b087232cb4701f5c304e81ce3dc06630b31ea5e107c02848e322830287b"} which seems correct however I still get the same error sadly

AlejandroSuero commented 1 month ago

@jakevollkommer I would try removing supermaven's directory with rm -rf ~/.supermaven and If it still errors, paste the error here, and try using a VM with a MacOS to see if errors the same way.

Also try to the following:

It should print this:

{
  downloadUrl = "https://supermaven-public.s3.amazonaws.com/sm-agent/24/darwin/arm64/sm-agent",
  sha256Hash = "ff756b087232cb4701f5c304e81ce3dc06630b31ea5e107c02848e322830287b",
  version = 24
}

Here is my curl version using the default installed curl (/usr/bin/curl):

> curl --version
curl 8.6.0 (x86_64-apple-darwin23.0) libcurl/8.6.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.61.0
Release-Date: 2024-01-31
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets
JStav commented 1 month ago

Just chiming in, in case this helps debug. I had a similar issue, I got an error trying to download the binary.

Added a supermaven.lua file to my plugins with the following:

return {
  "supermaven-inc/supermaven-nvim",
}

Got the error. Changed my Lua file to:

return {
  "supermaven-inc/supermaven-nvim",
  config = function()
    require("supermaven-nvim").setup({})
  end,
}

Was still getting the error.

Deleted the ~/.supermaven directory and restarted Neovim. Problem fixed!

romeovs commented 1 month ago

As a follow up, I found the culprit for the weird characters being added to the result of the spawned command. I was seeing the same problem in other programs too.

I'm using fish shell and my fish config had:

tabs -2

This would cause fish to inject characters even if the shell is not interactive.

Changing the config to:

# Set tab width
if status --is-interactive
  tabs -2
end

fixed the problem.

This is unrelated to neovim, but other users might find it useful.

jakevollkommer commented 3 weeks ago

Just chiming in, in case this helps debug. I had a similar issue, I got an error trying to download the binary.

Added a supermaven.lua file to my plugins with the following:

return {
  "supermaven-inc/supermaven-nvim",
}

Got the error. Changed my Lua file to:

return {
  "supermaven-inc/supermaven-nvim",
  config = function()
    require("supermaven-nvim").setup({})
  end,
}

Was still getting the error.

Deleted the ~/.supermaven directory and restarted Neovim. Problem fixed!

Hey all, sorry for late response. After rm -rf ~/.supermaven and copy/pasting the above config, still getting the same error. :/

I ran :lua print(vim.inspect(vim.fn.json_decode(vim.fn.system({ "curl", "-s", "https://supermaven.com/api/download-path?platform=macosx&arch=aarch64&editor=neovim" })))) again and got the following:

{
  downloadUrl = "https://supermaven-public.s3.amazonaws.com/sm-agent/24/darwin/arm64/sm-agent",
  sha256Hash = "ff756b087232cb4701f5c304e81ce3dc06630b31ea5e107c02848e322830287b",
  version = 24
}

curl --version

Release-Date: 2023-10-11
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets

actually not sure how to upgrade the system installed curl at /usr/bin/curl?

AlejandroSuero commented 3 weeks ago

@jakevollkommer I think updating the system and Xcode should be enough. At least I don't do anything fancier than that when it comes to system default dependencies.

jakevollkommer commented 2 weeks ago

@AlejandroSuero upgraded to grep 2.6.0, error persists

jakevollkommer commented 2 weeks ago

also tried the minimal default config, no luck still :/ might have to give up tbh

AlejandroSuero commented 2 weeks ago

@jakevollkommer I will try brew install curl and then removing ~/.supermaven to see if it does the trick.

sm-victorw commented 2 weeks ago

@jakevollkommer I wish I could be of more help but I have tried with the same OS, arch and Neovim version and have not been able to replicate this.

I'm very surprised to hear that :lua print(vim.inspect(vim.fn.json_decode(vim.fn.system({ "curl", "-s", "https://supermaven.com/api/download-path?platform=macosx&arch=aarch64&editor=neovim" })))) runs fine in Neovim but the plugin setup doesn't, as this line of code seems to be the same thing that is run by the plugin

If you would like to continue debugging this would you be able to clone the repo and have your plugin manager point to the local directory? I'm curious what would happen if you were to replace line 64 of binary_fetcher, local json = vim.fn.json_decode(response) with this line that apparently works? e.g. have local json = vim.fn.json_decode(vim.fn.system({ "curl", "-s", "https://supermaven.com/api/download-path?platform=macosx&arch=aarch64&editor=neovim" }))

jakevollkommer commented 2 weeks ago

Sure, I can try that. Not actually sure how to point lazy.nvim at a local dir but can look it up later

sm-victorw commented 2 weeks ago

It would just be { dir = "~/path/to/plugin", config = function() require("supermaven-nvim").setup({}) end, } so just the regular config but with "supermaven-inc/supermaven-nvim", replaced with dir = "~/path/to/plugin",

jakevollkommer commented 2 weeks ago

that worked 🫠

jakevollkommer commented 2 weeks ago

Didn't make any changes at all to the cloned repo

sm-victorw commented 2 weeks ago

That's quite strange, I don't have enough of an understanding of lazy.nvim to understand why reading the plugin locally should be any different from pointing to it remotely

AlejandroSuero commented 2 weeks ago

@jakevollkommer maybe it wasn't up to date or something, if not, some weird interaction with the cache probably.


Side note:

If you want to have lazy setup so you can do this kind of thing more often, I recommend this setup:

-- your lazy config file
require("lazy").setup({
  -- your config options...
  dev = {
    path = vim.env.HOME .. "path/to/plugin",
    fallback = true
  },
})
-- plugin config
{
  "supermaven-inc/supermaven-nvim",
  dev = true,
  -- ...
}

This way, if dev = true it will pick up the cloned repo and if you change branches it will pick up the branch you are working on.

More information about this:

jakevollkommer commented 2 weeks ago

I figured any cache would be in ~/.supermaven, no? Unless you mean lazy cache or nvim cache?

FWIW, I just removed the dir key and instead set it back to supermaven-inc/supermaven-nvim and now it's working 🚀

I guess it just had trouble downloading initially, but now it's linked