lensapp / lens

Lens - The way the world runs Kubernetes
https://k8slens.dev/
MIT License
22.53k stars 1.47k forks source link

Extension appears to be enabled but can't be found #1684

Closed jim-docker closed 3 years ago

jim-docker commented 3 years ago

When installing an extension from tarball through the UI it appears to install successfully, and can be enabled but does not actually get loaded.

Root cause is actually the symlink points to a non-existent folder.

From the logs:

info: [EXTENSION-DISCOVERY] Added extension @mirantis/lens-extension-cc
info: [STORE]: SAVING /Users/jimehrismann/Library/Application Support/Lens/lens-extensions.json
[EXTENSIONS-LOADER]: can't load extension main at /Users/jimehrismann/Library/Application Support/Lens/node_modules/@mirantis/lens-extension-cc/dist/main.js: Error: Cannot find module '/Users/jimehrismann/Library/Application Support/Lens/node_modules/@mirantis/lens-extension-cc/dist/main.js'

~/Library/Application Support/Lens/node_modules/@mirantis/lens-extension-cc is a symlink pointing to ~/.k8slens/extensions/lens-extension-cc but the extension is actually installed in ~/.k8slens/extensions/mirantis--lens-extension-cc

Apart from this, it seems odd that the link is created in ~/Library/Application Support/Lens/node_modules/ and points to the files installed in ~/.k8slens/extensions/. Shouldn't it be the other way around? The extension should actually be installed under ~/Library/Application Support/Lens/node_modules/ and a link to it be created in ~/.k8slens/extensions/?

affects 4.0.0

panuhorsmalahti commented 3 years ago

Can't reproduce just yet. In any case it's correct that the symlink is from ~/Library/Application Support/Lens/node_modules/ to ~/.k8slens/extensions/.

panuhorsmalahti commented 3 years ago

This is what probably happened:

  1. User copied extension to /Users/<username>/.k8slens/extensions/lens-extension-cc
  2. User uninstalled extension from the UI (or just deleting the folder manually).
  3. User installed extension from the Lens UI.

At this point /Users/<username>/Library/Application Support/Lens/node_modules/@mirantis/lens-extension-cc still points to the old /Users/<username>/.k8slens/extensions/lens-extension-cc.

I think the fix would be actually run npm uninstall (or something) to remove it from node_modules. It's already removed from package.json and /Users/<username>/.k8slens/extensions

panuhorsmalahti commented 3 years ago

Users encountering this bug can for now remove the broken symlink manually from e.g. /Users/<username>/Library/Application Support/Lens/node_modules/@publisher/extension.

stefcameron commented 3 years ago

This is what probably happened:

  1. User copied extension to /Users/<username>/.k8slens/extensions/lens-extension-cc
  2. User uninstalled extension from the UI (or just deleting the folder manually).
  3. User installed extension from the Lens UI.

Yep, that's what happened... 😄 (I just deleted the folder manually, which was a symlink in my case, because that's also how I had installed the extension in the first place...)

panuhorsmalahti commented 3 years ago

Should be fixed (well enough) now.

We could still handle the following case: user removes the extension manually and then starts Lens. Even in this case the broken symlink should be fixed on the next install.