0

I open the file like this, with hopping:

C-x C-f /ssh:b0ef@ximian|sudo:ximian:/etc/nixos/configuration.nix RET

If I call org-store link, I get this:

[[file:/sudo:root@ximian:/etc/nixos/configuration.nix::{ config, pkgs, ... }:]]

This is not correct, cause it has removed the hop and when trying to open, I get:

tramp-error: Host name ‘ximian’ does not match ‘\`\(?:spartacus\|\(?:127\.0\.0\.1\|::1\|localhost[46]?\)\)\'’

If I use scp as suggested, I get:

Error in post-command-hook (ivy--queue-exhibit): (user-error "Method ‘scp’ is not supported for multi-hops.")
6
  • Works for me: I do C-x f /sudo::/etc/fstab, store the link with C-c l. open an Org mode file, insert the the link with C-c C-l and the link works. It shows [file:/sudo:root@<hostname>:/etc/fstab] where <hostname> is the FQDN of localhost. You need to give us more information about what you are doing exactly.
    – NickD
    Sep 19, 2023 at 15:28
  • First of all, I don't understand how you do "C-x f /sudo::/etc/fstab", cause that's opening a local file, yet your link is a network file?;) Sep 19, 2023 at 17:36
  • (I meant C-x C-f of course, but you knew that :-) ) The link is a file: link: it doesn't know whether the referent is a local or a remote file. That's determined by the path. So open the file (local e.g. /sudo:;/etc/fstab or remote using e.g. /scp:root@ximian:/etc/nixos/configuration.nix, do C-c l in the file and then insert the link in your Org mode file with C-c C-l - then test it.
    – NickD
    Sep 19, 2023 at 18:43
  • BTW, the tramp sudo method is a local method: it just allows you to access a local file as a different user. You have to use something like the ssh or scp methods for remote access.
    – NickD
    Sep 19, 2023 at 18:51
  • This command: "/scp:root@ximian:/etc/nixos/configuration.nix" would mean that the ssh server allows root logins. I'm trying to hop, first login as b0ef, then sudo on the remote system to root Sep 20, 2023 at 5:46

1 Answer 1

1

There are two possible solutions.

  1. Save the hop. Set tramp-save-ad-hoc-proxies to t. With this setting, Tramp remembers that /sudo:root@ximian: has to use the full path /ssh:b0ef@ximian|sudo:ximian:.

  2. Use expanded file names. In Tramp 2.6.1 (Emacs 29.2, or from GNU ELPA), set tramp-show-ad-hoc-proxies to t. By this, all hops are kept, also when you save it.

See the Tramp manual

N.B.: scp cannot be used for multi-hop file names.

5
  • Hmm, I still get the same link, even when I (setq tramp-show-ad-hoc-proxies t) Sep 20, 2023 at 7:13
  • Which Emacs / Tramp version are you using? Sep 20, 2023 at 16:22
  • GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) and Tramp 2.6.0.29.1. Ah, ok, Emacs-29.2;). That's pretty recent;) ok, grabbing it and reporting back. Hmm, I don't even have access to an Emacs-29.2 in NixOS Unstable;) Sep 20, 2023 at 19:44
  • Emacs 29.2. isn't released yet, I'm building from git. Your better option is to install Tramp 2.6.1.2 from GNU ELPA. Note that there is a bug in Emacs 29.1 which prevents Tramp installation, see elpa.gnu.org/packages/tramp.html for mitigation action. Sep 21, 2023 at 6:33
  • Thank you;) I've installed Emacs git, so the links works now;) Nov 11, 2023 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.