deluan / zsh-in-docker

Install Zsh, Oh My Zsh and plugins inside a Docker container with one line!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple executions fail.

mikebronner opened this issue · comments

When trying to run this command multiple times, let's say rebuilding a container, but not clearing the data from the volume, it throws the following error:

sh -c "$(curl -L https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \                                                                                ─╯
    -p git \
    -p https://github.com/zsh-users/zsh-autosuggestions /home/sail/.oh-my-zsh/custom/plugins/zsh-autosuggestions \
    -p https://github.com/MichaelAquilina/zsh-you-should-use /home/sail/.oh-my-zsh/custom/plugins/you-should-use \
    -p https://github.com/zsh-users/zsh-syntax-highlighting /home/sail/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting \
    -p https://github.com/zsh-users/zsh-completions /home/sail/.oh-my-zsh/custom/plugins/zsh-completions
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3828  100  3828    0     0   4497      0 --:--:-- --:--:-- --:--:--  7748

Installing Oh-My-Zsh with:
  THEME   = default
  PLUGINS = git https://github.com/zsh-users/zsh-autosuggestions 

###### Installing dependencies for ubuntu
/usr/bin/sudo
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease                                                                             
Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease                                                                           
Hit:4 https://dl.yarnpkg.com/debian stable InRelease                                                                                       
Hit:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease                                                                           
Hit:6 https://deb.nodesource.com/node_18.x jammy InRelease                                                                       
Hit:7 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease         
Hit:8 http://apt.postgresql.org/pub/repos/apt jammy-pgdg InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
zsh is already the newest version (5.8.1-1).
curl is already the newest version (7.81.0-1ubuntu1.6).
git is already the newest version (1:2.34.1-1ubuntu1.5).
locales is already the newest version (2.35-0ubuntu3.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
locales-all is already the newest version (2.35-0ubuntu3.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
fatal: destination path '/home/sail/.oh-my-zsh/custom/plugins/zsh-autosuggestions' already exists and is not an empty directory.

Is there a better way to handle this to automatically skip plugins that are already installed? Here is my RUN command:

USER sail
RUN sh -c "$(curl -L https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \
    -p git \
    -p https://github.com/zsh-users/zsh-autosuggestions \
    -p https://github.com/MichaelAquilina/zsh-you-should-use \
    -p https://github.com/zsh-users/zsh-syntax-highlighting \
    -p https://github.com/zsh-users/zsh-completions
USER root
sh -c "$(curl -L https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \
    -p git \
    -p https://github.com/zsh-users/zsh-autosuggestions /home/sail/.oh-my-zsh/custom/plugins/zsh-autosuggestions \
    -p https://github.com/MichaelAquilina/zsh-you-should-use /home/sail/.oh-my-zsh/custom/plugins/you-should-use \
    -p https://github.com/zsh-users/zsh-syntax-highlighting /home/sail/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting \
    -p https://github.com/zsh-users/zsh-completions /home/sail/.oh-my-zsh/custom/plugins/zsh-completions

Is this the command you are using? It seems invalid, as you have duplicated items, with both URL and local files.

Is there a better way to handle this to automatically skip plugins that are already installed? Here is my RUN command:

This is not a use case the script handles as it is meant to be called only from a Dockerfile and the plugins will only be already installed if you installed them yourself in a previous step, which defeats the purpose of the script.

@deluan thanks for your quick reply! We are using this in Dockerfile, but its for a Github Codespaces container, and it appears to break when rebuilding the container without first deleting it. With some tinkering I got it to work without erring on rebuild:

USER sail
RUN sh -c "$(curl -L https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \
    -p git \
    -p https://github.com/jessarcher/zsh-artisan \
    -p https://github.com/zsh-users/zsh-autosuggestions \
    -p https://github.com/MichaelAquilina/zsh-you-should-use \
    -p https://github.com/zsh-users/zsh-syntax-highlighting \
    -p https://github.com/zsh-users/zsh-completions
RUN mv /home/sail/.oh-my-zsh/custom/plugins/zsh-you-should-use /home/sail/.oh-my-zsh/custom/plugins/you-should-use
RUN mv /home/sail/.oh-my-zsh/custom/plugins/zsh-artisan /home/sail/.oh-my-zsh/custom/plugins/artisan
USER root

COPY .zshrc /home/sail/.zshrc

This works as I copy over a custom pre-built .zshrc file after these are installed.

Thanks for this package :) !