'"Indicated packet length too large" error when using remote interpreter in PyCharm
Solution 1:[1]
I got this error because my .bashrc file printed to stdout. .bashrc is sourced when PyCharm connects to a remote interpreter's machine over SFTP. It has to be silent, otherwise it interferes with the SFTP protocol.
The solution is to exit .bashrc early when not running interactively by putting this line at the top:
# If not running interactively, return early
[[ $- == *i* ]] || return
Further reading:
Solution 2:[2]
After a little bit check, I found the final solution for this problem.
It is not a problem about pycharm or intellij actually.
The underlying working principle of sync files to the remote server is using sftp to upload files and download files from a remote server.
Maybe you have noticed that it works when using the root user to sync.
For different people, they use different sftp utils like putty, Linux client, Windows cmd, Power shell, xshell, and so on.
By using the command sftp root@host or sftp user@host (where the user is what you logged) in xshell.
xshell will ask you to type in a password with a dialog.
Both these commands will work.
But when you use windows cmd by the same commands, here messages will jump out.
Received message too long 1399157792
Ensure the remote shell produces no output for non-interactive sessions.
And you will see, pycharm just forward this information.
Here is a related question about the long message, sftp gives an error: "Received message too long" and what is the reason?
So, we need to change the sftp server configuration to non-interactive mode.
By editing /etc/ssh/sshd_config, need you to have root permission or ask the server administrator to do.
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
And restart the sshd service, by systemctl restart sshd
Solution 3:[3]
I got a similar issues. I was pip updating a bunch of software in the cluster each time I logged in. So if pycharm runs the bashrc in the cluster each time it pushes and for some reason it processes it's output then this is an issue. I removed all lines that print in my bashrc in the remote/cluster.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kilian Batzner |
| Solution 2 | FavorMylikes |
| Solution 3 | Charlie Parker |

