Add rule for pip_install permission fix (#895)

* Add rule for pip_install permission fix

* Fix whitespace

* Switch quotation to single

* remove 2nd else

* E261 indent comment
This commit is contained in:
Inga Feick
2019-04-24 18:15:38 +02:00
committed by Vladimir Iakovlev
parent 828ae537da
commit 82902fb50d
3 changed files with 43 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
from thefuck.utils import for_app
from thefuck.specific.sudo import sudo_support
@sudo_support
@for_app('pip')
def match(command):
return ('pip install' in command.script and 'Permission denied' in command.output)
def get_new_command(command):
if '--user' not in command.script: # add --user (attempt 1)
return command.script.replace(' install ', ' install --user ')
return 'sudo {}'.format(command.script.replace(' --user', '')) # since --user didn't fix things, let's try sudo (attempt 2)