Skip to content

Use $HOME instead of ~ in PATH env variable #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

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

# Show Docker image size
- name: find the pull request id
Expand Down
11 changes: 11 additions & 0 deletions linux/bash/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Start: Define custom environment variables

# Add dotnet tools to PATH so users can install a tool using dotnet tools and
# can execute that command from any directory
export PATH=$HOME/.dotnet/tools:$PATH

# Add user's home directories to PATH at the front so they can install tools
# which override defaults
export PATH=$HOME/.local/bin:$HOME/bin:$PATH

# End: Define custom environment variables
8 changes: 4 additions & 4 deletions linux/tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ RUN rm -f ./linux/Dockerfile && rm -f /bin/su
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -s /usr/bin/node /usr/bin/nodejs

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

# Set AZUREPS_HOST_ENVIRONMENT
ENV AZUREPS_HOST_ENVIRONMENT cloud-shell/1.0
4 changes: 2 additions & 2 deletions tests/PSinLinuxCloudShellImage.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ Describe "Various programs installed with expected versions" {

It "has local paths in `$PATH" {
$paths = ($env:PATH).split(":")
$paths | Should -Contain "~/bin"
$paths | Should -Contain "~/.local/bin"
$paths | Should -Contain "$HOME/bin"
$paths | Should -Contain "$HOME/.local/bin"
}

It "Ansible pwsh has modules" {
Expand Down
6 changes: 5 additions & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ pwsh /tests/root-tests.ps1

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

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