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

coala -B --json fails #4881

Open
SanketDG opened this issue Nov 18, 2017 · 20 comments · May be fixed by #5170
Open

coala -B --json fails #4881

SanketDG opened this issue Nov 18, 2017 · 20 comments · May be fixed by #5170

Comments

@SanketDG
Copy link
Member

SanketDG commented Nov 18, 2017

Fresh install of coala and coala-bears master on a new venv:

Then I run coala -B --json

[WARNING][11:33:59] Implicit 'Default' section inheritance is deprecated. It will be removed soon. To silence this warning remove settings in the 'Default' section from your coafile. You can use dots to specify inheritance: the section 'all.python' will inherit all settings from 'all'.
[ERROR][11:34:02] An unknown error occurred. This is a bug. We are sorry for the inconvenience. Please contact the developers for assistance. During execution of coala an exception was raised. This should never happen. When asked for, the following information may help investigating:
[INFO][11:34:02] Exception was:
Traceback (most recent call last):

  File "/home/sanketdg/projects/coala/coalib/coala.py", line 84, in main
    args)

  File "/home/sanketdg/projects/coala/coalib/output/ConsoleInteraction.py", line 990, in show_bears
    print_bears(bears, show_description, show_params, console_printer, args)

  File "/home/sanketdg/projects/coala/coalib/output/ConsoleInteraction.py", line 950, in print_bears
    separators=(',', ': '))

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 201, in encode
    chunks = list(chunks)

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 430, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
    yield from chunks

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 325, in _iterencode_list
    yield from chunks

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 438, in _iterencode
    yield from _iterencode(o, _current_indent_level)

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 430, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
    yield from chunks

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 438, in _iterencode
    yield from _iterencode(o, _current_indent_level)

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 428, in _iterencode
    yield from _iterencode_list(o, _current_indent_level)

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 325, in _iterencode_list
    yield from chunks

  File "/home/sanketdg/.pyenv/versions/3.6.1/lib/python3.6/json/encoder.py", line 437, in _iterencode
    o = _default(o)

  File "/home/sanketdg/projects/coala/coalib/output/JSONEncoder.py", line 32, in default
    for member in get_public_members(obj)}

  File "/home/sanketdg/.pyenv/versions/3.6.1/envs/coala/lib/python3.6/site-packages/coala_utils/decorators.py", line 134, in get_public_members
    return {attr: getattr(obj, attr) for attr in dir(obj)

  File "/home/sanketdg/.pyenv/versions/3.6.1/envs/coala/lib/python3.6/site-packages/coala_utils/decorators.py", line 136, in <dictcomp>
    and not hasattr(getattr(obj, attr), '__call__')}

  File "/home/sanketdg/.pyenv/versions/3.6.1/envs/coala/lib/python3.6/site-packages/dependency_management/requirements/DistributionRequirement.py", line 205, in package_managers
    self.get_package_managers())

  File "/home/sanketdg/.pyenv/versions/3.6.1/envs/coala/lib/python3.6/site-packages/dependency_management/requirements/DistributionRequirement.py", line 193, in get_package_managers
    '{}'.format(','.join(self.packages.keys())))

NotImplementedError: This platform doesn't have any of the specified package manager(s): apt_get
@SanketDG SanketDG changed the title master fails on Fedora 26 coala -B --json fails Nov 18, 2017
@Makman2
Copy link
Member

Makman2 commented Nov 18, 2017

Which OS are you running on? Seems for me we haven't adapted some requirement for your platform^^

@SanketDG
Copy link
Member Author

Fedora 26, previously used yum (till 21 iirc), now uses dnf

@Makman2
Copy link
Member

Makman2 commented Nov 19, 2017

Confirmed, I get the same ;)

@Makman2
Copy link
Member

Makman2 commented Nov 19, 2017

CC @shreyans800755 , as it is caused by the --show-bears and --json options 👍

@shreyans800755
Copy link
Contributor

@Makman2 @SanketDG
I'm getting all the bears in json format as expected. I'm on ubuntu 16.04 system. Can this be specific to your system ?

@SanketDG
Copy link
Member Author

Yeah, probably, but I cant seem to find where exactly is DistributionRequirement used....

@shreyans800755
Copy link
Contributor

shreyans800755 commented Nov 25, 2017

I've created a PR to test this scenario on CI at #4913.
It looks like it is giving the same error as you are getting but with different package manager - brew.

Ref https://travis-ci.org/coala/coala/jobs/307175601#L1659
Same error is there on Circle as well.

@SanketDG @Makman2

shreyans800755 added a commit to shreyans800755/coala that referenced this issue Dec 3, 2017
@newbazz
Copy link
Contributor

newbazz commented Jan 10, 2018

I would like to work on this issue.

@Makman2
Copy link
Member

Makman2 commented Jan 10, 2018

Unassigning due to inactivity.

@Makman2 Makman2 assigned newbazz and unassigned shreyans800755 Jan 10, 2018
@saksham189
Copy link
Contributor

saksham189 commented Feb 10, 2018

I would like to fix this. @newbazz are you working on this?

@newbazz
Copy link
Contributor

newbazz commented Feb 10, 2018

yes you can take the issue.

@saksham189
Copy link
Contributor

saksham189 commented Feb 12, 2018

So far while exploring the traceback I have figured out that the issue is caused by package_managers attribute of the object. Calling getattr(obj, 'package_managers') is actually checking whether the package is installed or not and failing at this point. This is run from decorator.py inside the coala_utils folder inside my virtualenv.
Could you please tell me which files I am allowed to edit? @Makman2

@Makman2
Copy link
Member

Makman2 commented Feb 12, 2018

All that are necessary ;)

@Makman2 Makman2 assigned saksham189 and unassigned newbazz Feb 12, 2018
@saksham189
Copy link
Contributor

saksham189 commented Feb 13, 2018

I believe this is causing coala/coala-eclipse#44 (failing test for coala-eclipse plugin)
The test is trying to get all the bears by running coala -B --json

@saksham189
Copy link
Contributor

saksham189 commented Feb 13, 2018

What is the correct output for this command? Do you get the list of bears in JSON format or do also get some other information such as this:

"ASCIINEMA_URL": "https://asciinema.org/a/89021", "AUTHORS": [ "The coala developers" ], "AUTHORS_EMAILS": [ "[email protected]" ], "BEAR_DEPS": [], "CAN_DETECT": [], "CAN_FIX": [ "Formatting" ], "INCLUDE_LOCAL_FILES": [], "LANGUAGES": [ "Python 3", "Python", "Python 2" ], "LICENSE": "AGPL-3.0", "MAINTAINERS": [], "MAINTAINERS_EMAILS": [], "PLATFORMS": [ "any"

@Makman2
Copy link
Member

Makman2 commented Feb 13, 2018

Good question. --json usually means that someone wants more, computer-readable / -serializable information, but without --json only the bear names are displayed. @anctartica up to you to decide the correct behaviour, but in my opinion the extra info is good and useful if someone already uses --json.

@shreyans800755
Copy link
Contributor

@Makman2 @anctartica
coala -B --json works on my local. It is showing all the details and just names.

But the behaviour is inconsistent with coala -B which only shows the names of the bears and not the details.
Content wise, output of coala -B --json matches with the output of coala -B --show-details.

To keep the consistency, we should only display the names of the bears unless details are asked using other args. However, I think it is outside of the scope of this issue. So, I've created another issue for that at #5156.
@Makman2 Can you block the new issue on this one and mark it as bug as well ?

@Makman2
Copy link
Member

Makman2 commented Feb 13, 2018

But I think that one is not really a bug, rather an enhancement or "feature".

@saksham189
Copy link
Contributor

If I have to update files in coala_utils to fix this issue then would this issue have to be closed here and opened in the coala_utils repo which is on gitlab?

@Makman2
Copy link
Member

Makman2 commented Feb 14, 2018

Why coala-utils? This shouldn't require changes there

saksham189 added a commit to saksham189/coala that referenced this issue Feb 15, 2018
coala -B --json command fails while accessing
package_managers attribute. This should be handled
in JSONEncoder.

Closes coala#4881
@saksham189 saksham189 linked a pull request Feb 15, 2018 that will close this issue
2 tasks
saksham189 added a commit to saksham189/coala that referenced this issue Feb 15, 2018
coala -B --json command fails while accessing
package_managers attribute. This should be handled
in JSONEncoder.

Closes coala#4881
saksham189 added a commit to saksham189/coala that referenced this issue Feb 15, 2018
coala -B --json command fails while accessing
package_managers attribute. This should be handled
in JSONEncoder.

Closes coala#4881
gitmate-bot pushed a commit to saksham189/coala that referenced this issue Mar 10, 2018
coala -B --json command fails while accessing
package_managers attribute. This should be handled
in JSONEncoder.

Closes coala#4881
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

6 participants