aspiers / git-deps

git commit dependency analysis tool
GNU General Public License v2.0
297 stars 46 forks source link

Error when analysing dependencies in a 'real' repository (MacOS) #97

Open Napoleon-BlownApart opened 4 years ago

Napoleon-BlownApart commented 4 years ago

[MacOS 10.14.5, Installed libgit2 using homebrew, and git-deps using pip3]

Nice idea, and the visualisation reduces the cognitive load associated with understanding the dependency graph.

However, whilst this tool works fine with an example similar to that in the video, I'm getting an error when running it against our real repository at Uni. The error messages below occur when accessing the same repository via the browser and using the CLI.) Any suggestions on how to fix this?

git deps --serve (GUI)

    Typed *master* into the textbox

    [2020-01-03 01:31:43,233] ERROR in app: Exception on /deps.json/master [GET]
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
        response = self.full_dispatch_request()
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
        rv = self.handle_user_exception(e)
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
        reraise(exc_type, exc_value, tb)
      File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
        raise value
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
        rv = self.dispatch_request()
      File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
        return self.view_functions[rule.endpoint](**req.view_args)
      File "/usr/local/lib/python3.7/site-packages/git_deps/server.py", line 103, in deps
        detector.find_dependencies(rev)
      File "/usr/local/lib/python3.7/site-packages/git_deps/detector.py", line 122, in find_dependencies
        self.find_dependencies_with_parent(dependent, parent)
      File "/usr/local/lib/python3.7/site-packages/git_deps/detector.py", line 147, in find_dependencies_with_parent
        self.blame_hunk(dependent, parent, path, hunk)
      File "/usr/local/lib/python3.7/site-packages/git_deps/detector.py", line 161, in blame_hunk
        if not self.tree_lookup(path, parent):
      File "/usr/local/lib/python3.7/site-packages/git_deps/detector.py", line 311, in tree_lookup
        tree_or_blob = self.repo[tree_or_blob[dirent].oid]
    KeyError: 'object not found - no match for id (5668198989e66aa87478ba3c9f5102639485e3c2)'

git deps master (CLI)

    git deps master

    4aae9cc00dc260007f8f6d3af633639f99ced3b1 fec35b7eb51f6c644486e39feb02108d8bcd590a
    4aae9cc00dc260007f8f6d3af633639f99ced3b1 0244cbb301caa2f6df953f95a9b17f7da2c86140
    4aae9cc00dc260007f8f6d3af633639f99ced3b1 bcd7a130ca4cc736edd5e259629d8b13fd54110c
    4aae9cc00dc260007f8f6d3af633639f99ced3b1 9d03f8e726eb3e7537d14f65b6ce53b9a78a7ecc
    4aae9cc00dc260007f8f6d3af633639f99ced3b1 012e405173c2a12cb774662542dd9f0254197865
    4aae9cc00dc260007f8f6d3af633639f99ced3b1 d526b3d262036e6400070985932a537d71a2dfda
    4aae9cc00dc260007f8f6d3af633639f99ced3b1 ef5daeae0578a3af957e87a399aa3828200ef21a
    4aae9cc00dc260007f8f6d3af633639f99ced3b1 2506addacca283ef6db268f67772a93810452948
    Traceback (most recent call last):
      File "/usr/local/bin/git-deps", line 8, in <module>
        sys.exit(run())
      File "/usr/local/lib/python3.7/site-packages/git_deps/cli.py", line 141, in run
        main(sys.argv[1:])
      File "/usr/local/lib/python3.7/site-packages/git_deps/cli.py", line 135, in main
        cli(options, args)
      File "/usr/local/lib/python3.7/site-packages/git_deps/cli.py", line 119, in cli
        detector.find_dependencies(rev)
      File "/usr/local/lib/python3.7/site-packages/git_deps/detector.py", line 122, in find_dependencies
        self.find_dependencies_with_parent(dependent, parent)
      File "/usr/local/lib/python3.7/site-packages/git_deps/detector.py", line 147, in find_dependencies_with_parent
        self.blame_hunk(dependent, parent, path, hunk)
      File "/usr/local/lib/python3.7/site-packages/git_deps/detector.py", line 161, in blame_hunk
        if not self.tree_lookup(path, parent):
      File "/usr/local/lib/python3.7/site-packages/git_deps/detector.py", line 311, in tree_lookup
        tree_or_blob = self.repo[tree_or_blob[dirent].oid]
    KeyError: 'object not found - no match for id (5668198989e66aa87478ba3c9f5102639485e3c2)'
aspiers commented 3 years ago

Sorry for the very slow response. Any chance you could share the repo you used to reproduce this?

Napoleon-BlownApart commented 3 years ago

No problem. It's been so long that I need to refresh my memory of what this was about. It might take a couple weeks before I get a chance to dive into it, got a lot on right now, but I will come back to it.

fuulish commented 2 years ago

Not sure if it's the same cause, but the error is the same as in issue #107. Does the repo contain submodules by any chance?

Napoleon-BlownApart commented 2 years ago

I tried it in a repo without submodules, and I'm getting the following message:

user@host:[21:44]$ git deps --serve
fatal: 'deps' appears to be a git command, but we were not
able to execute it. Maybe git-deps is broken?
~/Programming/LISP/config ((5e63142...)~*%)

I'm afraid it's been so long now that I can't even recall exactly how I installed etc.

fuulish commented 2 years ago

That does look an installation issue, agreed. Even if you cannot reproduce the git-deps call, do you know what ID 5668198989e66aa87478ba3c9f5102639485e3c2 refers to in your above repo in terms of git objects?

Napoleon-BlownApart commented 2 years ago

going through my bash history, it appears that I tried to use the command on one of my repos. When it didn't work, I created a fresh repo and tried it there. I think that hash is from that repo, which I have since deleted.

When I use git deps master I get the following message:

fatal: 'deps' appears to be a git command, but we were not
able to execute it. Maybe git-deps is broken?

When I try using git-deps master:

-bash: /usr/local/bin/git-deps: /usr/local/opt/python/bin/python3.7: bad interpreter: No such file or directory

/usr/local/bin/git-deps has a shbang #!/usr/local/opt/python/bin/python3.7 but I don't a python version there. I changed the shbang to point to a /usr/local/bin/python3 (which on my system is v3.9.6), and git-deps master now returns:

Traceback (most recent call last):
  File "/usr/local/bin/git-deps", line 6, in <module>
    from git_deps.cli import run
ModuleNotFoundError: No module named 'git_deps'
fuulish commented 2 years ago

Have you tried reinstalling git-deps? The mismatch you are seeing in the python version might mean that the git_deps module is installed in a (python-version-specific) path that is not used by your environment. I.e., if it's from a previous installation, the git_deps module might be installed in a python3.7- and not python3.9-specific path.