Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvim always logs server_start:164 error in WSL (SOLVED: permissions issue) #26058

Closed
xudyang1 opened this issue Nov 15, 2023 · 4 comments
Closed
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md filesystem file metadata/attributes, filenames, path manipulation platform:wsl startup Nvim startup sequence (`:h startup`)
Milestone

Comments

@xudyang1
Copy link

Problem

In windows subsystem for linux (WSL), use neovim with custom init.lua or with --clean flag always produce the following error:

WRN 2023-11-15T16:47:33.489 ?.5332     server_start:164: Failed to start server: permission denied: /run/user/1000//
WRN 2023-11-15T16:48:25.884 ?.5564     server_start:164: Failed to start server: permission denied: /run/user/1000//
WRN 2023-11-15T16:49:03.825 ?.5888     server_start:164: Failed to start server: permission denied: /run/user/1000//
WRN 2023-11-15T16:49:17.203 ?.6133     server_start:164: Failed to start server: permission denied: /run/user/1000//
WRN 2023-11-15T16:49:31.533 ?.6262     server_start:164: Failed to start server: permission denied: /run/user/1000//

nvim or nvim --clean appends a line WRN .... to the file in ~/.local/state/nvim/log

Steps to reproduce

nvim --clean   # `:q`
cat ~/.local/state/nvim/log

Expected behavior

I also use neovim in powershell from the host system (windows 10), the log file (~/AppData/Local/nvim-data/log) does not contain such errors. Therefore, this may be a bug in neovim when used inside WSL environment.

Neovim version (nvim -v)

0.9.4

Vim (not Nvim) behaves the same?

i don't use vim

Operating system/version

ubuntu 22.04 (WSL)

Terminal name/version

windows terminal/ 1.19.2682.0

$TERM environment variable

xterm-256color

Installation

appimage

@xudyang1 xudyang1 added the bug issues reporting wrong behavior label Nov 15, 2023
@zeertzjq zeertzjq added startup Nvim startup sequence (`:h startup`) platform:wsl labels Nov 15, 2023
@justinmk
Copy link
Member

justinmk commented Nov 30, 2023

permission denied: /run/user/1000//

This implies that the temp directory being calculated by vim_mktempdir is not
correct. Maybe this function is failing:

neovim/src/nvim/os/users.c

Lines 125 to 133 in 400b784

int os_get_username(char *s, size_t len)
{
#ifdef UNIX
return os_get_uname((uv_uid_t)getuid(), s, len);
#else
// TODO(equalsraf): Windows GetUserName()
return os_get_uname((uv_uid_t)0, s, len);
#endif
}

  • Is /run/user/1000/ an existing directory on your system?
  • What does does this show:
    :echo v:servername
    :echo stdpath('run')
    :echo tempname()
    
  • What happens if you start Nvim with the $TMPDIR env var set to the current directory?
    TMPDIR=. nvim
    
    • What does :echo tempname(), etc., say in that case?
  • If you are interested in debugging this, should be easy to set a breakpoint here:
    static void vim_mktempdir(void)

@justinmk justinmk added this to the backlog milestone Nov 30, 2023
@justinmk justinmk added the complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md label Nov 30, 2023
@xudyang1
Copy link
Author

xudyang1 commented Jan 21, 2024

permission denied: /run/user/1000//

This implies that the temp directory being calculated by vim_mktempdir is not correct. Maybe this function is failing:
...

Sorry for replying so late.

  1. /run/user/1000 is an existing directory but it is empty and requires sudo.

  2. Here are the results:

:echo v:servername

:echo stdpath('run') 
/run/user/1000/
:echo tempname()
/tmp/nvim.myUserName/0EKFgk/0
  1. TMPDIR=. nvim results in :echo tempname() being directory ./nvim.myUserName/someRandomString/ under current directory when using nvim. After exiting neovim, only ./nvim.myUserName/ exist.
    Outputs of :echo v:servername and :echo stdpath('run') remain unchanged.

@xudyang1
Copy link
Author

xudyang1 commented Jan 26, 2024

@justinmk I think this issue is particularly related to the failed service user@1000.service in WSL2 with systemd enabled.

$ systemctl --failed
  UNIT              LOAD   ACTIVE SUB    DESCRIPTION
● user@1000.service loaded failed failed User Manager for UID 1000

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
1 loaded units listed.
$ systemctl status user@1000.service
× user@1000.service - User Manager for UID 1000
     Loaded: loaded (/lib/systemd/system/user@.service; static)
    Drop-In: /usr/lib/systemd/system/user@.service.d
             └─timeout.conf
     Active: failed (Result: exit-code) since Fri 2024-01-26 12:20:01 EST; 23min ago
       Docs: man:user@.service(5)
    Process: 1625 ExecStart=/lib/systemd/systemd --user (code=exited, status=1/FAILURE)
   Main PID: 1625 (code=exited, status=1/FAILURE)
        CPU: 15ms

Jan 26 12:20:01 DESKTOP-********* systemd[1]: Starting User Manager for UID 1000...
Jan 26 12:20:01 DESKTOP-********* systemd[1625]: pam_unix(systemd-user:session): session opened for user bell(uid=1000) by (uid=0)
Jan 26 12:20:01 DESKTOP-********* systemd[1625]: pam_systemd(systemd-user:session): Runtime directory '/run/user/1000' is not owned by UI>
Jan 26 12:20:01 DESKTOP-********* systemd[1625]: pam_systemd(systemd-user:session): Not setting $XDG_RUNTIME_DIR, as the directory is not>
Jan 26 12:20:01 DESKTOP-********* systemd[1625]: Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.
Jan 26 12:20:01 DESKTOP-********* systemd[1]: user@1000.service: Main process exited, code=exited, status=1/FAILURE
Jan 26 12:20:01 DESKTOP-********* systemd[1]: user@1000.service: Failed with result 'exit-code'.
Jan 26 12:20:01 DESKTOP-********* systemd[1]: Failed to start User Manager for UID 1000.
$ sudo systemctl restart user@1000.service
Job for user@1000.service failed because the control process exited with error code.
See "systemctl status user@1000.service" and "journalctl -xeu user@1000.service" for details.
$ journalctl -xeu user@1000.service
Jan 26 12:47:44 DESKTOP-********* systemd[1]: Starting User Manager for UID 1000...
░░ Subject: A start job for unit user@1000.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit user@1000.service has begun execution.
░░
░░ The job identifier is 573.
Jan 26 12:47:44 DESKTOP-********* systemd[2356]: pam_unix(systemd-user:session): session opened for user bell(uid=1000) by (uid=0)
Jan 26 12:47:44 DESKTOP-********* systemd[2356]: pam_systemd(systemd-user:session): Runtime directory '/run/user/1000' is not owned by UI>
Jan 26 12:47:44 DESKTOP-********* systemd[2356]: pam_systemd(systemd-user:session): Not setting $XDG_RUNTIME_DIR, as the directory is not>
Jan 26 12:47:44 DESKTOP-********* systemd[2356]: Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.
Jan 26 12:47:44 DESKTOP-********* systemd[1]: user@1000.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ An ExecStart= process belonging to unit user@1000.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Jan 26 12:47:44 DESKTOP-********* systemd[1]: user@1000.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit user@1000.service has entered the 'failed' state with result 'exit-code'.
Jan 26 12:47:44 DESKTOP-********* systemd[1]: Failed to start User Manager for UID 1000.
░░ Subject: A start job for unit user@1000.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit user@1000.service has finished with a failure.
░░
░░ The job identifier is 573 and the job result is failed.
  • Also note that WSL Ubuntu-22.04 does not set $TMP, TMPDIR, $TEMP, and $USERPROFILE:
$ echo $TMP,$TMPDIR,$TEMP,$USERPROFILE
,,,
  • But $XDG_RUNTIME_DIR is set despite the error message from the command $ systemctl status user@1000.service
$ echo $XDG_RUNTIME_DIR
/run/user/1000/
  • /run/user/1000/ is owned by root user only, this may be the consequence of the failed service user@1000.service.
$ sudo ls -ld /run/user/1000/
drwx------ 2 root root 4096 Nov 15 10:49 /run/user/1000/

Related:

@xudyang1
Copy link
Author

It could be this podman issue, solved by changing owner to current user sudo chown username:usergroup /run/user/1000.

Closed.

@justinmk justinmk added filesystem file metadata/attributes, filenames, path manipulation and removed bug issues reporting wrong behavior labels Jan 26, 2024
@justinmk justinmk changed the title neovim always log server_start:164 error in WSL Nvim always logs server_start:164 error in WSL (SOLVED: permissions issue) Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md filesystem file metadata/attributes, filenames, path manipulation platform:wsl startup Nvim startup sequence (`:h startup`)
Projects
None yet
Development

No branches or pull requests

3 participants