@@ -293,15 +293,21 @@ export function getFeatureLayers(featuresConfig: FeaturesConfig, containerUser:
293293
294294 const useSELinuxLabel = process . platform === 'linux' && isBuildah ;
295295 const builtinsEnvFile = `${ path . posix . join ( FEATURES_CONTAINER_TEMP_DEST_FOLDER , 'devcontainer-features.builtin.env' ) } ` ;
296- let result = `RUN \\
297- echo "_CONTAINER_USER_HOME=$(${ getEntPasswdShellCommand ( containerUser ) } | cut -d: -f6)" >> ${ builtinsEnvFile } && \\
298- echo "_REMOTE_USER_HOME=$(${ getEntPasswdShellCommand ( remoteUser ) } | cut -d: -f6)" >> ${ builtinsEnvFile }
296+ const tempUserHome = `RUN \\
297+ echo "_CONTAINER_USER_HOME=$(${ getEntPasswdShellCommand ( containerUser ) } | cut -d: -f6)" >> ${ builtinsEnvFile } && \\
298+ echo "_REMOTE_USER_HOME=$(${ getEntPasswdShellCommand ( containerUser ) } | cut -d: -f6)" >> ${ builtinsEnvFile }
299299
300300` ;
301301
302+ // placeholder empty string to concatenate the feature layers
303+ let result = '' ;
304+
302305 // Features version 1
303306 const folders = ( featuresConfig . featureSets || [ ] ) . filter ( y => y . internalVersion !== '2' ) . map ( x => x . features [ 0 ] . consecutiveId ) ;
304307 folders . forEach ( folder => {
308+ // calculate container user home and remote user home before feature installation
309+ result += tempUserHome ;
310+
305311 const source = path . posix . join ( contentSourceRootPath , folder ! ) ;
306312 const dest = path . posix . join ( FEATURES_CONTAINER_TEMP_DEST_FOLDER , folder ! ) ;
307313 if ( ! useBuildKitBuildContexts ) {
@@ -327,6 +333,9 @@ RUN chmod -R 0755 ${dest} \\
327333 // Features version 2
328334 featuresConfig . featureSets . filter ( y => y . internalVersion === '2' ) . forEach ( featureSet => {
329335 featureSet . features . forEach ( feature => {
336+ // recalculate container user home and remote user home if feature modifies it
337+ result += tempUserHome ;
338+
330339 result += generateContainerEnvs ( feature . containerEnv ) ;
331340 const source = path . posix . join ( contentSourceRootPath , feature . consecutiveId ! ) ;
332341 const dest = path . posix . join ( FEATURES_CONTAINER_TEMP_DEST_FOLDER , feature . consecutiveId ! ) ;
0 commit comments