如何启动Emacs图形界面?Ubuntu 14.04下启动异常求助
Hey there, I've run into this exact issue on Ubuntu 14.04 before—let's walk through some troubleshooting steps to get Emacs' graphical interface working:
Verify you installed the GUI-enabled Emacs package
Sometimessudo apt-get install emacspulls in the headlessemacs-noxpackage by default depending on your repositories. Check which package you have installed with:dpkg -l | grep emacsIf you only see
emacs-noxand no entries likeemacs-gtkoremacs24-gtk, install the GUI version explicitly:sudo apt-get install emacs-gtkThis package is compiled for GTK, which plays nicely with Ubuntu's Unity desktop.
Check the DISPLAY environment variable
Emacs' GUI relies on the X Window System, and theDISPLAYvariable tells it which X server to use. In a local terminal, run:echo $DISPLAYYou should see something like
:0or:0.0. If it's empty, your terminal isn't connected to the X server (this happens if you're in a pure text TTY or SSHing without X forwarding). For a local desktop, manually set the variable and try again:export DISPLAY=:0 emacs testfileForce Emacs to launch the GUI with command-line flags
If the package and DISPLAY check out, use these flags to bypass terminal-mode defaults:- Use
-cto create a new graphical frame directly:emacs -c testfile - Or explicitly specify the display device:
emacs --display :0 testfile
- Use
Rule out configuration issues
Old or misconfigured Emacs settings can force terminal mode. Test launching Emacs without loading your config:emacs -q testfileIf the GUI pops up now, your
~/.emacsor~/.emacs.d/folder has a setting causing the problem. Back up your config and gradually reintroduce settings to find the culprit (look for lines modifyinginitial-terminal-frame-alistor forcing terminal-specific behavior).Check if your system's GUI environment is working
If none of the above works, test another graphical app likegedit testfile. If that also fails, the issue isn't with Emacs—it's a problem with Ubuntu's Unity desktop or Xorg server. Try restarting your desktop or checking Xorg logs for errors.
内容的提问来源于stack exchange,提问作者Mike S

