Skip to content

Commit 0668db5

Browse files
Commonutils: chown: cannot access '/home/vscode/.zshrc': No such file or directory (#662)
* Update main.sh * Update devcontainer-feature.json * Test install as non root user. --------- Co-authored-by: Samruddhi Khandale <[email protected]>
1 parent 0cf690e commit 0668db5

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

src/common-utils/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "common-utils",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"name": "Common Utilities",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
66
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",

src/common-utils/main.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ if [ "${INSTALL_ZSH}" = "true" ]; then
500500
copy_to_user_files=("${oh_my_install_dir}")
501501
[ -f "$user_rc_file" ] && copy_to_user_files+=("$user_rc_file")
502502
cp -rf "${copy_to_user_files[@]}" /root
503-
chown -R ${USERNAME}:${group_name} "${oh_my_install_dir}" "${user_rc_file}"
503+
chown -R ${USERNAME}:${group_name} "${copy_to_user_files[@]}"
504504
fi
505505
fi
506506
fi
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# Definition specific tests
9+
check "default-zsh-with-no-zshrc" bash -c "[ ! -e ~/.zshrc ]"
10+
11+
# Report result
12+
reportResults

test/common-utils/configure_zsh_no_template.sh renamed to test/common-utils/configure_zsh_no_template_second_step.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ set -e
44

55
# Optional: Import test library
66
source dev-container-features-test-lib
7-
87
# Definition specific tests
98
function file_not_overridden() {
10-
cat ~/.zshrc | grep 'alias fnomockalias=' | grep testingmock
9+
cat $1 | grep 'alias fnomockalias=' | grep testingmock
1110
}
12-
check "default-zsh-with-no-zshrc" file_not_overridden
11+
check "default-zsh-with-no-zshrc" file_not_overridden /home/devcontainer/.zshrc
1312

1413
# Report result
1514
reportResults

test/common-utils/scenarios.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,20 @@
115115
}
116116
}
117117
},
118-
"configure_zsh_no_template": {
118+
"configure_zsh_no_template_second_step": {
119119
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
120-
"postCreateCommand": "echo alias fnomockalias=testingmock >> /root/.zshrc",
121-
"remoteUser": "root",
120+
"postCreateCommand": "echo alias fnomockalias=testingmock >> /home/devcontainer/.zshrc",
121+
"remoteUser": "devcontainer",
122+
"features": {
123+
"common-utils": {
124+
"installZsh": true,
125+
"installOhMyZshConfig": false
126+
}
127+
}
128+
},
129+
"configure_zsh_no_template_first_step": {
130+
"image": "debian:bullseye",
131+
"remoteUser": "devcontainer",
122132
"features": {
123133
"common-utils": {
124134
"installZsh": true,

0 commit comments

Comments
 (0)