PyCharm Remote SSH Interpreter Environment Variables Missing Login Shell Inheritance
0 reputation · 18 Apr 2022, 15:31 UTC
0 reputation · 18 Apr 2022, 15:31 UTC
PyCharm's remote SSH interpreter configuration launches processes through an IDE-managed wrapper rather than the remote user's login shell, so variables exported in ~/.bashrc, ~/.bash_profile, or ~/.zshrc do not reach the running process. A local interpreter inherits the developer's host environment, which can make identical code succeed locally but fail on a production host because PATH, PYTHONPATH, or custom secrets are absent.
The run/debug configuration exposes an "Environment variables" field, but it requires manual duplication of remote shell state. Relying on the interpreter's "Shell path" to force a login shell is an undocumented workaround that can load unrelated profiles or slow startup. This behavior has been reported across PyCharm Professional 2021.3 through 2024.2, though the exact boundary between wrapper initialization and shell sourcing is not clearly documented.
What is the supported boundary for environment inheritance in remote SSH interpreters, and is there a documented configuration to source login profiles without manual duplication? Should teams treat the "Shell path" setting as a stable mechanism for production parity, or does it remain an unsupported workaround with unpredictable side effects?
No. There is no documented, supported configuration in PyCharm that makes a Remote SSH interpreter automatically source a remote user’s login profile such as ~/.bashrc, ~/.bash_profile or ~/.zshrc. The supported boundary for environment inheritance is limited to variables you explicitly set in the Run/Debug configuration Environment variables field and the minimal environment exported by PyCharm’s IDE-managed wrapper.
The "Shell path" option in the interpreter settings is not a supported mechanism for production parity. It is an undocumented workaround that can invoke a login shell for the wrapper. That behavior is not part of the public API, is not guaranteed across releases, and can introduce unrelated profile side effects and startup delays.
Local interpreters inherit the developer host environment, so code can succeed locally while failing remotely when PATH, PYTHONPATH or custom secrets are missing. The mismatch is expected with the current wrapper design, not a misconfiguration.
To give a precise recommendation for your setup, it helps to know which shell is the remote user’s default login shell and whether the needed variables live in a login-only file such as ~/.bash_profile versus an interactive-only file such as ~/.bashrc. That determines whether a wrapper script sourcing the correct file is sufficient.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.