qiuxiang / coc-solidity

Solidity language server for coc.nvim
MIT License
49 stars 0 forks source link

Server fails to run and crashes until won't restart #12

Closed ekr990011 closed 2 years ago

ekr990011 commented 2 years ago

I'm on arch and I am trying to get coc-solidity to work with nvim.

I have installed the regular arch binaries for solc: yay -S solidity whereis solc /usr/bin/solc

Upon running a solidity file I get the error: The "solidity" server crashed 4 times in 3 minutes. The server will not be restarted

My :CocCommand workspace.showOutput

node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:817:11)
    at Socket._write (node:net:829:8)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at Socket.Writable.write (node:internal/streams/writable:334:10)
    at /home/doom/.config/coc/extensions/node_modules/coc-solidity/node_modules/solidity-ls/dist/index.js:78:17
    at new Promise (<anonymous>)
    at compile (/home/doom/.config/coc/extensions/node_modules/coc-solidity/node_modules/solidity-ls/dist/index.js:43:10)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

I have tried without the arch package for solidity as well by directly downloading from the sources linked to in the README.md. Once I do that I simply recieve: [coc.nvim] spawn solc ENOENT

I have tried setting up my CocConfig with this to point to the directly downloaded binary:

{
    "languageserver": {
        "solidity": {
            "command": "~/Downloads/solc-static-linux",
            "args": [ "--lsp" ],
            "trace.server": "verbose",
            "rootPatterns": [".git/"],
            "filetypes": ["solidity", "sol"]
        }
    }
}

I got that suggestion for: https://dev.to/christianparpart/builtin-solidity-language-server-267n Syntax errors show up but nothing from coc-solidity

Any suggestions?

qiuxiang commented 2 years ago

i also use arch, what is your solc version?

$ solc --version
solc, the solidity compiler commandline interface
Version: 0.8.15+commit.e14f2714.Linux.g++
rodrigo-pino commented 2 years ago

I run arch as well and when I execute

solc --version

I get:

solc: error while loading shared libraries: libz3.so.4.8: cannot open shared object file: No such file or directory

This is what provoking the server to crash on my machine. Can an option be added to modifiy which solc binary to use (and avoid using the system one for now)

ekr990011 commented 2 years ago

I get:

solc: error while loading shared libraries: libz3.so.4.8: cannot open shared object file: No such file or directory

This is what provoking the server to crash on my machine. Can an option be added to modifiy which solc binary to use (and avoid using the system one for now)

^ That is also what I get. It seems to imply we do not have libz3 4.8

I checked and I have: Packages (1) z3-4.9.0-1

ekr990011 commented 2 years ago

Possible solution but I am a coc noob so do double check for me @rodrigo-pino

If you have the downgrade package installed you can do: sudo downgrade z3 I chose 4.8.17, I was wary to put it in the Ignorepkg yet as it appears the solidity package needs to be updated and may be sometime fairly soon in the future.

After I did that I get:

❯ solc --version
solc, the solidity compiler commandline interface
Version: 0.8.15+commit.e14f2714.Linux.g++

No more crashing of the server. It does seem to auto-complete things like struct/uint now. Now I just need to learn to actually use coc better :P

qiuxiang commented 2 years ago

my solution is sudo ln -s /usr/lib/libz3.so.4.9 /usr/lib/libz3.so.4.8

ekr990011 commented 2 years ago

That should work too, thanks for taking the time, really appreciate it! :)