- 1 year ago
emacs Tramp on Windows: plink says /bin/sh: env: command not found
The error message "/bin/sh: env: command not found" in Emacs Tramp on Windows typically occurs when the remote shell (sh) used by Tramp does not have the env
command available. This issue is often encountered when using plink
(PuTTY Link) as the remote shell on Windows.
To fix this problem, you need to make sure that the env
command is available on the remote system. Here are some steps to resolve the issue:
Install Coreutils on the Remote System:
Theenv
command is part of the Coreutils package on Unix-like systems. If it is not available on the remote system, you can install Coreutils to provide the necessary utilities, includingenv
.For example, on systems using package managers like apt (Debian/Ubuntu) or yum (Red Hat/CentOS), you can install Coreutils with the following command:
For Debian/Ubuntu:
bashsudo apt-get install coreutils
For Red Hat/CentOS:
bashsudo yum install coreutils
Ensure the Path is Set Correctly:
Ifplink
is used as the remote shell, make sure that the environment variables, including the PATH, are set correctly. The remote shell should be able to locate the necessary commands, includingenv
. If needed, you can set the PATH explicitly in the remote user's shell configuration file (e.g.,.bashrc
,.bash_profile
, etc.).Alternative Remote Shell:
If installing Coreutils or adjusting the PATH does not resolve the issue, consider using a different remote shell with Tramp. For example, you can try using thessh
remote shell instead ofplink
if it is available and configured properly on your Windows system.To switch to the
ssh
remote shell in Emacs Tramp, you can add the following line to your Emacs configuration:emacs(setq tramp-default-method "ssh")
This will make Tramp use the
ssh
remote shell by default.
By installing Coreutils or ensuring the PATH is set correctly, you should be able to resolve the "/bin/sh: env: command not found" error in Emacs Tramp on Windows when using plink
as the remote shell. If the issue persists, consider using an alternative remote shell like ssh
.