coder / code-server

VS Code in the browser
https://coder.com
MIT License
66.63k stars 5.46k forks source link

[Bug]: python.defaultInterpreterPath not working #6717

Closed ty-elastic closed 4 months ago

ty-elastic commented 4 months ago

Is there an existing issue for this?

OS/Web Information

Steps to Reproduce

  1. create Dockerfile which performs
    
    sudo apt -y update
    sudo apt install -y python3-venv

mkdir /workspace cd /workspace python3 -m venv .venv source .venv/bin/activate

pip install jupyter

code-server --install-extension ms-toolsai.jupyter --force --user-data-dir /user-data code-server --install-extension ms-python.python --force --user-data-dir /user-data

and then I've tried to set `python.defaultInterpreterPath` via:

cat > /workspace/workspace.code-workspace <<EOL { "folders": [ { "path": "/workspace" } ], "settings": { "python.venvPath" : ["/workspace"], "python.defaultInterpreterPath": "/workspace/.venv/bin/python3" } } EOL


and/or

cat > /user-data/User/settings.json <<EOL { "python.venvPath" : ["/workspace"], "python.defaultInterpreterPath": "/workspace/.venv/bin/python3" } EOL


and/or

cat > /user-data/Machine/settings.json <<EOL { "python.venvPath" : ["/workspace"], "python.defaultInterpreterPath": "/workspace/.venv/bin/python3" } EOL


and/or

cat > /workspace/.vscode/settings.json <<EOL { "python.venvPath" : ["/workspace"], "python.defaultInterpreterPath": "/workspace/.venv/bin/python3" } EOL



### Expected

When I open a `test.ipynb` file, `.venv (Python 3.11.2)` should be automatically selected as the kernel.

### Actual

I get `Detecting Kernels`, and then `Select Kernel`.

### Logs

[logs2.txt](https://github.com/coder/code-server/files/14543680/logs2.txt)

### Screenshot/Video

_No response_

### Does this issue happen in VS Code or GitHub Codespaces?

- [ ] I tested this in native VS Code.
- [ ] This does not happen in native VS Code.
- [ ] I tested this in GitHub Codespaces.
- [ ] This does not happen in GitHub Codespaces.

### Are you accessing code-server over a secure context?

- [ ] I am using a secure context.

### Notes

I'm trying to build a container which includes a code-server preconfigured for working on Jupyter notebooks with Python content, and trying to avoid the user having to manually select a Kernel.

Notably, I gather that the current python interpreter is stored in browser storage. I cleared that before this test.
ty-elastic commented 4 months ago

interestingly, if I set python.defaultInterpreterPath to something nonsense like /workspace/blah/.venv/bin/python3 I get a failure message when I open the notebook. Screenshot 2024-03-08 at 4 17 42 PM

yet with it set properly, I get Screenshot 2024-03-08 at 4 06 46 PM and then Screenshot 2024-03-08 at 4 21 45 PM

ty-elastic commented 4 months ago

also weird, when I set python.defaultInterpreterPath to something nonsense like /workspace/blah/.venv/bin/python3, I get the error about an invalid interpreter, and then when I go to select a python environment I see this: Screenshot 2024-03-08 at 4 17 56 PM (note the "Use Python from..." line).. which doesn't show up when I set it to a valid interpreter.

ty-elastic commented 4 months ago

Screenshot 2024-03-08 at 4 25 47 PM

ah, that's interesting. if i just create a standard python file and run it, it works... its like the jupyter extension doesn't respect python.defaultInterpreterPath ?

ty-elastic commented 4 months ago

haha. my fault. this is a known issue, unrelated to code-server, of course ;-).

https://github.com/microsoft/vscode-jupyter/issues/15032