Path issue for diffs on Windows
See original GitHub issueI searched for other issues like this, but couldn’t find any.
Description
I’m not able to get the diff tool to work on Windows. When trying to view a diff, the DiffWidget component displays an error. I believe this is related to paths being improperly passed to the backend for diffs when using windows paths.
I believe the function call here is causing the issue: https://github.com/jupyterlab/jupyterlab-git/blob/master/src/components/diff/DiffWidget.tsx#L38 but I’m new here, so take that with a grain of salt 🤷♂
Reproduce
- Go to a repo that has changes in it
- Click on the diff icon for a file that has been changed to view the diff
- See error
Failed to fetch diff with error:JSON.parse: unexpected character at line 1 column 1 of the JSON data
Expected behavior
I would expect to be able to view this diff on the windows platform.
Upon further inspection, I can see the following parameters passed in a Post to my lab server:
{
"file_path":"../C:/path_to_a notebook.ipynb",
"ref_local":{"git":"HEAD"},
"ref_remote":{"special":"WORKING"}
}
making the request without ../
in file_path
appears to fix the issue.
I’m familiar with react but I’m not sure where in this project this is getting messed up, and I"m not set up to easily develop on this(although I’m totally willing to figure it out if someone can point me to some links to get up and running)
Context
- Python package version:
conda list jupyterlab-git
# packages in environment at C:\Users\username\AppData\Local\Continuum\miniconda3:
#
# Name Version Build Channel
jupyterlab-git 0.8.2 py_0 conda-forge
- Extension version:
jupyter labextension list
JupyterLab v1.1.4
Known labextensions:
app dir: C:\Users\username\AppData\Local\Continuum\miniconda3\share\jupyter\lab
@jupyter-voila/jupyterlab-preview v0.1.3 enabled ok
@jupyter-widgets/jupyterlab-manager v1.0.3 enabled ok
@jupyterlab/celltags v0.2.0 enabled ok
@jupyterlab/git v0.8.2 enabled ok
@jupyterlab/toc v1.0.1 enabled ok
nbdime-jupyterlab v1.0.0 enabled ok
Command Line Output
Here's the error: [E 17:03:01.489 LabApp] C:\ Traceback (most recent call last): File "C:\Users\username\AppData\Local\Continuum\miniconda3\lib\site-packages\nbdime\webapp\nb_server_extension.py", line 97, in get_git_notebooks git_root = find_repo_root(file_path) File "C:\Users\username\AppData\Local\Continuum\miniconda3\lib\site-packages\nbdime\gitfiles.py", line 52, in find_repo_root repo = get_repo(path)[0] File "C:\Users\username\AppData\Local\Continuum\miniconda3\lib\site-packages\nbdime\gitfiles.py", line 41, in get_repo repo = Repo(path) File "C:\Users\username\AppData\Local\Continuum\miniconda3\lib\site-packages\git\repo\base.py", line 184, in __init__ raise InvalidGitRepositoryError(epath) git.exc.InvalidGitRepositoryError: C:\ [W 17:03:01.498 LabApp] 422 POST /nbdime/api/gitdiff?1575410581479 (::1): Invalid notebook: C:\Users\username\Code\AOE\Users\username\Code\AOE\EDE\notebooks\examples\voila.ipynb [W 17:03:01.502 LabApp] 422 POST /nbdime/api/gitdiff?1575410581479 (::1) 15.94ms referer=http://localhost:8888/lab [E 17:03:18.133 LabApp] C:\ Traceback (most recent call last): File "C:\Users\username\AppData\Local\Continuum\miniconda3\lib\site-packages\nbdime\webapp\nb_server_extension.py", line 97, in get_git_notebooks git_root = find_repo_root(file_path) File "C:\Users\username\AppData\Local\Continuum\miniconda3\lib\site-packages\nbdime\gitfiles.py", line 52, in find_repo_root repo = get_repo(path)[0] File "C:\Users\username\AppData\Local\Continuum\miniconda3\lib\site-packages\nbdime\gitfiles.py", line 41, in get_repo repo = Repo(path) File "C:\Users\username\AppData\Local\Continuum\miniconda3\lib\site-packages\git\repo\base.py", line 184, in __init__ raise InvalidGitRepositoryError(epath) git.exc.InvalidGitRepositoryError: C:\ [W 17:03:18.136 LabApp] 422 POST /nbdime/api/gitdiff?1575410598126 (::1): Invalid notebook: C:\Users\username\Code\AOE\Users\username\Code\AOE\EDE\notebooks\examples\voila.ipynb
Browser Output
Please see request params above, no console output was issued for this error
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (9 by maintainers)
Top GitHub Comments
I successfully reproduce the bug. The error was coming from
https://github.com/jupyterlab/jupyterlab-git/blob/d6b27c633dd2031a6bf2ff1d46293ac931539cb6/src/model.ts#L627
PathExt.relative
was not able to compute the relative path when the path is using backslashes. The fix is to work with a posix format in the frontend.@jamesjnadeau I just merged in #507. Can you please check if your issue is fixed in the latest master?
#507 does basically the same thing as your #516, but it fixes the issue on the Python side (where the offending path originates).
If #507 fixes the path issue but you still see the issue with the git filters, please open a new issue for that.