Emacs takes unbelievably long to start

后端 未结 3 892
悲哀的现实
悲哀的现实 2021-01-12 07:27

Yesterday, I :q\'d Vim to try Emacs for a while. I\'ve started using Elisp (which is a hundred times better than VimScript), but even when I first installed it

相关标签:
3条回答
  • 2021-01-12 08:03

    Emacs's PROBLEM file says:

    *** Emacs startup on GNU/Linux systems (and possibly other systems) is slow.
    
    This can happen if the system is misconfigured and Emacs can't get the
    full qualified domain name, FQDN.  You should have your FQDN in the
    /etc/hosts file, something like this:
    
    127.0.0.1   localhost
    129.187.137.82  nuc04.t30.physik.tu-muenchen.de nuc04
    
    The way to set this up may vary on non-GNU systems.
    

    This "slow startup" typically comes from a timeout, and 30s sounds about right.

    As a side note: the DNS lookup that causes this slow down was considered important/useful back in the days where (almost) all machines had a static IP address. Nowadays the info gathered this way does not justify the effort, so starting with Emacs-25, Emacs does not perform this DNS lookup, so this problem should simply not exist any more.

    0 讨论(0)
  • 2021-01-12 08:08

    I had a smilar problem with emacs taking about 15 seconds for startup. In my case the reason was a DNS timeout. For some reason, with my dormitory DNS, a failed reverse lookup (host 127.0.0.1) takes about 10 seconds. Replacing the DNS server by the google nameserver (8.8.8.8) produces an almost instant "not found: 3(NXDOMAIN)" response. At the same time, emacs's startup time went down to less than 2 seconds. Thanks @Stefan who pointed me into the direction of DNS problems.

    Edit: adding the google nameserver as additional NS in Network Manager also does the job. (i.e. when your resolv.conf has the NSs in this order:

    nameserver a.b.c.d
    nameserver 8.8.8.8
    

    )

    0 讨论(0)
  • 2021-01-12 08:22

    Okay, I have a (quirky and temporary) solution. I have to run dhclient em1 to access the internet, which makes Emacs take 30 seconds to load, probably because of some timeout. So, having already run dhclient em1, I use a shell script to launch Emacs that does the following:

    sudo pkill dhclient
    sudo ifconfig em1 down
    emacs -nw -daemon 2> /dev/null
    sudo ifconfig em1 up
    sudo dhclient em1
    

    That disables networking, launches Emacs as a daemon, and re-enables networking. It's ugly, but it works for now. If anybody else has a better answer, I'd be happy to hear it. Of course, em1 would have to be replaced by your Ethernet device (probably eth0, I guess).

    0 讨论(0)
提交回复
热议问题