teal-language / vscode-teal

Teal language support for Visual Studio Code
MIT License
76 stars 11 forks source link

Language Server cannot start with local tl installation #4

Closed octacian closed 11 months ago

octacian commented 4 years ago

After manually installing the extension I discovered that the language server doesn't start up correctly if the tl package is installed to the local LuaRocks tree via luarocks install --local tl. Instead, it fails with the following reason:

[Info  - 5:19:27 PM] Connection to server got closed. Server will restart.
events.js:177
      throw er; // Unhandled 'error' event
      ^

Error: spawn tl ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn tl',
  path: 'tl',
  spawnargs: [ 'check', '/tmp/tmp-320698azbtbUp7T3xE' ]
}
[Error - 5:19:27 PM] Connection to server got closed. Server will not be restarted.

Installing tl globally via sudo luarocks install tl solves the problem.

pdesaulniers commented 4 years ago

Thanks for reporting. This should be handled more gracefully.

Right now, the extension simply calls whichever tl it finds in the $PATH. So, this issue should be fixed by appending <your home folder>/.luarocks/bin/ to the $PATH variable.

As per this wiki page, assuming you're using Bash, you can add eval $(luarocks path --bin) to ~/.bashrc to take care of this.

pdesaulniers commented 4 years ago

With commit https://github.com/pdesaulniers/vscode-teal/commit/ba37a765837bf72570d44925a2997b3637340b63, the server should not crash when tl cannot be found.

The next step will be to add a configuration key to customize the path of the tl executable. Also, maybe the extension should look for tl in multiple places before giving up...

pdesaulniers commented 3 years ago

Since https://github.com/teal-language/vscode-teal/commit/e324c9904ca480a0ccbab44849298ce14c52cae3, the compiler's path can be customized using the Teal > Compiler Path setting.

image

I think this issue can be closed now!

MikuAuahDark commented 1 year ago

Hello, is this change available in VS Code Extensions Marketplace?

pdesaulniers commented 1 year ago

Hello! No, unfortunately, I canceled this change at some point, since it was a bit misleading :(

Last time I checked, tl's launcher script was programmed to load the first tl.lua it finds in the LUA_PATH, rather than the one in the same directory as the launcher script. So, in some circumstances, the compiler defined in the Teal > Compiler Path setting would not match the one that tl actually uses...

With that said, it seems like this behavior has been changed in the compiler, so it might be possible to reimplement this setting: https://github.com/teal-language/tl/blob/098780faa1220c6028257270ea9c197a273c2004/tl#L3-L15

MikuAuahDark commented 1 year ago

Alright, looking forward to it, thanks.

pdesaulniers commented 1 year ago

Another option would be to bundle tl along with the extension. So, by default, the extension would not depend on tl being installed; it would simply use its own build of the compiler. Would that be OK for your use case?

MikuAuahDark commented 1 year ago

For now I used the prebuilt binaries of Teal (tl.exe) and put it somewhere accessible by VSCode (through my PATH). While bunding the extension is also a good idea, the extension must be updated when new version of Teal is released.

mundusnine commented 1 year ago

Another option would be to bundle tl along with the extension. So, by default, the extension would not depend on tl being installed; it would simply use its own build of the compiler. Would that be OK for your use case?

The initial solution you implemented would be ideal imho. The reason being that it would enable support for monorepos were the repos could have a specific version of teal versioned. Also, if users of teal embed it into their own binaries, they could supply the path to their binary that embeds teal.

eigenbom commented 1 year ago

To +1 this I'd appreciate being able to set the path to the tl compiler rather than having it in my global PATH. Can we re-open this issue?

pdesaulniers commented 1 year ago

OK, let's reopen the issue :)

It should be a matter of reverting this commit and publishing a new release: https://github.com/teal-language/vscode-teal/commit/922a03e785c07e0cc4bbd1a43b4b0d6d02131fdb

pdesaulniers commented 11 months ago

The teal.compilerPath setting has been re-added in version v0.9.0.