Skip to content

Commit

Permalink
Avoid having to use sudo with pip
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuxel committed Jan 18, 2020
1 parent 892e344 commit 797aef8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ RUN apt-get update \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME \
#
# Avoid having to use "sudo" with pip when running as non-root user
&& echo 'if [ "$(stat -c %U /usr/local/bin)" != "$(id -u)" ]; then \
sudo chown -R $(id -u):root /usr/local/lib/python*/site-packages \
&& sudo chown -R $(id -u):root /usr/local/bin; \
fi' | tee -a /home/$USERNAME/.bashrc /home/$USERNAME/.zshrc \
&& chown $USERNAME /home/$USERNAME/.bashrc /home/$USERNAME/.zshrc \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
Expand Down

0 comments on commit 797aef8

Please sign in to comment.