devcontainers / cli

A reference implementation for the specification that can create and configure a dev container from a devcontainer.json.
https://containers.dev
MIT License
1.59k stars 222 forks source link

Bug: _REMOTE_USER_HOME is empty when executing a Feature where common-utils configures the user #331

Open samruddhikhandale opened 1 year ago

samruddhikhandale commented 1 year ago

Reported in https://github.com/devcontainers/features/issues/336#issuecomment-1360027876

// devcontainer.json
{
  "image": "mcr.microsoft.com/dotnet/sdk:6.0-jammy",
  "features": {
    "ghcr.io/devcontainers/features/azure-cli:1": {
      "version": "latest",
      "installBicep": "true"
    },
    "ghcr.io/devcontainers/features/common-utils:2": {
      "installZsh": true,
      "installOhMyZsh": true,
      "upgradePackages": true,
      "username": "vscode",
      "userUid": "1000",
      "userGid": "1000"
    }
  },
  "overrideFeatureInstallOrder": [
    "ghcr.io/devcontainers/features/common-utils"
  ],
  "remoteUser": "vscode"
}

While executing the azure-cli Feature, it logs the following values (added loggings in install.sh)👇

image

Expected : The value of _REMOTE_USER_HOME should have been /home/vscode

samruddhikhandale commented 1 year ago

ℹ️ This dev config Works perfectly where user is available in image metadata👇

{
  "image": "mcr.microsoft.com/devcontainers/base:jammy",
  "features": {
    "ghcr.io/devcontainers/features/azure-cli:1": {
      "version": "latest",
      "installBicep": "true"
    }
  }
}

image

chrmarti commented 1 year ago

We determine _REMOTE_USER_HOME before any features run.

samruddhikhandale commented 1 year ago

https://github.com/devcontainers/features/issues/570#issue-1750480909 mentions a similar issue while using the docker-in-docker Feature.

cgrothaus commented 1 year ago

I'm having the same issue. Using

  1. a non-devcontainer base image (hexpm/elixir)
  2. the common-utils feature
  3. the shell-history feature.

The shell history install.sh script logs the _REMOTE_USER and _REMOTE_USER_HOME variables, and the latter one is empty:

 > [vscode dev_containers_target_stage 15/15] RUN chmod -R 0755 /tmp/dev-container-features/shell-history_5 && cd /tmp/dev-container-features/shell-history_5 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh:
0.118 ===========================================================================
0.118 Feature       : Shell History
0.118 Description   : Preserve shell history across dev container instances. Currently supports bash, zsh, and fish
0.118 Id            : ghcr.io/stuartleeks/dev-container-features/shell-history
0.118 Version       : 0.0.3
0.118 Documentation : 
0.118 Options       :
0.118 
0.118 ===========================================================================
0.118 Activating feature 'shell-history'
0.118 User: vscode     User home: 
0.118 ***********************************************************************************
0.118 *** Require _REMOTE_USER and _REMOTE_USER_HOME to be set (by dev container CLI) ***
0.118 ***********************************************************************************
0.119 ERROR: Feature "Shell History" (ghcr.io/stuartleeks/dev-container-features/shell-history) failed to install!
s-froghyar commented 10 months ago

@cgrothaus I'm getting the same issue now, did you find a workaround by any chance?

cgrothaus commented 10 months ago

@s-froghyar Sadly, no 🤷 .

prulloac commented 8 months ago

Hi! FYI I'm trying to solve this issue, currently testing against the broken scenarios stated here and on the docker-in-docker feature

carlgleisner commented 2 months ago

Hi @cgrothaus and @prulloac, I ran into this while setting up infrastructure as code with Bicep for an Azure deployment.

Did you by any chance make progress on this?