NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.21k stars 14.21k forks source link

vscode: eamodio.gitlens can't load icons #218031

Closed SuperSamus closed 7 months ago

SuperSamus commented 1 year ago

Describe the bug

In VSCode (and Codium), the extension eamodio.gitlens is unable to load icons, and uses generic rectangles instead. Opening VSCode/Codium with --verbose shows:

vscode-file: Refused to load resource /nix/store/wls3y80nfld9hln166zw0b1rhssj5wyk-vscode-extension-eamodio-gitlens-2022.12.604/share/vscode/extensions/eamodio.gitlens/dist/glicons.woff2 from vscode-file: protocol (original URL: vscode-file://vscode-app/nix/store/wls3y80nfld9hln166zw0b1rhssj5wyk-vscode-extension-eamodio-gitlens-2022.12.604/share/vscode/extensions/eamodio.gitlens/dist/glicons.woff2)

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix-shell -p "vscode-with-extensions.override {vscodeExtensions = [vscode-extensions.eamodio.gitlens];}"
  2. Open code.
  3. You can see that what are supposed to be GitLens icons are rectangles instead.

Expected behavior

GitLens should load the icons correctly.

Screenshots

EDIT: Instead of rectangles, the icons are invisible now.

image image

Additional context

Bug also happens with the extension fetched from https://github.com/nix-community/nix-vscode-extensions (both from vscode-marketplace and open-vsx).

The bug doesn't reproduce with vscode-fhs.

Notify maintainers

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.12-zen1, NixOS, 23.05 (Stoat), 23.05.20230223.03fb722`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.2`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
CedricFinance commented 1 year ago

VScode only allows files to be loaded from certain root folders (source).

// Define an initial set of roots we allow loading from
// - appRoot    : all files installed as part of the app
// - extensions : all files shipped from extensions
// - storage    : all files in global and workspace storage (https://github.com/microsoft/vscode/issues/116735)

On NixOS, the extensionsDir is in the Nix store with links to the different extensions (also in the Nix store).

This issue is that the extensions tries to load the file from the extension's folder directly (/nix/store/wls3y80nfld9hln166zw0b1rhssj5wyk-vscode-extension-eamodio-gitlens-2022.12.604) and not from the extensions folder (something like /nix/store/xxxxx-vscode-extensions).

If the path of the font is /nix/store/xxxxx-vscode-extensions/share/vscode/extensions/eamodio.gitlens/dist/glicons.woff2, it should work (/nix/store/xxxxx-vscode-extensions must be in the authorised folders whereas /nix/store/wls3y80nfld9hln166zw0b1rhssj5wyk-vscode-extension-eamodio-gitlens-2022.12.604 isn't).

ranuwp commented 1 year ago

Facing this until today. Anyone has workaround for this issue?

katexochen commented 1 year ago

pinging @ratsclub as maintainer

katexochen commented 1 year ago

@CedricFinance thanks for the research! Do you think this is something we can substitute in our packaging? Or does it require an upstream fix?

Quoteme commented 1 year ago

I researched into this as well. I am not really sure how @CedricFinance came to his conclusion, that the problem stems from vscode/vscodium not having permissions to load icons from specific places, if I understood him correctly. Neither do I know how we could test this hypothesis.

EDIT: I was stupid. It's because of the error

vscode-file: Refused to load resource /nix/store/kd22v8wj9fv6f33zv2vg3rww8swbgmdv-vscode-extension-eamodio-gitle
ns-2023.10.1105/share/vscode/extensions/eamodio.gitlens/dist/glicons.woff2 from vscode-file: protocol (original URL: vscode-file://vscode-app/ni
x/store/kd22v8wj9fv6f33zv2vg3rww8swbgmdv-vscode-extension-eamodio-gitlens-2023.10.1105/share/vscode/extensions/eamodio.gitlens/dist/glicons.woff
2)

What I noticed, however, is that the github.copilot extension has the same problem:

Figure 1
image
Missing GitHub-Copilot Icon

Furthermore, if I go into my /nix/store/XXXXX-vscode-extensions/share/vscode/extensions/ folder and issues the command rg "\"icons\": \{" --max-columns=100 --max-columns-preview=10 ./*, I get the following output:

./vscjava.vscode-spring-boot-dashboard/package.json
30:    "icons": {

./github.copilot/package.json
304:        "icons": {

./eamodio.gitlens/package.json
7665:       "icons": {

Not sure about the spring-boot-dashboard extension, but it seems like extensions which define this attribute in their package.json cannot load their icons.