【问题标题】:Emacs: can't find uname when attempting to connect to remote host with trampEmacs:尝试使用tramp连接到远程主机时找不到uname
【发布时间】:2013-03-20 18:05:06
【问题描述】:

我正在使用emacs 24.3 on OSX,但在使用 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。我在 Ubuntu 12.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 elisp tramp


    【解决方案1】:

    在我的情况下,这个问题是由 .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 配置变量相关的任何内容,然后从那里开始工作。

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

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

    并检查输出缓冲区。特别是,尝试弄清楚您是否完全到达了远程主机,或者是否在客户端被绊倒了。

    【讨论】:

      【解决方案2】:

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

      (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 和 homebrew 之后,我弄坏了一些东西,我得到了你描述的错误,所以最后我删除了那个函数,现在我的路径只有以下配置

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-02-15
        • 2011-08-08
        • 1970-01-01
        • 1970-01-01
        • 2018-08-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多