Skip to content

Fix and improve startup performances of Python workspaces using venv #19806

@cccs-eric

Description

@cccs-eric

Describe the bug

When using a python virtual environment, the vscode-python sidecar cannot activate the venv since it tries to activate it using the source command, which is not available in the current shell (/bin/sh).

Che version

7.29.2

Steps to reproduce

  1. Create a new workspace using the built-in Python stack.
  2. Once the workspace is loaded, set up a new venv using the devfile's set up venv command
  3. Change the Python interpreter and select the venv python3 binary under /projects/.venv/bin/python3
  4. Open the hello-world.py file and execute it using the green "Play" arrow located at the top-right of the editor
  5. You should see the following error:
$ source /projects/.venv/bin/activate
/bin/sh: 1: source: not found
$ /projects/.venv/bin/python3 /projects/python-hello-world/hello-world.py
Hello, world!

Expected behavior

I should be able to run hello-world.py using the devfile command and also the built-in run button of the editor. But to do so, it needs to activate the venv associated.

Not sure what would be the best solution, but I can see:

  1. Change the default shell of the sidecar to be bash, so source can be used
  2. Change the way the venv is activated by using . instead or source

Screenshots

image

Release Notes Text

The default Python image now uses bash as the default shell and venv runs successfully. The startup time of an existing workspace has been significantly reduced for the Python getting started example with an update to persist venv folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/devfile-registrykind/bugOutline of a bug - must adhere to the bug report template.new&noteworthyFor new and/or noteworthy issues that deserve a blog post, new docs, or emphasis in release notesseverity/P1Has a major impact to usage or development of the system.sprint/next

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions