continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
19.23k stars 1.66k forks source link

Doesn't work in NixOS #821

Open utkukaratas opened 9 months ago

utkukaratas commented 9 months ago

Before submitting your bug report

Relevant environment info

- OS: NixOS (unstable)
- Continue: v0.8.2
- IDE: VSCODE

Description

VS Code plugin logs:

Activation Event:onStartupFinished Activation Time:83ms

libstdc++.so.6: cannot open shared object file: No such file or directory

To reproduce

No response

Log output

No response

Geezus42 commented 9 months ago

How did you configure VSCode? Could you share the relevant portion?

functorism commented 9 months ago

Can confirm I'm seeing the same issue on NixOS:

Error: libstdc++.so.6: cannot open shared object file: No such file or directory
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1869)

This is a Nix specific distribution problem to solve, and I'd take a look at building the extension with https://github.com/nix-community/nix-vscode-extensions to resolve the issue. I havent' tried this yet, but will report back when I have time to.

Raroh73 commented 9 months ago

I'm using home-manger's VS Code module and this code works for me:

(pkgs.vscode-utils.buildVscodeMarketplaceExtension {
  mktplcRef = {
    name = "continue";
    publisher = "Continue";
    version = "0.9.61";
    sha256 = "f3538fff6a5f2b5c354e1227907e9ad3127d8fecf3940ddf15598f17f144c14e";
    arch = "linux-x64";
  };
  nativeBuildInputs = [
    pkgs.autoPatchelfHook
  ];
  buildInputs = [ pkgs.stdenv.cc.cc.lib ];
})

It patches binary ELFs for NixOS.

Edit: If there is demand then I can make PR to nixpkgs.

Edit 2: I made PR to NixOS that adds VS Code extension: https://github.com/NixOS/nixpkgs/pull/289289.

ic4-y commented 8 months ago

@Raroh73 I should say this does NOT work for me as is. I just get "Error activating the Continue extension" when starting VSCode. Not sure what is going on there, the log file is empty. Do you have any other config to share to make this work?

Raroh73 commented 8 months ago

@icodeforyou-dot-net It's all code that I'm using for this extension. I'm not sure why it doesn't work for you but I will try to help. Do you use same version that I specified or different one?

ic4-y commented 8 months ago

Thanks @Raroh73

Yeah, I just added your code snippet to to my programs.vscode.extensions list for home manager. I also tried the newest version. But same things occurs. I also tried to delete all the cached stuff that VSCode might have left somewhere. Not sure I got all of it, but it seems I got most of it at least.

Did you set any custom models or something in settings.json or something like that? In my case the extension appears in the side bar, but I just get a loading animation when opening it. When clicking on the button "Toggle Full Screen" I get a number of error messages. I made a screenshot of those.

Screenshot from 2024-02-20 13-37-22

Edit: I guess for some reason it cannot open the config.json which it needs.

Also the error when activating extension appears to be this from the VSCode debug console. Obviously having a read-only filesystem is somewhat to be expected on NixOS:

[Extension Host] Error activating extension:  Error: EROFS: read-only file system, open '/home/ap/.vscode/extensions/Continue.continue/continue_tutorial.py'
    at Object.openSync (node:fs:605:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:2131)
    at Object.writeFileSync (node:fs:2345:35)
    at showTutorial (/nix/store/s5xl38py78xr7xlgp26w31a6xhx2jnkm-vscode-extension-Continue-conti…e-0.9.67/share/vscode/extensions/Continue.continue/out/extension.js:176329:10)
    at openTutorialFirstTime (/nix/store/s5xl38py78xr7xlgp26w31a6xhx2jnkm-vscode-extension-Continue-conti…e-0.9.67/share/vscode/extensions/Continue.continue/out/extension.js:176338:11)
    at activateExtension (/nix/store/s5xl38py78xr7xlgp26w31a6xhx2jnkm-vscode-extension-Continue-conti…e-0.9.67/share/vscode/extensions/Continue.continue/out/extension.js:176367:9)
    at dynamicImportAndActivate (/nix/store/s5xl38py78xr7xlgp26w31a6xhx2jnkm-vscode-extension-Continue-conti…e-0.9.67/share/vscode/extensions/Continue.continue/out/extension.js:176448:11)
Raroh73 commented 8 months ago

@icodeforyou-dot-net I have very minimal config set but after deleting ~/.continue folder extension properly created default config for me.

Edit: After seeing your edit I deleted .vscode and .config/Code folders and extension broke for me. I used continue extension before 0.9.61 version and maybe one of updates changed how extension works but I need to test it.

Edit 2: Version 0.8.12 didn't work but version 0.8.0 worked for me.

Edit 3: Version 0.8.3 is last release version that works for me.

ic4-y commented 8 months ago

After seeing your edit I deleted .vscode and .config/Code folders and extension broke for me.

Sorry I broke things for you :smiling_face_with_tear:

From the error message I got there seems to be some openTutorialFirstTime function running, I guess, the first time you open it. And that errors out. So for some reason you bypassed that. If we could reproduce this bypass, we might have a workaround.

I will try 0.8.3 later and see if this fixes things.

Raroh73 commented 8 months ago

I think it requires write access to extension folder (in nix store) because of this commit. It rewrites keyboard shortcuts in tutorial file basing on running OS. I will need to find a way to bypass first activation somehow.

ic4-y commented 8 months ago

Well it does set context.globalState.update("continue.tutorialShown", true); at the end. I am just not sure where this globalState is located for future reference. If we knew, we could just put true in there and we should be good to go I'd say.

Raroh73 commented 8 months ago

From my research it looks like globalState is VS Code's database for extensions settings. I don't know if there is proper way to use VS Code api from command line.

ic4-y commented 8 months ago

@Raroh73 From looking at other VSCode extentions, I believe one might add a postInstall hook like so:

        postInstall = ''
          cd "$out/$installPrefix"
          jq '.contributes.configuration.properties."continue.tutorialShown".default = "true"' package.json | sponge package.json
        '';

However that did not work for me, so I have no idea how to actually do it. But maybe something along these lines?

I should say I tried version 0.8.0 and that one works now with deepseek-coder-1.3b on my local ollama using your config. Very nice.

Raroh73 commented 8 months ago
postInstall = ''
  cd "$out/$installPrefix"
  substituteInPlace "out/extension.js" \
    --replace 'await showTutorial();' '//await showTutorial();'
'';

It disables showTutorial() function so activation can pass. If you want to test it you probably will need to delete all 3 folders so I recommend backing them up.

ic4-y commented 8 months ago

Great, that sounds like a somewhat hacky workaround! I will delete all three folders without backing them up later and try it! :love_you_gesture:

(Nix is supposed to make things have less state. So deleting state every once in a while might be a decent idea.) :smile:

ic4-y commented 8 months ago

So I did test it by now and it basically works with newer version @Raroh73 . :confetti_ball: However I managed to break it once more when I reloaded the extension. It got stuck in shoing the loading spinner. I have not been able to reproduce this problem, so I can't say if this is at all related to NixOS. After deleting all VSCode related files once more it went away and the extension now works again.

Raroh73 commented 8 months ago

My PR was merged and now is available on NixOS Unstable.

lyssieth commented 8 months ago

I'd been using VSCode Insiders from AUR before I switched to configuring my VSCode with Nix, so I have a state.vscdb to compare to.

Looks like the best workaround to make openTutorialFirstTime see a true is to do the following:

INSERT INTO ItemTable VALUES('Continue.continue', '{"continue.tutorialShown":true}');

to the ~/.config/Code/User/globalStorage/state.vscdb sqlite file.

Doing that gets even the latest version of Continue loading and working properly (my config is using gpt4-turbo for chat and local ollama for tab autocomplete).

ciferkey commented 7 months ago

Just wanted to say the Intellij Plugin is also not working in NixOS. Should I make a separate issue with the details?

otopetrik commented 6 months ago

Just wanted to say the Intellij Plugin is also not working in NixOS. Should I make a separate issue with the details?

Providing the libstdc++.so.6 library is not enough, the continue-binary executable has a non-NixOS path to the interpreter /lib64/ld-linux-x86-64.so.2. Using patchelf does not help, because the binary is sensitive to internal changes (some fixed offsets). Behavior basically matches the following issue. Instead of the solution with top-level `/lib64' directory, use build a wrapper to run the unmodified binary in FHS environment.

NixOS-package Intellij plugin would be nice. For now the following workaround works:

In ~/.local/share/JetBrains/<IDE-version>/continue-intellij-extension/core/linux-x64 rename continue-binary to continue-binary-real. Make sure it is executable, it looks like it is installed without executable bit, and only marked executable later (during plugin start?).

Create continue-binary file with following contents:

#!/usr/bin/env bash
read -r -d '' EXPR <<'EOF'
with import <nixpkgs> { };
pkgs.buildFHSEnv {
  name = "continue-binary";
  runScript = ''./continue-binary-real "$@"'';
}
EOF
$(nix-build --expr "${EXPR}" --no-out-link)/bin/continue-binary "$@"

and chmod +x continue-binary.

vkopio commented 6 months ago

I managed to fix the aforementioned libstdc++ error with nix-ld (using vscode-fhs Nix package), but now the extension crashes with

Extension host (LocalProcess pid: 33180) terminated unexpectedly. Code: 132, Signal: unknown

The last working VSCode extension version is 0.8.11. I tried to inspect changes after that version change, but I did not find a clear mapping between the source code and the extension versions.

Edit: In 0.8.12 the extension crashes when indexing reaches at 33%, and in later prerelease versions the extension crashes at 25%.

ToyVo commented 5 months ago

Thanks for mentioning vscode-fhs, I didn't realize that was a thing, I was sitting here thinking how am I going to modify the desktop file to add env LD_LIBRARY_PATH=NIX_LD_LIBRARY_PATH to it.