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

LanguageServer.jl throws due to missing SHA #987

Closed
Seelengrab opened this issue Oct 2, 2021 · 4 comments
Closed

LanguageServer.jl throws due to missing SHA #987

Seelengrab opened this issue Oct 2, 2021 · 4 comments

Comments

@Seelengrab
Copy link
Contributor

Seelengrab commented Oct 2, 2021

Hi,

I'm trying to use LanguageServer.jl with Kakoune. I'm using the integration detailed in the wiki here, but the language server never finishes initialization. Trying to use the command from the README.md to start the language server quickly shows the following error:

{"method":"telemetry/event",
"params":
{"name":"LSSymbolServerFailure",
  "stacktrace":"",
   "message":"ERROR: LoadError: ArgumentError: Package SHA not found in current path:\n- Run `import Pkg; Pkg.add(\"SHA\")` to install the SHA package.\n\nStacktrace:\n [1] require(into::Module, mod::Symbol)\n   @ Base ./loading.jl:967\nin expression starting at /home/sukera/.julia/packages/SymbolServer/rrlGM/src/server.jl:1\n","command":"symserv_crash"},"jsonrpc":"2.0"}

with the relevant error part being:

ERROR: LoadError: ArgumentError:Package SHA not found in current path:
 Run `import Pkg; Pkg.add(\"SHA\")` to install the SHA package.
 
 Stacktrace:
 [1] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:967\nin expression starting at ~/.julia/packages/SymbolServer/rrlGM/src/server.jl:1

Since SHA is mentioned in [extras] section of the Project.toml, I suspect this has something to do with that.. I thought that section would only be loaded when testing?

My julia version:

julia> versioninfo()
Julia Version 1.7.0-rc1
Commit 9eade6195e (2021-09-12 06:45 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
@Seelengrab
Copy link
Contributor Author

Well adding SHA manually to my main environment made the error go away, but it didn't fix not having any language server features integrated with kakoune... the debug logs are less than helpful since they're empty (even though I tried to amp them up in verbosity) and there's no julia instance to be found when running the language server via kak-lsp directly (I assume it crashes, but I don't get any error messages about that).

@Seelengrab
Copy link
Contributor Author

Thinking about what this is doing some more, the setup suggested in the wiki is fundamentally kaputt - it's assuming the language server is running in the same environment the project is in, which is not and should not be the case.. I'll try to fix this and if I get this running, I'll make a PR here and to the kak-lsp repo, since there is a (similarly broken) config being shipped as a default now.

@Seelengrab
Copy link
Contributor Author

Ok, not using the plug.kak version of kak-lsp and instead using one provided by pacman seems to work, insofar that I get linting & communication seems to work, but the language server can't seem to be able to find all required references.. The logs I could manage to be spit out are claiming the symbol server crashed due to not having SHA available, could this be the cause?

I've had similar problems when using VSCode in the past, is this just super fragile or am I doing something horribly wrong?

In case it helps, here is how I start/interact with the language server:

My kak-lsp config for julia:

[language.julia]
filetypes = ["julia"]
roots = [".git"]
command = "julia"
args = [
        "--startup-file=no",
        "--history-file=no",
        "-e",
        """
                import Pkg
                using Logging
                @info "Opening scratch space..."
                Pkg.activate(;temp=true)
                Pkg.add("Scratch")
                using Scratch
                download_cache = @get_scratch!("Kakoune_LSP_cache")
                @info "Got scratch space at '$download_cache'"
                Pkg.activate(download_cache)
                @info "Activating environment for LSP"
                Pkg.add(["SHA","LanguageServer"]) # have to add SHA explicitly to make the SymbolServer not throw
                using LanguageServer, LanguageServer.SymbolServer
                @info "Using parent environment as linting environment"
                runserver()
        """,
        ]

I'm using Scratch.jl to isolate the LSP environment from the main/project environment. This seems to work fine, but the symbol server isn't doing its work properly - I receive a boatload of Missing Reference for any type/function defined in a different file than the currently open one (it doesn't seem to follow include?).

With the config above, I start kakoune like this, in e.g. ~/project/Project.jl, which has a Project.toml:

kak src/File.jl

After a few seconds, even though I get syntax highlighting, I also get the aforementioned boatload of Missing Reference warnings.

@Seelengrab
Copy link
Contributor Author

ok, smaller example, directly using SymbolServer.jl and now I'm even more confused:

julia> srv = SymbolServer.SymbolServerInstance()
SymbolServerInstance(nothing, "", Set{Base.Process}(), "/home/sukera/.julia/packages/SymbolServer/rrlGM/store")

julia> s = getstore(srv, "/home/sukera/projects/
BigNums.jl/   PropCheck.jl/
julia> s = getstore(srv, "/home/sukera/projects/BigNums.jl/")
(:failure, IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=305, maxsize=Inf, ptr=306, mark=-1))

julia> s[2]
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=305, maxsize=Inf, ptr=306, mark=-1)

julia> msg = String(take!(s[2]))
"ERROR: LoadError: ArgumentError: Package SHA not found in current path:\n- Run `import Pkg; Pkg.add(\"SHA\")` to install the SHA package.\n\nStacktrace:\n [1] require(into::Module, mod::Symbol)\n   @ Base ./loading.jl:967\nin expression starting at /home/sukera/.julia/packages/SymbolServer/rrlGM/src/server.jl:1\n"

Since this doesn't seem to be related to LanguageServer.jl itself, I'll open an issue over at SymbolServer.jl

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

1 participant