docker - Magit无法连接到docker内的emacsclient?

标签 docker magit emacsclient

我正在 docker 中运行 emacs24.5.1(基本镜像是 Ubuntu)。我通过 apt-get 安装了 emacs。此外,我通过melpa安装了magit(magit版本magit-20170702.858),它很棒。但是,当我尝试提交某些内容时,magit 遇到以下错误:

1 git ? commit -- 
  /usr/bin/emacsclient.emacs24: connect: Connection refused 
  /usr/bin/emacsclient.emacs24: error executing alternate editor 
    "sh -c 'echo "WITH-EDITOR: $$ OPEN $0"; sleep 604800 & sleep=$!; trap "kill $sleep; exit 0" USR1; trap "kill $sleep; exit 1" USR2; wait $sleep'"
error: There was a problem with the editor 
  '/usr/bin/emacsclient.emacs24 --socket-name=/root/.emacs.d/server/server'.
Please supply the message using either -m or -F option.

当我尝试手动启动 emacsclient 时,emacsclient 出现错误:

/usr/bin/emacsclient.emacs24 --socket-name=/root/.emacs.d/server/server tmp.make
/usr/bin/emacsclient.emacs24: connect: Connection refused
/usr/bin/emacsclient.emacs24: error accessing socket "/root/.emacs.d/server/server"

这表明这实际上并不是一个 Magit 错误,而是一个 emacsclient 错误,而且实际上它可能正在发生,因为我在 docker 内运行,尽管我对此不确定。

有谁知道如何启动 emacsclient 或绕过 magit 中 emacsclient 的要求。曾经有一个插件模式可以绕过 magit 内的 emacsclient,但不久前它已被弃用并从 melpa 中删除,所以我不太热衷于尝试它。

更新 emacs --daemon 在 docker 内启动没有问题,但 magit commit 仍然不起作用,所以也许这根本不是 docker 问题?

emacs --daemon                                                                         

 Warning: due to a long standing Gtk+ bug                                               
 http://bugzilla.gnome.org/show_bug.cgi?id=85715                                        
 Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost. 
 Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.      
 Loading 00debian-vars...                                                               
 Loading 00debian-vars...done                                                           
 Loading /etc/emacs/site-start.d/50cmake-data.el (source)...                            
 Loading /etc/emacs/site-start.d/50cmake-data.el (source)...done                        
 Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...                   
 Loading debian-ispell...                                                               
 Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...           
 Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done       
 Loading debian-ispell...done                                                           
 Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...             
 Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done         
 Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done               
 Loading /root/.emacs.d/init_func.el (source)...                                        
 Loading /root/.emacs.d/init_func.el (source)...done                                    
 Loading flymake...                                                                     
 Loading flymake...done                                                                 
 Loading company...                                                                     
 Loading company...done                                                                 
 Loading linum...                                                                       
 Loading linum...done                                                                   
 [yas] Prepared just-in-time loading of snippets successfully.                          
 Loading /root/.emacs.d/recentf...                                                      
 Loading /root/.emacs.d/recentf...done                                                  
 Cleaning up the recentf list...                                                        
 Cleaning up the recentf list...done (0 removed)                                        
 Starting Emacs daemon.                                                                 

最佳答案

仔细检查您的基础镜像:this thread报告看到相同的错误消息:

I managed to figure out the problem. I had byte compiled the emacs code with emacs24, and loading that in emacs23 caused all heck to break loose.
With the byte compilation done with a matching version of emacs, the test suite passes.

您可以find here an example of building a docker image使用 emacs,来自 various distro (包括 Ubuntu 16.04)。
Emacs(23,替换为您的版本)is installed as :

export DEBIAN_FRONTEND=noninteractive
test $1 = 7.11 && emacs=emacs23-nox || emacs=emacs-nox
apt-get update
apt-get install -y -q build-essential git \
    libxapian-dev libgmime-2.6-dev libtalloc-dev \
    zlib1g-dev python-sphinx man dtach $emacs gdb gpgsm
apt-get -y autoremove
apt-get -y clean
rm -rf /var/lib/apt/lists/

关于docker - Magit无法连接到docker内的emacsclient?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45069329/

相关文章:

docker - 从位于 docker 中的应用程序连接到 Redis 服务器

docker - 使用 docker 持续部署

linux - 如何检查框架中或终端中的 emacs?

git - 如何使用 magit 编辑提交的差异

version-control - 在 Emacs Lisp 中获取 VC 根

emacs - Emacs 服务器可以编辑 Emacs 客户端指定的远程文件吗?

emacs - 如何设置 Emacs 服务器使用的端口?

amazon-web-services - docker 容器中的“aws configure”将不使用环境变量或配置文件

docker - Docker和Cinder,在openstack中可能吗?

emacs - 在magit中,如何查看分支添加到当前分支的差异?