Poetry: Bash completion permission denied

Created on 3 Apr 2019  路  5Comments  路  Source: python-poetry/poetry

  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] I have searched the documentation and believe that my question is not covered.

Question

When I attempt to run the bash one liner to enable Bash completion, I get a permission denied message.

```$ poetry completions bash > /etc/bash_completion.d/poetry.bash-completion
bash: /etc/bash_completion.d/poetry.bash-completion: Permission denied

I also attempted this with `sudo` (I know I shouldn't...)

$ sudo poetry completions bash > /etc/bash_completion.d/poetry.bash-completion
bash: /etc/bash_completion.d/poetry.bash-completion: Permission denied
```

Other than this, poetry seems to be working fine.

Most helpful comment

The solution proposed by @pmav99 almost worked for me, but instead of redirecting the output using >, the output should be piped to sudo tee ...:

poetry completions bash | sudo tee /etc/bash_completion.d/poetry.bash-completion

All 5 comments

The way you do it, the process that tries to write the file does not have root permissions.

You can use tee. Try:

poetry completions bash > sudo tee /etc/bash_completion.d/poetry.bash-completion

box@dev1:~$ poetry completions bash > sudo tee /etc/bash_completion.d/poetry.bash-completion
/home/box/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
  "program uses threads.", RuntimeWarning)

[TooManyArguments]
Too many arguments.

completions [--alias ALIAS] [--] [<shell>]

I got this same issue on a fresh Ubuntu 18.04 box after installing latest poetry (0.12.17) -- maybe this should be fixed in the docs?

(I ended up first piping the output to a temporary file I could write to and then copying that in place.)

+1 I get the same error on Ubuntu 16.04

The solution proposed by @pmav99 almost worked for me, but instead of redirecting the output using >, the output should be piped to sudo tee ...:

poetry completions bash | sudo tee /etc/bash_completion.d/poetry.bash-completion

instead of redirecting the output using >, the output should be piped to sudo tee ...

This is normal, that's because man tee' actually statestee - read from standard input and write to standard output and files... Basicallyteeis a "fork", a "duplicator" to pipe the output BOTH on console, AND on a given file path; of course redirecting the output doesn't work, sinceteedoes not get it's inputs from redirects but rather from stanard input, aka/dev/stdin, which is the default pipe (|`) output.

TL;DR:
tee works ONLY when piping (|) into it. (@pmav99 take note :wink:)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ambv picture ambv  路  3Comments

Euphorbium picture Euphorbium  路  3Comments

probablykasper picture probablykasper  路  3Comments

nikaro picture nikaro  路  3Comments

ulope picture ulope  路  3Comments