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

VS Code Flatpak Support #2873

Closed
mmstick opened this issue Jan 17, 2020 · 11 comments
Closed

VS Code Flatpak Support #2873

mmstick opened this issue Jan 17, 2020 · 11 comments

Comments

@mmstick
Copy link

mmstick commented Jan 17, 2020

Problem

Linux distributions are collectively moving towards Flatpak as a distribution model for third party applications. However, the VS Code extension is currently unsupported within the VS Code Flatpak, due to the way that it tries to spawn ra_lsp_server by looking up its path within system paths — paths that won't exist inside of a Flatpak container.

Solution

The extension could check for the existence of /usr/bin/flatpak-spawn to determine if being run within a Flatpak container. If within a Flatpak container, ra_lsp_server can be invoked with flatpak-spawn --host ra_lsp_server.

@bjorn3
Copy link
Member

bjorn3 commented Jan 17, 2020

I solved this by telling flatpak to let the PATH env var to include ~/.cargo/bin, but your solution is much better I think.

@matklad
Copy link
Member

matklad commented Jan 17, 2020

Hm, looks like this ideally should be some build-in API in the VS Code, similar to how file system is. But I guess there isn't, and we indeed should do this ourselves :-(

Also, I cannot help but note that there's a much better solution for reproducible application packaging :-)

@mmstick
Copy link
Author

mmstick commented Jan 17, 2020

I solved this by telling flatpak to let the PATH env var to include ~/.cargo/bin, but your solution is much better I think.

For anyone wondering how to get this to work:

flatpak --user override com.visualstudio.code \
    --env=PATH=/app/bin:/usr/bin:/home/$USER/.cargo/bin

@bjorn3
Copy link
Member

bjorn3 commented Dec 19, 2020

The extension now downloads it's own rust-analyzer executable into the extension storage. I am using VSCode inside Flatpak and haven't had any trouble in a long time.

@bjorn3 bjorn3 closed this as completed Dec 19, 2020
@dhardy
Copy link

dhardy commented Nov 7, 2022

Essentially the same issue occurs with VSCodium in a flatpak:

error: could not execute process `rustc -vV` (never executed) Caused by: No such file or directory (os error 2)

Solution is as above:

flatpak --user override com.vscodium.codium  --env=PATH=/app/bin:/usr/bin:/home/$USER/.cargo/bin

@willswats
Copy link

Could this be reopened? I had to use the flatpak override provided by dhardy to get the extension working on the VSCodium flatpak.

@bjorn3
Copy link
Member

bjorn3 commented Nov 27, 2022

@willswats What do you want rust-analyzer to do? Using flatpak override from within a flatpak application is not possible and rust-analyzer doesn't know what to add to PATH as you may have installed rustc and cargo anywhere. Rust-analyzer gets the location from PATH.

@willswats
Copy link

@bjorn3 I don't know enough about rust-analyzer or flatpak to come up with a solution, but I wouldn't regard this as solved if the user has to search online for a fix.

@mmstick
Copy link
Author

mmstick commented Nov 27, 2022

You should report the issue to the maintainer of the flathub package.

@RichardJECooke
Copy link

@mmstick I ran flatpak --user override com.visualstudio.code --env=PATH=/app/bin:/usr/bin:/home/$USER/.cargo/bin and nothing happened. I then opened VSCode from the taskbar and rust-analyzer still had the error.

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: Failed to load the project at /home/ne/code/rust-actix-web/complete-application/Cargo.toml: Failed to query rust toolchain version at /home/me/code/rust-actix-web/complete-application, is your toolchain setup correctly?: cd "/home/me/code/rust-actix-web/complete-application" && "cargo" "--version" failed: No such file or directory (os error 2)

@RichardJECooke
Copy link

Yeah I think VSCode under flatpak is just broken. They should remove it rather messing people around.

Rather install it from the site proper -

curl -L -o vscode.deb "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64" &&
sudo dpkg -i vscode.deb &&
rm vscode.deb;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants