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

Incompatibility with JupyterLab core npm packages 3.0.10 #595

Closed
bsyouness opened this issue May 10, 2021 · 17 comments
Closed

Incompatibility with JupyterLab core npm packages 3.0.10 #595

bsyouness opened this issue May 10, 2021 · 17 comments

Comments

@bsyouness
Copy link
Contributor

Description

We use a custom version of JupyterLab which depends on the following dependencies that I upgraded:
Screen Shot 2021-05-10 at 6 07 52 PM

Doing that broke the LSP extension in that the check if not uri.startswith(virtual_documents_uri) in "virtual_documents_shadow.py" at line 141 now fails. This is due to an additional "/" that gets inserted in the file URI as per this example:

uri file://c:/XXX/.virtual_documents/1%20Migration%20Guide.ipynb doesn't start with file:///c:/XXX/.virtual_documents

Reproduce

Bump up to the latest version of JupyterLab.

@krassowski
Copy link
Member

Thank you for the heads up! Would you like to open a PR to fix this (and bump the versions?).

@bsyouness
Copy link
Contributor Author

Sure yeah!

@krassowski
Copy link
Member

It would be very welcome :) It seems to be related to url-parse 1.5.1 update and I think that is causing the current failures..

@bsyouness
Copy link
Contributor Author

So we've been looking into this and trying to make sense of it... Should we be using 3 or 2 slashes. 3 slashes is windows-specific and was the status-quo before this breaking change. Do we want to stick with 3 slashes and amend the way the URI is built in jupyterlab core somehow? Any other suggestions?

@krassowski
Copy link
Member

@bollwyvl do you have an opinion on this one?

@bollwyvl
Copy link
Collaborator

Aw, man, I sure love windows paths. LOVE'm. It's unlikely i'll have any bandwidth to work on this this week, but one of them has to be right. Looks like the python tests expect three slashes. This jives with my understanding of the // being the protocol separator, and then the <nothing here>/ being the authority.

@krassowski
Copy link
Member

unshiftio/url-parse#203 looks like an upstream bug report for this issue.

@bollwyvl
Copy link
Collaborator

bollwyvl commented May 13, 2021 via email

@krassowski
Copy link
Member

I think the troublesome fix went into 1.5.0. It might be difficult to revert to an earlier version since it got a) a security fix label b) already merged and released by JupyterLab core. I was thinking about an upstream fix, or making our server side comparison be more lenient (as a special case for the lack/presence of triple /).

@krassowski
Copy link
Member

1.5.1 was meant to address some of the issues introduced by the fix but not this one. I will make some noise on the issue.

@bsyouness
Copy link
Contributor Author

bsyouness commented May 13, 2021

I think the troublesome fix went into 1.5.0. It might be difficult to revert to an earlier version since it got a) a security fix label b) already merged and released by JupyterLab core. I was thinking about an upstream fix, or making our server side comparison be more lenient (as a special case for the lack/presence of triple /).

I think maybe the latter (making the server side comparison more lax), would be a good idea too in case something like this happens again — according to the issue you identified I get the impression that this kind of url parsing will remain problematic. I'm happy to create a PR to that effect if you want to tell me how you think the comparison should be performed.

@krassowski
Copy link
Member

Maybe just strip the prefix before preforming the starts with check, whether it is file:// or file:///?
Regular expression would be an alternative, but maybe better to avoid it.

@bollwyvl
Copy link
Collaborator

bollwyvl commented May 13, 2021 via email

@krassowski
Copy link
Member

It seems that a simple fix mostly did it (for Win and Linux) but it is still a problem on Mac (curiously) https://github.com/krassowski/jupyterlab-lsp/pull/599/files
Any ideas?

@krassowski
Copy link
Member

krassowski commented May 17, 2021

Ok, debugged on CI. MacOS fails the comparison on:

uri = "file:///users/runner/work/jupyterlab-lsp/jupyterlab-lsp/atest/output/darwin_39_1/home/n%C3%B6te%20b%C3%B2%C3%B3ks/.virtual_documents/Python.ipynb"`
virtual_documents_uri = "file:///Users/runner/work/jupyterlab-lsp/jupyterlab-lsp/atest/output/darwin_39_1/home/n%C3%B6te%20b%C3%B2%C3%B3ks/.virtual_documents"

The difference is in lowercase vs uppercase "users"/"Users".

@krassowski
Copy link
Member

Which was already reported in unshiftio/url-parse#203 as well... I guess the simple workaround is not that simple. It looks like unshiftio/url-parse#204 will fix that too.

@krassowski
Copy link
Member

Closing as resolved.

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

No branches or pull requests

3 participants