microsoft / vscode-dev-containers

NOTE: Most of the contents of this repository have been migrated to the new devcontainers GitHub org (https://github.com/devcontainers). See https://github.com/devcontainers/template-starter and https://github.com/devcontainers/feature-starter for information on creating your own!
https://aka.ms/vscode-remote
MIT License
4.71k stars 1.4k forks source link

Packages cant be found in default image in Code Spaces #900

Open bscott opened 3 years ago

bscott commented 3 years ago

Steps to Reproduce:

  1. Start Code Spaces on Github.com in any project
  2. See errors displayed in Terminal
bash: brew: command not found
bash: jump: command not found
bash: direnv: command not found
bash: __git_ps1: command not found
Chuxel commented 3 years ago

@bscott That is expected as they are not included. Are you requesting them be added? We take care to be judicious about what is added since the more that is there, the less space users will have in the codespace. Homebrew in particular is surprisingly huge.

bscott commented 3 years ago

No problem

I thought they were included hence why I created the issue but it would be nice if they were added so the experience doesn't feel broken when we launch a new code space and immediately see these errors in the terminal.

Chuxel commented 3 years ago

@bscott Got it. I assume these references are coming from your dotfiles, correct?

You could install Linux brew if you detect it is missing in your dotfiles:

if ! type brew > /dev/null 2>&1; then
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"    
    # VS Code's default terminal on Linux is interactive, not a login shell, so update bashrc/zshrc
    echo 'if [[ "${PATH}" != *"/home/linuxbrew/.linuxbrew/bin"* ]]; then export PATH="/home/linuxbrew/.linuxbrew/sbin:/home/linuxbrew/.linuxbrew/bin:${PATH}"; fi' | tee -a $HOME/.zshrc >> $HOME/.bashrc
fi

The second line is because VS Code defaults to a non-login shell for Linux (for historic reasons), so ~/.profile won't be sourced.