Bug 2036710 - colin can't find its rulesets
Summary: colin can't find its rulesets
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: colin
Version: 36
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: user-cont bot
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-03 16:00 UTC by "FeRD" (Frank Dana)
Modified: 2022-03-26 15:21 UTC (History)
5 users (show)

Fixed In Version: colin-0.5.3-1.fc34 colin-0.5.3-1.fc35 colin-0.5.3-1.fc36
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-03-22 03:18:54 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description "FeRD" (Frank Dana) 2022-01-03 16:00:47 UTC
Description of problem:
The installed `colin` command can't find its rulesets, due to the installed location not being in its search path.

Version-Release number of selected component (if applicable):
colin-0.5.0-3.fc35.noarch


How reproducible:
100%

Steps to Reproduce:
1. sudo dnf install colin
2. colin list-checks
3. colin list-rulesets

Actual results:

$ colin list-checks  
10:53:34.549 ruleset.py        WARNING Ruleset directory cannot be found.
10:53:34.549 colin.py          ERROR  An error occurred: ColinRulesetException('Ruleset directory cannot be found.')
Error: Ruleset directory cannot be found.

$ colin list-rulesets
Ruleset directory cannot be found.
An error occurred: ColinRulesetException('Ruleset directory cannot be found.')
Error: Ruleset directory cannot be found.


Expected results:
colin lists the installed rulesets.

Additional info:
The rulesets _are_ installed (via the package python3-colin-0.5.0-3.fc35.noarch), however they're located in /usr/share/colin/, which is not one of the default search paths:

$ rpm -ql python3-colin|grep -i rule |grep -v pycache
/usr/lib/python3.10/site-packages/colin/core/ruleset
/usr/lib/python3.10/site-packages/colin/core/ruleset/__init__.py
/usr/lib/python3.10/site-packages/colin/core/ruleset/loader.py
/usr/lib/python3.10/site-packages/colin/core/ruleset/ruleset.py
/usr/share/colin/rulesets
/usr/share/colin/rulesets/default.json
/usr/share/colin/rulesets/fedora.json

$ pydoc3 colin.core.ruleset.ruleset.get_ruleset_dirs|cat
Help on function get_ruleset_dirs in colin.core.ruleset.ruleset:

colin.core.ruleset.ruleset.get_ruleset_dirs = get_ruleset_dirs()
    Get the directory with ruleset files
===>First directory to check:  ./rulesets                         <===
===>Second directory to check:  $HOME/.local/share/colin/rulesets <===
===>Third directory to check: /usr/local/share/colin/rulesets     <===
    :return: str


When I briefly had colin installed in my user site dir via `python3 -m pip install --force --user colin`, the default rulesets were present in `$HOME/.local/share/colin/rulesets`, and colin (even the /usr/bin/colin system install) _WAS_ able to find them. But when I removed the pip-installed package, it went right back to "Error: Ruleset directory cannot be found."

Comment 1 Frantisek Lachman 2022-01-05 08:47:14 UTC
Hi Frank,

thank you for the well-described bug. I will take a look at how to fix that.

In the meantime, you can try using `--ruleset-file`/`-f` option and specify the next path.

František

Comment 2 "FeRD" (Frank Dana) 2022-01-05 08:58:59 UTC
(In reply to Frantisek Lachman from comment #1)

Thanks, sounds good!

Looking at the code, in core/ruleset/ruleset.py you can probably replace that hardcoded `/usr/local/` on line 219 with `sys.prefix` — or add that as a fourth location to examine, if you prefer. So:

    import sys
    installed_sharedata = os.path.join(sys.prefix, RULESET_DIRECTORY)
    if os.path.isdir(installed_sharedata):
        logger.debug("Global ruleset directory found ('%s').", installed_sharedata)
        ruleset_dirs.append(installed_sharedata)

Comment 3 Frantisek Lachman 2022-01-05 09:24:44 UTC
Thanks for the hints. Since you have looked into the code already, are you interested in contributing that change upstream? (https://github.com/user-cont/colin/)

I can do that otherwise. (I am also an upstream maintainer so we can create a new fix release afterwards.)

František

Comment 4 Frantisek Lachman 2022-01-10 09:14:25 UTC
Hello,

the problem is fixed upstream: https://github.com/user-cont/colin/pull/285

and I'm creating a new upstream release: https://github.com/user-cont/colin/pull/286

František

Comment 5 Ben Cotton 2022-02-08 21:14:04 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 36 development cycle.
Changing version to 36.

Comment 6 Fedora Update System 2022-03-14 21:20:39 UTC
FEDORA-2022-10a5e6feb3 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2022-10a5e6feb3

Comment 7 Fedora Update System 2022-03-14 21:21:45 UTC
FEDORA-2022-a96eb84ac3 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-a96eb84ac3

Comment 8 Fedora Update System 2022-03-14 21:22:38 UTC
FEDORA-2022-5cbfa848e8 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-5cbfa848e8

Comment 9 Fedora Update System 2022-03-14 23:14:02 UTC
FEDORA-2022-10a5e6feb3 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-10a5e6feb3`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-10a5e6feb3

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2022-03-14 23:44:45 UTC
FEDORA-2022-a96eb84ac3 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-a96eb84ac3`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-a96eb84ac3

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2022-03-15 15:15:48 UTC
FEDORA-2022-5cbfa848e8 has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-5cbfa848e8`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-5cbfa848e8

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 12 Fedora Update System 2022-03-22 03:18:54 UTC
FEDORA-2022-10a5e6feb3 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 Fedora Update System 2022-03-22 03:41:44 UTC
FEDORA-2022-a96eb84ac3 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 14 Fedora Update System 2022-03-26 15:21:46 UTC
FEDORA-2022-5cbfa848e8 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.