8000 Wrong project root if invoked from a sub-directory · Issue #936 · fsfe/reuse-tool · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Wrong project root if invoked from a sub-directory #936

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

Open
monacofj opened this issue Mar 25, 2024 · 2 comments
Open

Wrong project root if invoked from a sub-directory #936

monacofj opened this issue Mar 25, 2024 · 2 comments
Labels
bug Something isn't working stale

Comments

@monacofj
Copy link
Contributor

Would anyone confirm or provide hints on the following issue.

Suppose that the project directory has the following structure:

 proj
 |___.reuse
      |____ dep5
      |____ templates
           |_____ proj.jinja2
 |___ file1.py
 |___ subdir
      |_____ file2.py

From within the project root directory, we want to annotate file1.py using the custom template proj.jinja2.

$ cd <path>/proj
$ reuse annotate --copyright=John --license=CC0-1.0 --template=proj file1.py
Successfully changed header of file1.py

So far so good.

However, suppose we also want to annotate file2 within subdir.

$ cd <path>/proj
$ cd subdir
$ reuse annotate --copyright=John --license=CC0-1.0 --template=proj file2.py
reuse annotate: error: template ../proj could not be found

To have it work, he have to move up to the root directory

$ cd <path>proj
$ reuse annotate --copyright=John --license=CC0-1.0 --template=proj subdir/file2.py
Successfully changed header of file2.py

Intriguingly, I have another project which was cloned from a remote Git repository where the problem does not occur, which led me to wonder if the issue had something to do with proj not being a git repo. However, I then recreated proj as a Git repo, cloned it and repeated the tests only to check that the problem persists.

As a note, I performed some debugging in reuse-tool source and could see that for my working project, the program correctly detects the project root dir (.. if I invoke reuse from a first-level subdir) , while for proj, the program identifies the project root as the absolute path <path>proj/subidr. I could not dig deeper in the problem, though.

@carmenbianca carmenbianca added the bug Something isn't working label Apr 8, 2024
@carmenbianca
Copy link
Member

Oof… Using reuse from subdirectories is one of those things that requires quite a bit of plumbing, but doesn't have nearly enough in the way of tests. It's a bit of a mess, especially because there are two types of relative paths:

  • Relative from project root
  • Relative from CWD

These are normally identical, but not always, and the bug here is probably something of that type.

Thanks for reporting.

Copy link

Thank you for your time and contributions! Unfortunately, this issue has been inactive for quite a while which means we probably can't manage the time to deal with it. That's why we're marking it as stale. We want to keep things tidy and focus on active discussions, but we’re always happy to revisit if this is still relevant!

If you’d like to keep this open, please add a comment to let us know and remove the label stale. Otherwise, this issue will most likely be automatically closed soon.

@github-actions github-actions bot added the stale label May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

2 participants
0