Mosh: Difference between revisions

From NixOS Wiki
imported>Ghuntley
No edit summary
imported>Mic92
No edit summary
Line 9: Line 9:
* nix-shell failing with <code>Error in tempdir() using /run/user/1000/nix-shell.XXXXX</code>
* nix-shell failing with <code>Error in tempdir() using /run/user/1000/nix-shell.XXXXX</code>


This is caused by the way <code>mosh</code> handles logging-in to the system, the login is actually handled by a short <code>ssh</code> session, which ends immediately. <code>logind</code>, as it is used, closes the user's session and cleans up behind, since there is no loingering configured by default.
This is caused by the way <code>mosh</code> handles logging-in to the system, the login is actually handled by a short <code>ssh</code> session, which ends immediately. <code>logind</code>, as it is used, closes the user's session and cleans up behind, since there is no lingering configured by default.


As a workaround, it is possible to set an alias in the user's shell wrapping <code>mosh-server</code> to keep the session around.<ref>[https://botbot.me/freenode/nixos/2017-12-20/?msg=94859441&page=1 #nixos 2017-12-20]</ref>
To enable lingering use:
 
<syntaxhighlight lang=console>
$ loginctl enable-linger $USER
</syntaxhighlight>
 
Then reconnect with mosh.
 
As a workaround, it is also possible to set an alias in the user's shell on the server wrapping <code>mosh-server</code> to keep the session around.
<ref>[https://github.com/NixOS/nixpkgs/issues/29234 issue#29234]</ref>


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>

Revision as of 09:12, 18 January 2018

Troubleshooting

Missing /run/user/1000

Using a mosh session, $XDG_RUNTIME_DIR (/run/user/1000) doesn't exist and causes issues such as:

  • nix-shell failing with Error in tempdir() using /run/user/1000/nix-shell.XXXXX

This is caused by the way mosh handles logging-in to the system, the login is actually handled by a short ssh session, which ends immediately. logind, as it is used, closes the user's session and cleans up behind, since there is no lingering configured by default.

To enable lingering use:

$ loginctl enable-linger $USER

Then reconnect with mosh.

As a workaround, it is also possible to set an alias in the user's shell on the server wrapping mosh-server to keep the session around. [1]

alias mosh-server = "systemd-run --user --scope mosh-server"

See https://github.com/NixOS/nixpkgs/issues/3702#issue-40762878 for alternative option


References