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

upgrading to monaco-languageclient version 6 throws command failed error #491

Closed
OliverwengFiltered opened this issue May 12, 2023 · 28 comments

Comments

@OliverwengFiltered
Copy link

Hi there,

I'm currently using monaco-languageclient version v5, when I'm upgrading it to v6, it throws command failed error.

it says

error /Users/xxxxx/xxxxxxx/node_modules/monaco-languageclient: Command failed.
Exit code: 127
Command: monaco-treemending
Arguments:

I have added the postinstall prop under package.json with value monaco-treemending and also tried manually run npx monaco-treemending, it prints Monaco-editor was tree-mended.

however, when I run yarn upgrade monaco-languageclient, it prints the above command failed error.

any ideas how to solve ?

@kaisalmen
Copy link
Collaborator

kaisalmen commented May 12, 2023

Hi @OliverwengFiltered thank you for reporting the problem. A similar or the same problem is reported here: CodinGame/monaco-vscode-api#113

The second time it tries to apply the patch to monaco-editor it exits with error.

@OliverwengFiltered
Copy link
Author

@kaisalmen
yes you are correct, the second time if I try npx monaco-treemending it throws below error

Error: Unable to apply patch on /Users/xxx/xxx/xxxx/xxxx/node_modules/monaco-editor/esm/vs/base/browser/browser.js
    at Object.patched (file:///Users/oliverweng/Desktop/DevelopmentApps/Filtered/node_modules/vscode/dist/monaco-treemending.js:854:30)
    at file:///Users/oliverweng/Desktop/DevelopmentApps/Filtered/node_modules/vscode/dist/monaco-treemending.js:820:15
    at Object.loadFile (file:///Users/oliverweng/Desktop/DevelopmentApps/Filtered/node_modules/vscode/dist/monaco-treemending.js:845:21)

is this something you folks can fix ?

@kaisalmen
Copy link
Collaborator

Yes, but not immediately. You need to live with it for a couple of days or use a workaround. pnpm seems to be the most problematic. npm ci will always work, 😉

@OliverwengFiltered
Copy link
Author

@kaisalmen
got it, I will wait, i will use the old version for now.
Thanks for the heads up @kaisalmen

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered in addition to the upcoming fix linked above I have updated the README: https://github.com/TypeFox/monaco-languageclient#using-monaco-languageclient

Any project using monaco-languageclient is not required to add and run the postinstall itself. This done by monaco-languageclient during dependency installation (=npm install). This is something I have misunderstood and one of the conclusions I draw from here: TypeFox/monaco-languageclient-ng-example#1

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered this is finally fixed with: https://www.npmjs.com/package/monaco-languageclient/v/6.0.3

@OliverwengFiltered
Copy link
Author

@kaisalmen

Thank you for fixing the postinstall issue.

I was trying the upgrade, but instead I got some module export error.

I'm using the corresponding versions for monaco-editor and vscode-api .

Any insight on this ?

Thank you !

Screenshot 2023-06-05 at 9 57 58 AM

@kaisalmen
Copy link
Collaborator

@CGNonofr any idea just by looking at the errors? My first guess is mismatching tsconfig/webpack config with regard to module/moduleResolution , but it is just guesswork without seeing the config.

@CGNonofr
Copy link
Collaborator

CGNonofr commented Jun 5, 2023

My guess is the patch wasn't applied

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered to my knowledge there is nothing as simple as npm ci with yarn, so please delete the node_modules folder again once, eventually remove the lock file and do a full re-installation.

@OliverwengFiltered
Copy link
Author

OliverwengFiltered commented Jun 5, 2023

@kaisalmen

cleaning node_modules, remove lock files didn't seem to help. Still hitting same kinda error.

it seems some export became unavailable, are we certain that the v6.0.3 compatible with monaco-editor 0.37.1 ? and vscode api 1.78.8 ?

Thanks.

Screenshot 2023-06-05 at 4 41 03 PM

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered this is really weird. I now added yarn and pnpm verification packages into the repo, see https://github.com/TypeFox/monaco-languageclient#pure-bundler-verification

It is not part of the npm workspace and allows to check install and manual invocation of treemending.

@kaisalmen
Copy link
Collaborator

I push another update. It is working for both package managers including multiple manual executions of yarn run test:treemending or pnpm run test:treemending after install.

@OliverwengFiltered
Copy link
Author

@kaisalmen

Thank you for adding those steps, I assume in order for us to picking up the latest, we will need to wait for the next release ?

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered
You can give https://www.npmjs.com/package/monaco-languageclient/v/6.1.0-next.1 a try. It depends on monaco-vscode-api 1.79.1 and monaco-editor 0.38.0, see PR #501

@OliverwengFiltered
Copy link
Author

Hi @kaisalmen

the v6.1.0-next.1 is promising, I am able to build it with some minor code changes on my end. I'm logging my changes here in case it helps you folks for additional improvements or for anyone else to see if needed.

  • after upgrading to v6.1.0-next.1 with yarn, it initially complains about mp3 files, and wasm files missing loader, so I added the corresponding loader in my webpack config.
  • after fixing the loader problem above, it starts complaining about two packages still missing. they are: vscode-textmate vscode-oniguruma, so I manually added by executing yarn add vscode-textmate vscode-oniguruma -D
  • did one more build, and now I can see it successfully built.
  • when I tried the actual page that has the editor with latest built resources, it starts to complain the MonacoServices obj under LanguageClientLib is undefined, and then I did some research and realized that I should probably switch to initServices, instead of calling MonacoServices.get(); and MonacoServices.install()
  • after the above all procedures, I am able to initialize the editor, and initialize the language server connection. however, I still see some error in my console when it tries to connect to my Java and C# language server. (C, C++, Python etc seems to be running perfectly.) although those errors are printing in my console, all the language server functions are all performing expectedly though.

appreciate any sight, regarding to those error messages.

Thanks!

Screenshot 2023-06-06 at 3 34 15 PM

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered did you configure services with initServices or did you leave it empty? I know it may not be possible, but sharing a repo or reproducible example makes problem cracking a lot easier.

@CGNonofr monaco-languageclient always initializes the files service even if nothing is configured. Is this not sufficient in this case. Any idea from just looking at the error?

@CGNonofr
Copy link
Collaborator

CGNonofr commented Jun 7, 2023

This error comes from the FileService not being overriden, what make you think it's not sufficient?

@kaisalmen
Copy link
Collaborator

what make you think it's not sufficient?

Doesn't the files service initialize an in memory file system that is used if nothing else is done?

@CGNonofr
Copy link
Collaborator

CGNonofr commented Jun 7, 2023

Correct!

@kaisalmen
Copy link
Collaborator

kaisalmen commented Jun 7, 2023

Then this is strange as initServices loads it, see:
https://github.com/TypeFox/monaco-languageclient/blob/main/packages/client/src/monaco-vscode-api-services.ts#L75-L76

@OliverwengFiltered can you at least add the debug logging? Thanks

await initServices({
    debugLogging: true
});

@OliverwengFiltered
Copy link
Author

@kaisalmen
to answer your previous question, yes, I am using initServices() without passing any params, assuming it will inherit the default configs.

where to see additional debug log ? i have enabled it with await initServices({ debugLogging: true });, but the error log seems to be the same.

Screenshot 2023-06-07 at 1 09 22 PM

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered you should at least see these info message, because the files service is always initialized:
image

@OliverwengFiltered
Copy link
Author

OliverwengFiltered commented Jun 7, 2023

@kaisalmen
yes I got those.

Screenshot 2023-06-07 at 6 13 01 PM

one thing worth mentioning is that, on my end, when the editor instance is created, it loads with a simple text model, (no errors at this point), and I have a language switch UI, once I click the language switch UI to switch to Java for example, then it will show the error. (my code is re-using the editor instance and switching model by using the editor.setModel(model) function), not sure if that add a bit more color for troubleshooting.

@CGNonofr
Copy link
Collaborator

CGNonofr commented Jun 8, 2023

The error is caused by the call to createOutputChannel done by vscode-languageclient

Are you sure to initialize the service BEFORE creating the first editor?

@OliverwengFiltered
Copy link
Author

@kaisalmen @CGNonofr

this works like a champ. As soon as I move the await LanguageClientLib.initServices(); to a few lines above before editor instance is created, it works without any error.

BTW, do you folks have insights about why there is a need to install vscode-textmate vscode-oniguruma two packages manually ?

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered that's good news

BTW, do you folks have insights about why there is a need to install vscode-textmate vscode-oniguruma two packages manually ?

Don't know. When using npm there is no need for that.

@OliverwengFiltered
Copy link
Author

@kaisalmen

all good, thank you for the support and knowledge sharing.

I will be looking forward to the next release !

have a great weekend!

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

Successfully merging a pull request may close this issue.

3 participants