Closed Bug 1300577 Opened 8 years ago Closed 6 years ago

"error: must call (at least) setupterm() first" in blessings when running mach lint/mach eslint

Categories

(Developer Infrastructure :: Lint and Formatting, defect, P5)

47 Branch
defect

Tracking

(firefox59 fixed)

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: janx, Assigned: ahal)

References

Details

(Keywords: thirdparty)

Attachments

(2 files)

Steps to reproduce:

    git clone https://github.com/mozilla/gecko-dev
    cd gecko-dev
    ./mach eslint --setup

Expected result:

    eslint is successfully set up.

Actual result:

    abort: no repository found in '/home/user/firefox' (.hg not found)!
    Error running mach:
    
        ['eslint', '--setup']
    
    The error occurred in code that was called by the mach command. This is either
    a bug in the called code itself or in the way that mach is calling it.
    
    You should consider filing a bug for this issue.
    
    If filing a bug, please include the full output of mach, including this error
    message.
    
    The details of the failure are as follows:
    
    error: must call (at least) setupterm() first
    
      File "/home/user/firefox/tools/lint/mach_commands.py", line 60, in eslint
        linters=['eslint'], paths=paths, **kwargs)
      File "/home/user/firefox/python/mach/mach/registrar.py", line 123, in dispatch
        return self._run_command_handler(handler, context=context, **kwargs)
      File "/home/user/firefox/python/mach/mach/registrar.py", line 90, in _run_command_handler
        result = fn(**kwargs)
      File "/home/user/firefox/tools/lint/mach_commands.py", line 42, in lint
        return cli.run(*runargs, **lintargs)
      File "/home/user/firefox/python/mozlint/mozlint/cli.py", line 103, in run
        formatter = formatters.get(fmt)
      File "/home/user/firefox/python/mozlint/mozlint/formatters/__init__.py", line 25, in get
        return all_formatters[name](**fmtargs)
      File "/home/user/firefox/python/mozlint/mozlint/formatters/stylish.py", line 53, in __init__
        self.num_colors = self.term.number_of_colors
      File "/home/user/firefox/python/blessings/blessings/__init__.py", line 257, in number_of_colors
        colors = tigetnum('colors')  # Returns -1 if no color support, -2 if no such cap.
Patrick, do you know who handles eslint setup bugs nowadays?
Flags: needinfo?(pbrosset)
Component: Build Config → Lint
Flags: needinfo?(pbrosset) → needinfo?(ahalberstadt)
Product: Core → Testing
I wasn't able to reproduce this. The '.hg not found' error is a red herring. Mozlint first tries to run `hg root`, and if that fails, runs `git rev-parse --show-toplevel`. We should redirect stderr to prevent that hg warning from showing up.

Jan, what is the output of:
<objdir>/_virtualenv/bin/pip freeze

I suspect this might be due to an old version of blessings or something. P.s, |mach eslint| will now just run the setup function automatically if you don't have the proper versions, so --setup isn't really necessary anymore.
Flags: needinfo?(ahalberstadt) → needinfo?(janx)
See Also: → 1300779
Thanks for your replies.

I don't currently have an <objdir>, as I haven't built Firefox in the repository yet, but:

    $ pip freeze
    You are using pip version 8.1.1, however version 8.1.2 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    dblatex==0.3.7.post1
    meld3==1.0.2
    mercurial==3.7.3
    pygobject==3.20.0
    python-apt==1.1.0b1
    requests==2.11.1
    supervisor==3.2.0

Also, running `pip install --upgrade pip` doesn't fix my problem.
Flags: needinfo?(janx)
It looks like you might be hitting an open issue in blessings:
https://github.com/erikrose/blessings/issues/39

What is your $TERM set to? I don't really understand the bug there though, Erik do you have any hints here?

Jan, in the meantime as a workaround you can run:
./mach lint -l eslint -f treeherder <path>

And that will both handle the setup for you and bypass the problem by using a formatter that doesn't use of blessings.
Flags: needinfo?(erik)
Summary: "./mach eslint --setup" no longer works in Git repositories → "error: must call (at least) setupterm() first" in blessings when running mach lint/mach eslint
This is a pretty deep bug on the blessings end, so I don't have an estimate of when it'll be fixed. In the meantime, you can work around it by setting TERM to something valid, like 'ansi'. In the worst case, you get some invalid escape sequences looking garbagey on your terminal.
Flags: needinfo?(erik)
I use mach eslint together with vim's makeprg and errorformat, which seemed to have worked before but now doesn't. I can consistently reproduce this using ./mach eslint -f compact | cat

The github issue is fixed in the blessed-integration branch for over a year, what are the chances of that branch being merged? It would be great to get this fixed.
Somewhat unrelated, but |mach eslint -f compact| won't work anymore even with this issue fixed since bug 1258341. This is because |mach eslint| no longer directly calls the eslint binary, but goes through a framework called mozlint[1]. mozlint reads structured JSON output from eslint and now handles the formatting itself. Good news is support for the compact formatter can be relatively easy to add, and doesn't even need to depend on blessings, so this issue is probably irrelevant to your needs.

As a workaround, try using -f treeherder instead of -f compact, and see if it works then. Also feel free to file a bug about the compact formatter under Testing::Lint if the treeherder formatter doesn't cut it.

[1] http://gecko.readthedocs.io/en/latest/tools/lint/index.html
Ah, I was already wondering why --no-color doesn't work anymore, this explains it! I've adapted my script to the treeherder output format, that works fine for me. Therefore I don't need the compact formatter.

If you are curious, put this in your ~/.vim/compiler/mach-eslint.vim 

CompilerSet errorformat=TEST-UNEXPECTED-WARNING\ \|\ %f:%l:%c\ \|\ %m
CompilerSet makeprg=./mach\ lint\ -l\ eslint\ -f\ treeherder

then run :compiler mach-eslint and one of :make / :make path/to/file / :make %

Thanks for the hints!
Awesome, I was actually planning to look into vim integration soon. You could probably remove the "-l eslint" argument and let mozlint figure out which linters to run on the given file automatically. Doing this probably wouldn't benefit you in the short term (unless you also edit python files regularly), but may in the future if new linters get added.
Priority: -- → P5
Keywords: thirdparty
Attached patch Workaround - v1Splinter Review
Can we workaround this issue using something like this? Aside from the vim issue I worked around, I hit this simply when doing ./mach eslint > issues.txt. I've tried various values of TERM but they all don't work for me.
Attachment #8938317 - Flags: feedback?(erik)
I submitted a related PR for this:
https://github.com/erikrose/blessings/pull/125

I *think* that should fix the issue in here too, though haven't tested.

Fallen, btw if you set $EDITOR=vim and run ./mach lint --edit, that should now automatically open up errors in vim's quickfix window.
We could use this bug to track updating blessings once that PR reaches a release.
The PR is released in version 1.6.1: https://pypi.python.org/pypi/blessings/. I've also released wheels, so you should be able to enjoy quicker installs if you wish.
Comment on attachment 8938317 [details] [diff] [review]
Workaround - v1

(In reply to Andrew Halberstadt [:ahal] from comment #11)
> I submitted a related PR for this:
> https://github.com/erikrose/blessings/pull/125
> 
> I *think* that should fix the issue in here too, though haven't tested.
Sounds great, thanks for working on this!

> Fallen, btw if you set $EDITOR=vim and run ./mach lint --edit, that should
> now automatically open up errors in vim's quickfix window.
Ah perfect, I like it! Thanks for the tip :)
Attachment #8938317 - Flags: feedback?(erik)
Assignee: nobody → ahalberstadt
Status: NEW → ASSIGNED
Comment on attachment 8940804 [details]
Bug 1300577 - Upgrade blessings to version 1.6.1,

https://reviewboard.mozilla.org/r/211066/#review216848
Attachment #8940804 - Flags: review?(gps) → review+
Pushed by ahalberstadt@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/176e82e199fe
Upgrade blessings to version 1.6.1, r=gps
https://hg.mozilla.org/mozilla-central/rev/176e82e199fe
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
Product: Testing → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: