opensafely-core / research-template-docker

This provides the devcontainer Docker image used by repos created from the OpenSAFELY research template.
Other
0 stars 0 forks source link

The Python venv isn't activated in VS Code's Terminal #20

Closed iaindillingham closed 1 month ago

iaindillingham commented 2 months ago

This means tools such as ipython and pytest aren't available. The user can run:

source /opt/venv/bin/activate

However, the user would need to know where the venv was located and what a venv was.

Jongmassey commented 2 months ago

I can't replicate this - can you detail steps to reproduce?

Jongmassey commented 2 months ago

Typo in now fixed in this commit - venv now activates once the python extension has activated

iaindillingham commented 2 months ago

I've started a Codespace from the commit you've linked to above. The Python venv isn't activated in VS Code's Terminal, as shown in the screenshot below:

improve-devcontainers-vs-code
Jongmassey commented 2 months ago

What's extensiondisable doing? Is this codespace in a browser or connected to from locally installed vs code?

Jongmassey commented 2 months ago

image In browser is working for me

Jongmassey commented 2 months ago

The terminal that starts upon codespace startup (the one that starts rstudio server) shows this message for me image

Any terminals manually created have the venv activated.

Is there anything in the output/python pane? I wonder if your local extensions/config are interfering with the codespaces config?

Jongmassey commented 2 months ago

I think there's some weird interactions with local extensions/settings when opening a codespace in VS code rather than in a browser. In any case, it can take a while for the Python extension to activate. We could add a venv activation statement to the postAttachCommand following the start of RStudio Server such that the already-open terminal immediately has an activated venv

Jongmassey commented 1 month ago

Some further observations:

Also:

Therefore:

I propose we add a venv activation statement to the rstudio user's .bashrc as part of the Dockerfile