Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh-plugin not working in combination with non-root container-user #579

Open
schoelst opened this issue Feb 12, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@schoelst
Copy link

schoelst commented Feb 12, 2024

Feature id and version

ghcr.io/devcontainers-contrib/features/zsh-plugins:0.0.4

Devcontainer base Image

python:3.10

What happened?

If I set the containerUser and remoteUser to vscode the zsh-plugin stops working. The default shell is set to zsh and oh-my-zsh and the .zshrc seem to be set up correctly, however, with the wrong user rights (root, see output). A re-owning at the end of the install script should solve the matter.

For the sake of completeness I create the vscode user like so (extract from Dockerfile):

ARG USERNAME=vscode
ARG USER_UID=1001
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
    && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
    # Add sudo support.
    && apt-get update \
    && apt-get install -y sudo \
    && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
    && chmod 0440 /etc/sudoers.d/$USERNAME

Also the location of the home dir is derived in a fragile manner in the install script (/home/$USERNAME) consider reading its location from the users $HOME.

Relevant log output

9bbbba51e624% pwd
/home/vscode
9bbbba51e624% ls -lha
total 16K
drwxr-xr-x. 1 vscode vscode  175 Feb 12 08:14 .
drwxr-xr-x. 1 root   root     20 Feb 12 08:13 ..
-rw-r--r--. 1 vscode vscode  220 Apr 23  2023 .bash_logout
-rw-r--r--. 1 vscode vscode 3.5K Apr 23  2023 .bashrc
drwxr-xr-x. 3 vscode vscode   24 Feb 12 08:13 .cache
drwxr-xr-x. 2 vscode vscode   37 Feb 12 08:14 .dbclient
drwxr-xr-x. 2 vscode vscode  103 Feb 12 08:13 .devcontainer
-rw-r--r--. 1 vscode vscode  299 Feb 12 08:13 .gitconfig
drwx------. 2 vscode vscode   82 Feb 12 08:13 .gnupg
drwxr-xr-x. 3 root   root     20 Feb 12 08:13 .oh-my-zsh
-rw-r--r--. 1 vscode vscode  807 Apr 23  2023 .profile
drwxr-xr-x. 2 vscode vscode   25 Feb 12 08:13 .ssh
drwxr-xr-x. 6 vscode vscode   70 Feb 12 08:13 .vscode-server
-rw-r--r--. 1 root   root      0 Feb 12 08:13 .zshrc

EDIT: Adjusted command used to create vscode user.

@schoelst schoelst added the bug Something isn't working label Feb 12, 2024
@schoelst
Copy link
Author

Here is my work around: After adding the following to my devcontainers.json it works now:

"postCreateCommand": " sudo cp /root/.zshrc /home/vscode && sudo cp -r /root/.oh-my-zsh /home/vscode && sudo chown -R vscode:vscode /home/vscode"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant