hubisan / emacs-wsl

Install and run Emacs with the Windows Subsystem for Linux (WSL 2) in Windows 10 or 11.
568 stars 43 forks source link

emacs: Could not open file: /dev/tty #27

Closed umutzd closed 4 years ago

umutzd commented 4 years ago

I can't run emacs with either of the X Server software mentioned in the Readme file. Tried both of them, especially VcXsrv access disabled mode. I run them and I can confirm that they are running by looking at the task manager.

When I issue these commands:

export DISPLAY=:0
export LIBGL_ALWAYS_INDIRECT=1
setsid emacs

The output is:

Display :0 unavailable, simulating -nw
emacs: Could not open file: /dev/tty

I don't know if there's anything to do with SSH or something else. I think I read it thoroughly.

Output of uname -a command:

Linux DESKTOP-0Q60T4A 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
hubisan commented 4 years ago
  1. Are you using WSL1? The guide has not yet been updated to work with WSL2. If your are using WSL2 check out https://github.com/hubisan/emacs-wsl/issues/3.

  2. Default terminal emulator wsl.exe?
    Are you using the default terminal emulator that comes with WSL? That's wsl.exe at probably C:\Windows\System32\wsl.exe? What is the output of echo $TERM? Is it xterm-256color?

  3. Emacs in Terminal working? Open WSL and run

    emacs -nw -q

    This should open Emacs in the terminal without loading your init.el.

  4. Try without setsid and without loading the init file. Open WSL and run:

    export DISPLAY=:0.0
    emacs -q
hubisan commented 4 years ago

@umucorn Were you able to solve your issue?

umutzd commented 4 years ago

Hi, I solved this problem by following the instructions for WSL2. I was using WSL2.

umutzd commented 4 years ago

But now, If I issue the command emacs everything starts correctly.

Not when I run this:

alias eme='
export DISPLAY_NUMBER="0.0"
export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk "{print $2}"):$DISPLAY_NUMBER
export LIBGL_ALWAYS_INDIRECT=1
setsid emacs
exit
'

I issue eme command and everything disappears suddenly.

umutzd commented 4 years ago

I solve this problem by changing eme alias to this and moving exports anywhere else:

alias eme='
setsid emacs -q
exit
'
whompyjaw commented 2 years ago

Hi, I solved this problem by following the instructions for WSL2. I was using WSL2.

Can you elaborate on which instructions you followed exactly? There are several options for each problem it seems.