Skip to content
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

Running scancode-license-data without arguments does not work #4024

Open
sschuberth opened this issue Dec 16, 2024 · 6 comments · May be fixed by #4029
Open

Running scancode-license-data without arguments does not work #4024

sschuberth opened this issue Dec 16, 2024 · 6 comments · May be fixed by #4029

Comments

@sschuberth
Copy link
Collaborator

sschuberth commented Dec 16, 2024

Description

Running scancode-license-data that comes with 32.3.0 does not work.

How To Reproduce

  1. Install scancode-toolkit version 32.3.0.
  2. Run scancode-license-data without any arguments.
  3. See
$ scancode-license-data
Dumping license data to: None
Traceback (most recent call last):
  File "/opt/python/versions/3.11.10/bin/scancode-license-data", line 8, in <module>
    sys.exit(dump_scancode_license_data())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/versions/3.11.10/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/versions/3.11.10/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/python/versions/3.11.10/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/versions/3.11.10/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/versions/3.11.10/lib/python3.11/site-packages/licensedcode/license_db.py", line 227, in dump_scancode_license_data
    scancode_license_data(path=path)
  File "/opt/python/versions/3.11.10/lib/python3.11/site-packages/licensedcode/license_db.py", line 204, in scancode_license_data
    count = generate(build_location=path)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/versions/3.11.10/lib/python3.11/site-packages/licensedcode/license_db.py", line 175, in generate
    if not os.path.exists(build_location):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen genericpath>", line 19, in exists
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

The same happens on another machine with Python 3.13:

Dumping license data to: None
Traceback (most recent call last):
  File "/usr/bin/scancode-license-data", line 8, in <module>
    sys.exit(dump_scancode_license_data())
             ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.13/site-packages/licensedcode/license_db.py", line 227, in dump_scancode_license_data
    scancode_license_data(path=path)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/licensedcode/license_db.py", line 204, in scancode_license_data
    count = generate(build_location=path)
  File "/usr/lib/python3.13/site-packages/licensedcode/license_db.py", line 175, in generate
    if not os.path.exists(build_location):
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "<frozen genericpath>", line 19, in exists
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

System configuration

  • What OS are you running on? Linux
  • What version of scancode-toolkit was used to generate the scan file? 32.3.0
  • What installation method was used to install/run scancode? Both RPM package on Fedora and pip install.
@sschuberth sschuberth added the bug label Dec 16, 2024
@sschuberth sschuberth changed the title Running scancode-license-data does not work Running scancode-license-data withouot arguments does not work Dec 16, 2024
@AyanSinhaMahapatra
Copy link
Member

@sschuberth please refer to the help text for the command:

scancode-license-data --help
Usage: scancode-license-data [OPTIONS]

  Dump scancode license data in various formats, and the licenseDB static
  website at `path`.

Options:
  --path DIR  Dump the license data in this directory in the LicenseDB format
              and exit. Creates the directory if it does not exist.
  -h, --help  Show this message and exit.

The code is at https://github.com/aboutcode-org/scancode-toolkit/blob/develop/src/licensedcode/license_db.py#L208 btw, as indicated in the traceback.

I think you are not providing the --path <path _to_dump_licenses> option which is causing the issue.
I could do a simple pip install for the latest scancode and this does work allright.

python3 -m venv scancode-32.3
source scancode-32.3/bin/activate
pip install scancode-toolkit==32.3.0
scancode-license-data --help
scancode-license-data --path license-data

Maybe this confusion was caused by inadequate docs? This should probably be included in https://scancode-toolkit.readthedocs.io/en/stable/cli-reference/other-commands.html which is at https://github.com/aboutcode-org/scancode-toolkit/blob/develop/docs/source/cli-reference/other-commands.rst

If you can confirm this, it would be great. We can then convert the issue to enhance the docs on this.

@sschuberth sschuberth changed the title Running scancode-license-data withouot arguments does not work Running scancode-license-data without arguments does not work Dec 17, 2024
@sschuberth
Copy link
Collaborator Author

I can confirm that both scancode-license-data --help and scancode-license-data --path license-data work, but my point is that just running scancode-license-data (without arguments) should not crash. Instead, it should probably just print the help as well.

@AyanSinhaMahapatra
Copy link
Member

We could add more documentation as suggested in #4024 (comment) and probably print a statement to provide path/nudge towards running the help text if someone does not provide a path.

@sschuberth
Copy link
Collaborator Author

sschuberth commented Dec 17, 2024

As no one reads docs, I indeed recommend to "build-in the docs" by making the tool print something meaningful in this case. Thanks!

@pombredanne
Copy link
Member

pombredanne commented Dec 18, 2024

The simplest way is to make the option required with a required=True arg at

@lyr-ast
Copy link

lyr-ast commented Dec 18, 2024

could you look at my pr and see if its fit for merging #4029

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment