Skip to content

Commit 2918057

Browse files
committed
Use $HOME instead of ~ in PATH env variable
Signed-off-by: Jose Blanquicet <josebl@microsoft.com>
1 parent 624adef commit 2918057

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
# Run the test cases
3939
- name: Run the test cases
40-
run: docker run --volume $(pwd)/tests:/tests tools_cloudshell /bin/bash /tests/test.sh
40+
run: docker run -i --volume $(pwd)/tests:/tests tools_cloudshell /bin/bash /tests/test.sh
4141

4242
# Show Docker image size
4343
- name: find the pull request id

linux/bash/bashrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Start: Define custom environment variables
2+
3+
# Add dotnet tools to PATH so users can install a tool using dotnet tools and
4+
# can execute that command from any directory
5+
export PATH=$HOME/.dotnet/tools:$PATH
6+
7+
# Add user's home directories to PATH at the front so they can install tools
8+
# which override defaults
9+
export PATH=$HOME/.local/bin:$HOME/bin:$PATH
10+
11+
# End: Define custom environment variables

linux/tools.Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ RUN rm -f ./linux/Dockerfile && rm -f /bin/su
6666
RUN ln -s /usr/bin/python3 /usr/bin/python
6767
RUN ln -s /usr/bin/node /usr/bin/nodejs
6868

69-
# Add user's home directories to PATH at the front so they can install tools which
70-
# override defaults
71-
# Add dotnet tools to PATH so users can install a tool using dotnet tools and can execute that command from any directory
72-
ENV PATH ~/.local/bin:~/bin:~/.dotnet/tools:$PATH
69+
# Add custom environment variables to /etc/skel/.bashrc so they will be
70+
# available to users any time they open a new shell.
71+
COPY ./linux/bash/bashrc linux/bashrc
72+
RUN cat linux/bashrc >> /etc/skel/.bashrc && rm linux/bashrc
7373

7474
# Set AZUREPS_HOST_ENVIRONMENT
7575
ENV AZUREPS_HOST_ENVIRONMENT cloud-shell/1.0

tests/PSinLinuxCloudShellImage.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ Describe "Various programs installed with expected versions" {
7474

7575
It "has local paths in `$PATH" {
7676
$paths = ($env:PATH).split(":")
77-
$paths | Should -Contain "~/bin"
78-
$paths | Should -Contain "~/.local/bin"
77+
$paths | Should -Contain "$HOME/bin"
78+
$paths | Should -Contain "$HOME/.local/bin"
7979
}
8080

8181
It "Ansible pwsh has modules" {

tests/test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ pwsh /tests/root-tests.ps1
1919

2020
pwsh -c "Install-Module Pester -Force -Scope AllUsers"
2121

22+
# Run tests as csuser with an interactive shell to verify the configuration in
23+
# the same environment this imange will be used in. Otherwise, the .bashrc won't
24+
# be sourced and the bash configuration (e.g., environment variables) won't be
25+
# set during the tests.
2226
echo "running tests as csuser"
23-
runuser -u csuser pwsh /tests/test.ps1
27+
runuser -u csuser -- /bin/bash -i -c 'pwsh /tests/test.ps1'

0 commit comments

Comments
 (0)