Skip to content

Path issue for diffs on Windows #471

@jamesjnadeau

Description

@jamesjnadeau

I 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

  1. Go to a repo that has changes in it
  2. Click on the diff icon for a file that has been changed to view the diff
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions