Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magit cannot connect to emacsclient inside docker?

I am running emacs24.5.1 inside docker (base image is Ubuntu). I installed emacs through apt-get. Furthermore I installed magit through melpa (magit version magit-20170702.858) and it's great. However when I try to commit something then magit encounters the following error:

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.

When I try to manually start emacsclient then emacsclient has the error:

/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"

Which suggests that it's not really a magit error but a emacsclient error, and really it probably is happening because I am running inside docker, although I am not sure about that.

Does anyone have a idea about how to either start emacsclient or to bypass the requirement of emacsclient inside magit. There used to an addon mode to bypass emacsclient inside magit, but that was deprecated and removed from melpa sometime ago, so I am not too keen on trying it on.

UPDATE emacs --daemon starts without issue inside docker, but magit commit still doesn't work so maybe it's not a docker issue after all?

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.                                                                 
like image 682
Pushpendre Avatar asked Oct 18 '22 09:10

Pushpendre


1 Answers

Double-check your base image: this thread reports seeing the same error message:

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.

You can find here an example of building a docker image with emacs, from various distro (including Ubuntu 16.04).
Emacs (23, replace it by your version) 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/
like image 135
VonC Avatar answered Oct 21 '22 00:10

VonC