From 4f6cc547d0a7828d036d22f320b9c078e492a9c4 Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Fri, 7 Jun 2024 09:55:55 -0400
Subject: [PATCH] Align root/vscode user dynamic for codespaces with
 non-codespaces config (#30593)

---
 .devcontainer/Dockerfile                   | 4 ++--
 .devcontainer/codespaces/devcontainer.json | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index 9d8fa2702..a0dc24ee8 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -5,7 +5,7 @@ FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bookworm
 # RUN gem install rails webdrivers
 
 ARG NODE_VERSION="20"
-RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"
+RUN . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1
 
 # [Optional] Uncomment this section to install additional OS packages.
 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
@@ -15,6 +15,6 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
 RUN gem install foreman
 
 # [Optional] Uncomment this line to install global node packages.
-RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && corepack enable" 2>&1
+RUN . /usr/local/share/nvm/nvm.sh && corepack enable 2>&1
 
 COPY welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
diff --git a/.devcontainer/codespaces/devcontainer.json b/.devcontainer/codespaces/devcontainer.json
index 6736734e6..c14d2c529 100644
--- a/.devcontainer/codespaces/devcontainer.json
+++ b/.devcontainer/codespaces/devcontainer.json
@@ -23,6 +23,8 @@
     }
   },
 
+  "remoteUser": "root",
+
   "otherPortsAttributes": {
     "onAutoForward": "silent"
   },