Skip to content

Cannot debug a dotfiles error #12100

Closed as not planned
Closed as not planned
@mrsimonemms

Description

@mrsimonemms

Bug description

I'm trying to install Starship in my Dotfiles. My script is fairly simple:

function starship() {
  echo "Installing Starship"

  curl -sS https://starship.rs/install.sh | BIN_DIR="${HOME}/bin" FORCE=1 sh

  echo "Starship installed - configuring it for the logged in user"

  PRESET="pure-preset"

  mkdir -p "${HOME}/.config"
  wget "https://starship.rs/presets/toml/${PRESET}.toml" -O "${HOME}/.config/starship.toml"
  echo "eval "$(starship init bash)"" > "${HOME}/.bashrc.d/101-starship"
}

starship

When I run this in an already running repo, this works fine. However, when I open a repo with it enabled, it immediately stops the workspace.

I'd like to be able to see why it's erroring. AFAIK, there's no way of seeing why Dotfiles are erroring if you cannot access ~/.dotfiles.log

Steps to reproduce

Configure your dotfiles to be github.com/mrsimonemms/dotfiles and start a workspace

Workspace affected

Any workspace when this repo is in a failed state, eg gitpodio-demodotfiles-04q359bw7nk

Expected behavior

See logs outside of a workspace

Example repository

Full broken Dotfiles:

#!/bin/bash

set -euo pipefail

function bash_alias() {
  echo "Setting up bash_alias"

  cp "${HOME}/.dotfiles/.bash_aliases" "${HOME}/.bash_aliases"
}

function bin_dir() {
  echo "Creating bin directory"

  export PATH="${PATH}:${HOME}/bin"
  mkdir -p "${HOME}/bin"
}

function kubeconfig() {
  echo "Looking for a KUBECONFIG_BASE64 envvar"

  if [ -n "${KUBECONFIG_BASE64-}" ]; then
    echo "KUBECONFIG_BASE64 envvar found"

    KUBECONFIG="${HOME}/.kube/config"

    mkdir -p "${HOME}/.kube"
    mv -f "${KUBECONFIG}" "${HOME}/.kube/config.orig" || true # Save the old kubeconfig
    echo "${KUBECONFIG_BASE64}" | base64 -d > "${KUBECONFIG}"
    chmod 600 "${KUBECONFIG}"
  fi
}

function ohmyzsh() {
  echo "Installing Oh My ZSH!"

  sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended

  cp "${HOME}/.dotfiles/oh-my-zsh/zshrc" "${HOME}/.zshrc"
}

function ssh_key() {
  echo "Looking for a SSH_PRIVATE_KEY_BASE64 envvar"

  mkdir -p "${HOME}/.ssh"

  if [ -n "${SSH_PRIVATE_KEY_BASE64-}" ]; then
    echo "SSH_PRIVATE_KEY_BASE64 envvar found"

    echo "${SSH_PRIVATE_KEY_BASE64}" | base64 -d > "${HOME}/.ssh/id_rsa"
    chmod 600 "${HOME}/.ssh/id_rsa"
  fi

  if [ -n "${SSH_PUBLIC_KEY_BASE64-}" ]; then
    echo "SSH_PUBLIC_KEY_BASE64 envvar found"

    echo "${SSH_PUBLIC_KEY_BASE64}" | base64 -d > "${HOME}/.ssh/id_rsa.pub"
    chmod 600 "${HOME}/.ssh/id_rsa.pub"
  fi
}

function starship() {
  echo "Installing Starship"

  curl -sS https://starship.rs/install.sh | BIN_DIR="${HOME}/bin" FORCE=1 sh

  echo "Starship installed - configuring it for the logged in user"

  PRESET="pure-preset"

  mkdir -p "${HOME}/.config"
  wget "https://starship.rs/presets/toml/${PRESET}.toml" -O "${HOME}/.config/starship.toml"
  echo "eval "$(starship init bash)"" > "${HOME}/.bashrc.d/101-starship"
}

bin_dir
kubeconfig
bash_alias
ssh_key
starship

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions