-
Notifications
You must be signed in to change notification settings - Fork 384
Closed
Labels
Description
I was helping someone debug a stuck invoke build in Jenkins, where part of the task was to run npm install
def do_npm_install():
run('npm install')The build would hang until we upgrade from 0.12.0 to 0.12.1 after this the build got "unstuck" and a new stack trace surfaced:
File "/web/tasks.py", line 49, in do_npm_install
run('npm install')
File "/usr/local/lib/python3.5/site-packages/invoke/__init__.py", line 27, in run
return Context().run(command, **kwargs)
File "/usr/local/lib/python3.5/site-packages/invoke/context.py", line 53, in run
return runner_class(context=self).run(command, **kwargs)
File "/usr/local/lib/python3.5/site-packages/invoke/runners.py", line 270, in run
raise ThreadException(exceptions)
invoke.exceptions.ThreadException:
Saw 1 exceptions within threads (UnicodeEncodeError):
Thread args: {'kwargs': {'buffer_': [],
'hide': False,
'output': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='ANSI_X3.4-1968'>},
'target': <bound method Runner.handle_stdout of <invoke.runners.Local object at 0x7f7d8d5f7400>>}
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/invoke/runners.py", line 851, in run
super(_IOThread, self).run()
File "/usr/local/lib/python3.5/threading.py", line 871, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/site-packages/invoke/runners.py", line 406, in handle_stdout
indices=threading.local(),
File "/usr/local/lib/python3.5/site-packages/invoke/runners.py", line 376, in _handle_output
output.write(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 463-471: ordinal not in range(128)
It seems that npm was trying to print and ASCII charset to STDOUT and Invoke didn't like that. The work around is to pipe stdout and stderr into a text file so Invoke never sees it. However, this bug should probably be fixed.
def do_npm_install():
run('npm install 2>&1 > npm_install.log')