question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Path issue for diffs on Windows

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
fcollonvalcommented, Dec 24, 2019

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.

2reactions
telamoniancommented, Jan 7, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

11 Ways to Fix "The System Cannot Find The Path ...
11 Ways to Fix "The System Cannot Find The Path Specified" Error on Windows · 1. Run Command Prompt as an Administrator ·...
Read more >
windows 7 - Why won't my diff.exe run from cmd line?
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths has no effect on cmd , because cmd doesn't use ShellExecuteEx to run programs.
Read more >
What is the Windows equivalent of the diff command?
So, my answer is that the Windows equivalent of diff , is none other than diff ... You can set the PATH variable...
Read more >
How to Use the Windiff.exe Utility - Windows Client
To view the actual file differences, click the first line in the Windiff.exe output results, and then on the Expand menu, click Left...
Read more >
Diff (devenv.exe) - Visual Studio (Windows)
Learn how to use the Diff devenv command-line switch to compare two files. ... The full path and name of the first file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found