Emacs:can';尝试使用tramp连接到远程主机时找不到uname

Emacs:can';尝试使用tramp连接到远程主机时找不到uname,emacs,elisp,tramp,Emacs,Elisp,Tramp,我正在使用,并且在使用tramp连接远程主机时遇到了一些问题。每次尝试连接时,都会出现以下错误: Tramp: Opening connection for root@foo.example.com using ssh... Tramp: Sending command `exec ssh -l root -e none foo.example.com' Tramp: Waiting for prompts from remote shell Tramp: Sending command `

我正在使用,并且在使用tramp连接远程主机时遇到了一些问题。每次尝试连接时,都会出现以下错误:

Tramp: Opening connection for root@foo.example.com using ssh...
Tramp: Sending command `exec ssh -l root  -e none foo.example.com'

Tramp: Waiting for prompts from remote shell
Tramp: Sending command `exec ssh -l root  -e none foo.example.com'
Tramp: Found remote shell prompt on `foo.example.com'
Tramp: Opening connection for root@foo.example.com using ssh...done
byte-code: `echo \"`uname -sr`\"' does not return a valid Lisp expression: `sh: uname: command not found
此实例中的远程主机是较旧的Fedora安装,uname位于
/bin/uname
。我在Ubuntu12.10机器上也遇到了同样的错误,所以我认为远程主机没有问题。我尝试了很多不同的方法,包括设置值
tramp remote path
,但都没有效果。我当前的流浪汉相关配置如下所示:

(require 'tramp)
(setq tramp-default-method "ssh")
(add-to-list 'tramp-remote-path "/bin")
(add-to-list 'tramp-remote-path "/usr/bin")
(add-to-list 'tramp-remote-path "/usr/local/bin")

如果有任何建议或帮助,我将不胜感激。谢谢。

在我的例子中,此问题是由.emacs中的错误设置导致的,该设置更改了shell设置。如果您已经积累了很多设置,我强烈建议您从头开始,而不是尝试调试.emacs文件。首先确保您可以在emacs之外通过ssh访问主机。一旦工作正常,就开始跑步

% emacs -q
开始时没有配置文件。在emacs内部,执行以下操作:

(require 'tramp)
并尝试在远程主机上打开一个文件

C-xC-f /your-host-name:/path/on/your/host/file.name
如果这能奏效,就像对我一样,那太好了!现在您可以找出.emacs中的什么问题导致了崩溃。查找与子shell或tramp配置变量相关的任何内容,并从中开始工作

如果问题仍然存在,请尝试为tramp添加更多诊断

(setq tramp-debug-buffer t)
(setq tramp-verbose 10)

并检查输出缓冲器。特别是,试着弄清楚你到底是在访问远程主机,还是在客户端被什么东西绊倒。

在我的例子中,我调用了这个函数,我添加了这个函数来执行emacs中的latex内容

(defun set-exec-path-from-shell-PATH ()
  "Sets the exec-path to the same value used by the user shell"
  (let ((path-from-shell
         (replace-regexp-in-string
          "[[:space:]\n]*$" ""
          (shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))
在玩了我的shell和自制软件之后,我弄坏了一些东西,我得到了你描述的错误,所以在最后我删除了这个函数,现在我只有下面的路径配置

(setenv "PATH" (concat (getenv "PATH") ":/bin"))
(setq exec-path (append exec-path '("/bin")))