rage / tmc-vscode

TestMyCode extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=moocfi.test-my-code
MIT License
25 stars 6 forks source link

TMC plugin not working in NixOS #705

Open JeztC opened 10 months ago

JeztC commented 10 months ago

Describe the bug TMC extension is not working on NixOS, and doesn't let me login or choose courses with the extension.

To Reproduce Steps to reproduce the behavior:

  1. Download TMC plugin from the extensions
  2. Click the TMC plugin menu to open it
  3. Error appears in the output

Expected behavior Normally the extension would let the user login to TMC.

Screenshots nix

Desktop (please complete the following information):

TMC Extension logs

[2024-01-06 10:45:34:090] [INFO] VSCodium version: 1.84.2
[2024-01-06 10:45:34:090] [INFO] moocfi.test-my-code version: 2.2.4
[2024-01-06 10:45:34:090] [INFO] Currently open workspace: CsharpProject
[2024-01-06 10:45:34:090] [INFO] Platform linux Arch x64
[2024-01-06 10:45:34:090] [INFO] TMC-Langs version: tmc-langs-cli-x86_64-unknown-linux-gnu-0.36.0
[2024-01-06 10:45:34:091] [INFO] Running "/home/jesse/.config/VSCodium/User/globalStorage/moocfi.test-my-code/cli/tmc-langs-cli-x86_64-unknown-linux-gnu-0.36.0" "tmc" "--client-name" "vscode_plugin" "--client-version" "2.2.4" "logged-in"
[2024-01-06 10:45:34:091] [DEBUG] Backend at https://tmc.mooc.fi
[2024-01-06 10:45:34:091] [DEBUG] Config dir at undefined
[2024-01-06 10:45:34:094] [DEBUG] stderr
Could not start dynamically linked executable: /home/jesse/.config/VSCodium/User/globalStorage/moocfi.test-my-code/cli/tmc-langs-cli-x86_64-unknown-linux-gnu-0.36.0
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld

[2024-01-06 10:45:34:094] [ERROR] Failed to check if authenticated:
Langs process ended without result data.
[2024-01-06 10:45:34:094] [ERROR] The above error may have been caused by an interfering antivirus program. Please add an exception for the following folder:
/home/jesse/.config/VSCodium/User/globalStorage/moocfi.test-my-code/cli
[2024-01-06 10:45:34:095] [ERROR] Error during initialization: Empy Langs Response Error: Langs process ended without result data.
Heliozoa commented 9 months ago

Sorry to get back to you late.

The extension uses an additional CLI binary for some of its functionality (https://github.com/rage/tmc-langs-rust) and we haven't considered NixOS support for it before since it hasn't come up, but we'd like to support it if we can.

I was unable to find a good solution for distributing a precompiled binary for NixOS, though possibly just because I'm not familiar with Nix. Seems like the preferred method is to compile the programs yourself? I haven't come up with a good way to integrate that with the extension, if you're well versed with nix and have some thoughts let me know. Currently, we just identify the the platform the extension is running on and download the appropriate executable from our servers.

For now, I've committed a default.nix file for the CLI. If you clone the repository (https://github.com/rage/tmc-langs-rust), build it with nix and replace the executable at the path in the error message, it should hopefully work without issues. If something is off with the default.nix file, an issue or PR is appreciated too.

Starting from the next release of the CLI, we'll also publish a version of the binary that should work on NixOS, but will not work on Java extensions (the binary will be built targeting musl, which doesn't support dynamic linking which the Java support relies on). The next release of the extension after that would then add logic to download the musl build if NixOS is detected.