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

Using @eclipse-che/plugin gives error #20259

Closed
sgraband opened this issue Aug 5, 2021 · 12 comments
Closed

Using @eclipse-che/plugin gives error #20259

sgraband opened this issue Aug 5, 2021 · 12 comments
Labels
kind/question Questions that haven't been identified as being feature requests or bugs. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@sgraband
Copy link

sgraband commented Aug 5, 2021

Summary

I am trying to read out the devfile in a custom theia editor, which i want to use in a Che workspace. I am following these instuctions: https://www.eclipse.org/che/docs/che-7/contributor-guide/che-theia-plug-in-api/. If i understand it correctly this should work with the @eclipse-che/plugin package. However when i create a theia plugin (or vscode extension) consuming this package and use await che.workspace.getCurrentWorkspace(); in the activate() function, the plugin cannot be build. I was able to workaround the build failure, but then the same error happens when the plugin is activated:

root ERROR [hosted-plugin: 292] Activating extension 'che-extension' failed: Error: Cannot find module '@eclipse-che/plugin'
Require stack:
- /tmp/theia-unpacked/che-extension.theia/lib/che-extension-backend.js
- /custom-theia/client/node_modules/@theia/plugin-ext/lib/hosted/node/plugin-host-rpc.js
- /custom-theia/client/node_modules/@theia/plugin-ext/lib/hosted/node/plugin-host.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Function.module._load (/custom-theia/client/node_modules/@theia/plugin-ext-vscode/lib/node/plugin-vscode-init.js:67:33)
    at Function.module._load (/custom-theia/client/node_modules/@theia/plugin-ext/lib/hosted/node/scanners/backend-init-theia.js:43:33)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/tmp/theia-unpacked/che-extension.theia/lib/che-extension-backend.js:45:11)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/tmp/theia-unpacked/che-extension.theia/lib/che-extension-backend.js',
    '/custom-theia/client/node_modules/@theia/plugin-ext/lib/hosted/node/plugin-host-rpc.js',
    '/custom-theia/client/node_modules/@theia/plugin-ext/lib/hosted/node/plugin-host.js'
  ]
}

Is there something i am missing with the @eclipse-che/plugin package? Is it only usable inside of Che-Theia or does it have any other constraints?
Thanks in advance.

UPDATE:
The problem above seems to not occur using the following theia plugin: https://github.com/sgraband/che-plugin-test.
However, the plugin can still not be activated due to 'che' not being define:
Activating extension '*' failed: che is not defined

Relevant information

I also tried it with this code:

const eclipseCheExtPlugin = vscode.extensions.getExtension('@eclipse-che.ext-plugin');
if (eclipseCheExtPlugin) {
  // grab user
  const user = await eclipseCheExtPlugin.exports.user.getCurrentUser();
 vscode.window.showInformationMessage(`Eclipse Che user information: id ${user.id} with name ${user.name}`);
} else {
  vscode.window.showWarningMessage('Not running inside Eclipse Che, not displaying any user information');
}

But this results in Not running inside Eclipse Che, not displaying any user information, when running the editor in Che.

@sgraband sgraband added the kind/question Questions that haven't been identified as being feature requests or bugs. label Aug 5, 2021
@benoitf
Copy link
Contributor

benoitf commented Aug 11, 2021

@eclipse-che.ext-plugin is only working in che-theia where we add @eclipse-che/plugin (in addition to other vscode/theia namespace)

so you can't just take this plug-in without adding as well the whole che-theia plug-in ext module

@sgraband
Copy link
Author

@benoitf Thanks for your answer! If i understand you correctly, your response is about the code in the relevant information section.
But what about just using @eclipse-che/plugin like described in the summary section. Is this also only possible inside of Che-Theia? According to the README.md it contains Eclipse Che API available for Eclipse Theia Plugins. So this should in theory work outside of Che-Theia?

@benoitf
Copy link
Contributor

benoitf commented Aug 12, 2021

it works only in che-theia because @eclipse-che/plugin is just a plug-in definition and something needs to provide the binding at runtime (and this is what does the che-plugin-ext implementation that is only in che-theia

@JonasHelming
Copy link

Is there any other foreseen way to access Che (devfile and API) from within a custom Theia editor that is not Che-Theia? Is it conceptionally possible to refactor the che/plugin in a way that it can be included into custom Theia editors that are not Che-theia, e.g. by reorganizing the dependencies?

@tsmaeder
Copy link
Contributor

@benoitf does it make sense to npm-publish the API, but not the implementations?

@benoitf
Copy link
Contributor

benoitf commented Aug 12, 2021

Is there any other foreseen way to access Che (devfile and API) from within a custom Theia editor that is not Che-Theia? Is it conceptionally possible to refactor the che/plugin in a way that it can be included into custom Theia editors that are not Che-theia, e.g. by reorganizing the dependencies?

we publish the API provided by che-theia, so if you want to use "che-theia programming model' you need to use che-theia.

Devfile API is accessible by che-server Rest API or through a mounted file in case of DevWorkspace. So you can access these information without CheTheia custom namespace.

@tsmaeder
Copy link
Contributor

We publish the API provided by che-theia, so if you want to use "che-theia programming model' you need to use che-theia.

But why do we publish the @eclipse-che/plugin package to npm if it can't be used by anyone outside the che-theia source tree anyway?

@benoitf
Copy link
Contributor

benoitf commented Aug 12, 2021

we publish to npmjs because you can develop vscode Extensions / Theia plug-ins to be installed in CheTheia by depending only on this package, not depending on the implementation.

@benoitf
Copy link
Contributor

benoitf commented Aug 12, 2021

also the API exposed by our @eclipse-che/plugin is tied to the version of underlying Che (like our Devfile model) but also to the underlying version of Theia.
So it means that if a 'custom Theia' would use the implementation of our Che-Theia, it would have to stick to the same "Theia+Che version" which is a very high constraint and it's also due to the Extension Model of Theia that is mostly failing when not using the same Theia dependency.

That said, this is why to not having to re-implement some logic in all editors that we moved the clone operation at an earlier step in the DevWorkspace. ( #15973 ) And that IDE plug-ins are not part of the Devfile v2 but are part of the project source code.

And we also want to have commands of the devfile being exposed by shell aliases as well so in the end you can easily plug other editors without having to handle clone or commands of the devfile, etc but still interact with your workspace definition.

@sgraband
Copy link
Author

sgraband commented Aug 13, 2021

Thanks a lot @benoitf ! This sounds exactly what we would need for the custom editor use case. I see this is on the roadmap for the next months, which is great. If we can help and or test anything, please let us know anytime.

@tsmaeder
Copy link
Contributor

tsmaeder commented Aug 16, 2021

So it means that if a 'custom Theia' would use the implementation of our Che-Theia, it would have to stick to the same "Theia+Che version" which is a very high constraint and it's also due to the Extension Model of Theia that is mostly failing when not using the same Theia dependency.

The provisioning of the API as a Theia plugin namespace is tied to the underlying Theia version (although unless the API provisioning SPI changes, you should be good), but nothing keeps us from making a library that can provide access to the dev workspace (from the che server or devworkspace operator) and publishing that for use of third-party editors.

Another idea would be to run a "proxy" inside the workspace that provides the API and dispatches to che server or devworkspace operator depending on the setup. It could provide a http API accessible from any language.

@che-bot
Copy link
Contributor

che-bot commented Feb 12, 2022

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 12, 2022
@che-bot che-bot closed this as completed Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Questions that haven't been identified as being feature requests or bugs. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

5 participants