Pycharm doesn't recognize file or folder with remote interpreter
Question:
In a file whose only content is
def test_sanity():
pass
I am trying to run the file, named test_something.py
.
The folder structure is
uv_metadata
|---uv_metadata
|------tests
|----------test_something.py
Getting the error
ssh://noam.s@ML:2202/home/noam.s/src/uv_metadata/venv/bin/python -u /home/noam.s/.pycharm_helpers/pycharm/_jb_pytest_runner.py --target test_something.py::test_sanity
Testing started at 14:34 ...
sh: 1: cd: can't cd to C:/Users/noam.s/src/uv_metadata/uv_metadata/tests
Launching pytest with arguments test_something.py::test_sanity --no-header --no-summary -q in /home/noam.s
============================= test session starts ==============================
collected 0 items
============================ no tests ran in 0.00s =============================
ERROR: file or directory not found: test_something.py::test_sanity
Process finished with exit code 4
Empty suite
I notice the line sh: 1: cd: can't cd to C:/Users/noam.s/src/uv_metadata/uv_metadata/tests
, which doesn’t make sense. Here is how my remote interpreter is configured:
This just stopped working, I don’t know what has changed.
How to make Pycharm recognize the test folder again?
Answers:
PyCharm 2021.2.3 has a buggy deployment configuration, which can cause clashes and sometimes not work properly when some mappings are configured separately on the same interpreter, even from different projects.
Likely, I was using the same interpreter with a different mapping, from some other Pycharm instance.
I had to go to Build, Execution, Deployment
-> Deployment
and remove everything from the list.
Following is the state after everything was clean and I added a new interpreter.
I also cleaned the interpreter list
and it went back to work.
A very inconvenient method to avoid this, but be safe
My method of working to avoid this is having only a single path mapping per interpreter.
If I need the same interpreter with different mappings, I create a new docker container, to make Pycharm think it is actually a different interpreter.
If I need the same mapping with a different interpreter, there isn’t a problem.
For accessing the interpreter that runs inside a remote docker, I am tunneling PORT to 22 on the docker, and making ssh server run on the docker on startup, like so, and mapping ~
to ~
in the docker, so the actual same venv is reflected in all dockers.
In a file whose only content is
def test_sanity():
pass
I am trying to run the file, named test_something.py
.
The folder structure is
uv_metadata
|---uv_metadata
|------tests
|----------test_something.py
Getting the error
ssh://noam.s@ML:2202/home/noam.s/src/uv_metadata/venv/bin/python -u /home/noam.s/.pycharm_helpers/pycharm/_jb_pytest_runner.py --target test_something.py::test_sanity
Testing started at 14:34 ...
sh: 1: cd: can't cd to C:/Users/noam.s/src/uv_metadata/uv_metadata/tests
Launching pytest with arguments test_something.py::test_sanity --no-header --no-summary -q in /home/noam.s
============================= test session starts ==============================
collected 0 items
============================ no tests ran in 0.00s =============================
ERROR: file or directory not found: test_something.py::test_sanity
Process finished with exit code 4
Empty suite
I notice the line sh: 1: cd: can't cd to C:/Users/noam.s/src/uv_metadata/uv_metadata/tests
, which doesn’t make sense. Here is how my remote interpreter is configured:
This just stopped working, I don’t know what has changed.
How to make Pycharm recognize the test folder again?
PyCharm 2021.2.3 has a buggy deployment configuration, which can cause clashes and sometimes not work properly when some mappings are configured separately on the same interpreter, even from different projects.
Likely, I was using the same interpreter with a different mapping, from some other Pycharm instance.
I had to go to Build, Execution, Deployment
-> Deployment
and remove everything from the list.
Following is the state after everything was clean and I added a new interpreter.
I also cleaned the interpreter list
and it went back to work.
A very inconvenient method to avoid this, but be safe
My method of working to avoid this is having only a single path mapping per interpreter.
If I need the same interpreter with different mappings, I create a new docker container, to make Pycharm think it is actually a different interpreter.
If I need the same mapping with a different interpreter, there isn’t a problem.
For accessing the interpreter that runs inside a remote docker, I am tunneling PORT to 22 on the docker, and making ssh server run on the docker on startup, like so, and mapping ~
to ~
in the docker, so the actual same venv is reflected in all dockers.