diff --git a/NOTICE.txt b/NOTICE.txt index f7f0a645..3fcbd800 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -8772,3 +8772,62 @@ THE SOFTWARE. --------------------------------------------------------- + +--------------------------------------------------------- + +ruby-build - MIT +https://github.com/rbenv/ruby-build + + +Copyright (c) 2012-2013 Sam Stephenson + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +--------------------------------------------------------- + +--------------------------------------------------------- + +rbenv - MIT +https://github.com/rbenv/rbenv + + +Copyright (c) 2013 Sam Stephenson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +--------------------------------------------------------- \ No newline at end of file diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh index 4fadadbc..7a8e1339 100755 --- a/containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh @@ -6,7 +6,7 @@ # # Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/ruby.md # -# Syntax: ./ruby-debian.sh [Ruby version] [non-root user] [Add rvm to rc files flag] [Install tools flag] +# Syntax: ./ruby-debian.sh [Ruby version] [non-root user] [Add to rc files flag] [Install tools flag] RUBY_VERSION=${1:-"latest"} USERNAME=${2:-"automatic"} @@ -57,8 +57,12 @@ fi function updaterc() { if [ "${UPDATE_RC}" = "true" ]; then - echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc + echo "Updating /etc/bash.bashrc..." + echo -e "$1" >> /etc/bash.bashrc + if [ -d "/etc/zsh" ]; then + echo "Updating /etc/zsh/zshrc..." + echo -e "$1" >> /etc/zsh/zshrc + fi fi } @@ -92,13 +96,42 @@ else su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system" rm -rf ${GNUPGHOME} fi + if [ "${INSTALL_RUBY_TOOLS}" = "true" ] && [ "${SKIP_GEM_INSTALL}" != "true" ]; then - su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && gem install ${DEFAULT_GEMS}" + # Non-root user may not have "gem" in path when script is run and no ruby version + # is installed by rvm, so handle this by using root's default gem in this case + ROOT_GEM="$(which gem)" + su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && \"$(which gem || ${ROOT_GEM})\" install ${DEFAULT_GEMS}" fi # VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it updaterc "if ! grep rvm_silence_path_mismatch_check_flag \$HOME/.rvmrc > /dev/null 2>&1; then echo 'rvm_silence_path_mismatch_check_flag=1' >> \$HOME/.rvmrc; fi\nsource /usr/local/rvm/scripts/rvm" +# Install rbenv/ruby-build for good measure +git clone --depth=1 \ + -c core.eol=lf \ + -c core.autocrlf=false \ + -c fsck.zeroPaddedFilemode=ignore \ + -c fetch.fsck.zeroPaddedFilemode=ignore \ + -c receive.fsck.zeroPaddedFilemode=ignore \ + https://github.com/rbenv/rbenv.git /usr/local/share/rbenv 2>&1 +ln -s /usr/local/share/rbenv/bin/rbenv /usr/local/bin +updaterc 'eval "$(rbenv init -)"' +git clone --depth=1 \ + -c core.eol=lf \ + -c core.autocrlf=false \ + -c fsck.zeroPaddedFilemode=ignore \ + -c fetch.fsck.zeroPaddedFilemode=ignore \ + -c receive.fsck.zeroPaddedFilemode=ignore \ + https://github.com/rbenv/ruby-build.git /usr/local/share/ruby-build 2>&1 +mkdir -p /root/.rbenv/plugins +ln -s /usr/local/share/ruby-build /root/.rbenv/plugins/ruby-build +if [ "${USERNAME}" != "root" ]; then + mkdir -p /home/${USERNAME}/.rbenv/plugins + chown -R ${USERNAME} /home/${USERNAME}/.rbenv + ln -s /usr/local/share/ruby-build /home/${USERNAME}/.rbenv/plugins/ruby-build +fi + # Clean up source /usr/local/rvm/scripts/rvm rvm cleanup all diff --git a/containers/codespaces-linux/README.md b/containers/codespaces-linux/README.md index f12bc1c8..0e427f5b 100644 --- a/containers/codespaces-linux/README.md +++ b/containers/codespaces-linux/README.md @@ -21,7 +21,7 @@ While language specific development containers can be useful, in some cases you If you use GitHub Codespaces, this is the "universal" image that is used by default if no custom Dockerfile or image is specified. If you like what you see but want to make a few additions or changes, you can use a custom Dockerfile to extend it and add whatever you need. -The container includes the `zsh` (and Oh My Zsh!) and `fish` shells that you can opt into using instead of the default `bash`. It also includes [nvm](https://github.com/nvm-sh/nvm), [rvm](https://rvm.io/), and [SDKMAN!](https://sdkman.io/) if you need to install a different version Node, Ruby, or Java tools than the container defaults. You can also set things up to access the container [via SSH](#accessing-the-container-using-ssh-scp-or-sshfs). +The container includes the `zsh` (and Oh My Zsh!) and `fish` shells that you can opt into using instead of the default `bash`. It also includes [nvm](https://github.com/nvm-sh/nvm), [rvm](https://rvm.io/), [rbenv](https://github.com/rbenv/rbenv), and [SDKMAN!](https://sdkman.io/) if you need to install a different version Node, Ruby, or Java tools than the container defaults. You can also set things up to access the container [via SSH](#accessing-the-container-using-ssh-scp-or-sshfs). ## Accessing the container using SSH, SCP, or SSHFS diff --git a/containers/codespaces-linux/definition-manifest.json b/containers/codespaces-linux/definition-manifest.json index 8d072476..e7541cb6 100644 --- a/containers/codespaces-linux/definition-manifest.json +++ b/containers/codespaces-linux/definition-manifest.json @@ -73,7 +73,9 @@ "Oh My Zsh!": "/home/codespace/.oh-my-zsh", "Oh My Bash!": "/home/codespace/.oh-my-bash", "nvm": "/home/codespace/.nvm", - "nvs": "/home/codespace/.nvs" + "nvs": "/home/codespace/.nvs", + "rbenv": "/usr/local/share/rbenv", + "ruby-build": "/usr/local/share/ruby-build" }, "gem": [ "rake", diff --git a/containers/ruby/.devcontainer/library-scripts/ruby-debian.sh b/containers/ruby/.devcontainer/library-scripts/ruby-debian.sh index 4fadadbc..7a754877 100755 --- a/containers/ruby/.devcontainer/library-scripts/ruby-debian.sh +++ b/containers/ruby/.devcontainer/library-scripts/ruby-debian.sh @@ -6,7 +6,7 @@ # # Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/ruby.md # -# Syntax: ./ruby-debian.sh [Ruby version] [non-root user] [Add rvm to rc files flag] [Install tools flag] +# Syntax: ./ruby-debian.sh [Ruby version] [non-root user] [Add to rc files flag] [Install tools flag] RUBY_VERSION=${1:-"latest"} USERNAME=${2:-"automatic"} @@ -57,8 +57,12 @@ fi function updaterc() { if [ "${UPDATE_RC}" = "true" ]; then - echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc + echo "Updating /etc/bash.bashrc..." + echo -e "$1" >> /etc/bash.bashrc + if [ -d "/etc/zsh" ]; then + echo "Updating /etc/zsh/zshrc..." + echo -e "$1" >> /etc/zsh/zshrc + fi fi } @@ -92,13 +96,42 @@ else su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system" rm -rf ${GNUPGHOME} fi + if [ "${INSTALL_RUBY_TOOLS}" = "true" ] && [ "${SKIP_GEM_INSTALL}" != "true" ]; then - su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && gem install ${DEFAULT_GEMS}" + # Non-root user may not have "gem" in path when script is run and no ruby version + # is installed by rvm, so handle this by using root's default gem in this case + ROOT_GEM="$(which gem)" + su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && \"$(which gem || ${ROOT_GEM})\" install ${DEFAULT_GEMS}" fi # VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it updaterc "if ! grep rvm_silence_path_mismatch_check_flag \$HOME/.rvmrc > /dev/null 2>&1; then echo 'rvm_silence_path_mismatch_check_flag=1' >> \$HOME/.rvmrc; fi\nsource /usr/local/rvm/scripts/rvm" +# Install rbenv/ruby-build for good measure +git clone --depth=1 \ + -c core.eol=lf \ + -c core.autocrlf=false \ + -c fsck.zeroPaddedFilemode=ignore \ + -c fetch.fsck.zeroPaddedFilemode=ignore \ + -c receive.fsck.zeroPaddedFilemode=ignore \ + https://github.com/rbenv/rbenv.git /usr/local/share/rbenv +ln -s /usr/local/share/rbenv/bin/rbenv /usr/local/bin +updaterc 'eval "$(rbenv init -)"' +git clone --depth=1 \ + -c core.eol=lf \ + -c core.autocrlf=false \ + -c fsck.zeroPaddedFilemode=ignore \ + -c fetch.fsck.zeroPaddedFilemode=ignore \ + -c receive.fsck.zeroPaddedFilemode=ignore \ + https://github.com/rbenv/ruby-build.git /usr/local/share/ruby-build +mkdir -p /root/.rbenv/plugins +ln -s /usr/local/share/ruby-build /root/.rbenv/plugins/ruby-build +if [ "${USERNAME}" != "root" ]; then + mkdir -p /home/${USERNAME}/.rbenv/plugins + chown -R ${USERNAME} /home/${USERNAME}/.rbenv + ln -s /usr/local/share/ruby-build /home/${USERNAME}/.rbenv/plugins/ruby-build +fi + # Clean up source /usr/local/rvm/scripts/rvm rvm cleanup all diff --git a/containers/ruby/definition-manifest.json b/containers/ruby/definition-manifest.json index cd8325b3..53de1101 100644 --- a/containers/ruby/definition-manifest.json +++ b/containers/ruby/definition-manifest.json @@ -53,7 +53,9 @@ ], "git": { "Oh My Zsh!": "/root/.oh-my-zsh", - "nvm": "/usr/local/share/nvm" + "nvm": "/usr/local/share/nvm", + "rbenv": "/usr/local/share/rbenv", + "ruby-build": "/usr/local/share/ruby-build" }, "gem": [ "rake", diff --git a/script-library/ruby-debian.sh b/script-library/ruby-debian.sh index 4fadadbc..7a754877 100755 --- a/script-library/ruby-debian.sh +++ b/script-library/ruby-debian.sh @@ -6,7 +6,7 @@ # # Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/ruby.md # -# Syntax: ./ruby-debian.sh [Ruby version] [non-root user] [Add rvm to rc files flag] [Install tools flag] +# Syntax: ./ruby-debian.sh [Ruby version] [non-root user] [Add to rc files flag] [Install tools flag] RUBY_VERSION=${1:-"latest"} USERNAME=${2:-"automatic"} @@ -57,8 +57,12 @@ fi function updaterc() { if [ "${UPDATE_RC}" = "true" ]; then - echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc + echo "Updating /etc/bash.bashrc..." + echo -e "$1" >> /etc/bash.bashrc + if [ -d "/etc/zsh" ]; then + echo "Updating /etc/zsh/zshrc..." + echo -e "$1" >> /etc/zsh/zshrc + fi fi } @@ -92,13 +96,42 @@ else su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system" rm -rf ${GNUPGHOME} fi + if [ "${INSTALL_RUBY_TOOLS}" = "true" ] && [ "${SKIP_GEM_INSTALL}" != "true" ]; then - su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && gem install ${DEFAULT_GEMS}" + # Non-root user may not have "gem" in path when script is run and no ruby version + # is installed by rvm, so handle this by using root's default gem in this case + ROOT_GEM="$(which gem)" + su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && \"$(which gem || ${ROOT_GEM})\" install ${DEFAULT_GEMS}" fi # VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it updaterc "if ! grep rvm_silence_path_mismatch_check_flag \$HOME/.rvmrc > /dev/null 2>&1; then echo 'rvm_silence_path_mismatch_check_flag=1' >> \$HOME/.rvmrc; fi\nsource /usr/local/rvm/scripts/rvm" +# Install rbenv/ruby-build for good measure +git clone --depth=1 \ + -c core.eol=lf \ + -c core.autocrlf=false \ + -c fsck.zeroPaddedFilemode=ignore \ + -c fetch.fsck.zeroPaddedFilemode=ignore \ + -c receive.fsck.zeroPaddedFilemode=ignore \ + https://github.com/rbenv/rbenv.git /usr/local/share/rbenv +ln -s /usr/local/share/rbenv/bin/rbenv /usr/local/bin +updaterc 'eval "$(rbenv init -)"' +git clone --depth=1 \ + -c core.eol=lf \ + -c core.autocrlf=false \ + -c fsck.zeroPaddedFilemode=ignore \ + -c fetch.fsck.zeroPaddedFilemode=ignore \ + -c receive.fsck.zeroPaddedFilemode=ignore \ + https://github.com/rbenv/ruby-build.git /usr/local/share/ruby-build +mkdir -p /root/.rbenv/plugins +ln -s /usr/local/share/ruby-build /root/.rbenv/plugins/ruby-build +if [ "${USERNAME}" != "root" ]; then + mkdir -p /home/${USERNAME}/.rbenv/plugins + chown -R ${USERNAME} /home/${USERNAME}/.rbenv + ln -s /usr/local/share/ruby-build /home/${USERNAME}/.rbenv/plugins/ruby-build +fi + # Clean up source /usr/local/rvm/scripts/rvm rvm cleanup all