Skip to content

Having no system username causes Fabric to error #400

Closed
@bitprophet

Description

@bitprophet

Description

I managed to stumble on this when using an ep.io account.

I have no name!@app-runner02:/mnt/bundles/port-8840/app_image/app$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from fabric.api import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/bundles/port-8840/app_image/pyenv/lib/python2.7/site-packages/fabric/api.py", line 9, in <module>
from fabric.context_managers import cd, hide, settings, show, path, prefix, lcd
File "/bundles/port-8840/app_image/pyenv/lib/python2.7/site-packages/fabric/context_managers.py", line 13, in <module>
from fabric.state import env, output, win32
File "/bundles/port-8840/app_image/pyenv/lib/python2.7/site-packages/fabric/state.py", line 128, in <module>
default=_get_system_username(),
File "/bundles/port-8840/app_image/pyenv/lib/python2.7/site-packages/fabric/state.py", line 75, in _get_system_username
return pwd.getpwuid(os.getuid())[0]
KeyError: 'getpwuid(): uid not found: 26442'    

I'm not sure what the correct behaviour should be, but a better error would indeed help.

As a work around I done something bad:

import pwd; pwd.getpwuid = lambda x: ["Monkey",]

... but it works fine (so far!)

If this username is only being collected to be used as a default when connecting to a remote host it would presumably be better to just make it a required parameter if one is not available? I am overwriting this anyway in my case.


Originally submitted by Dougal Matthews (d0ugal) on 2011-07-28 at 05:20am EDT

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions