eclipse-che / che

Kubernetes based Cloud Development Environments for Enterprise Teams
http://eclipse.org/che
Eclipse Public License 2.0
6.99k stars 1.19k forks source link

Inconsistent Environment Variables in postStart Events #23237

Open eye0fra opened 2 weeks ago

eye0fra commented 2 weeks ago

Describe the bug

This issue arises from the discussion in issue #23009.

Problem

There is an inconsistency in the environment variables, specifically the $PATH, when commands are executed during the postStart event in a Devfile. The commands do not share the same environment variables as they would if launched normally inside the workspace. This is particularly problematic when dealing with images that offer multiple shell environments, such as bash and zsh. The postStart events are executed with /bin/sh/ by default, which does not load shell-specific configuration files like .bashrc or .zshrc, leading to missing environment variables and configurations.

Comments Summary

Proposed Solution

Che version

7.94@latest

Steps to reproduce

Create a devfile with the following command and event:

events:
  postStart:
    - display-path
commands:
  - id: display-path
    exec:
      component: tools
      commandLine: echo $PATH

Expected behavior

PATH on the event must have the same value as the PATH env defined inside command and image component.

Runtime

OpenShift

Screenshots

image (5) image (4)

Installation method

OperatorHub

Environment

other (please specify in additional context)

Eclipse Che Logs

No response

Additional context

OpenShift DevSpaces 3.16.1