Skip to content

Update docker-with-sudo macro to also work on remotes - #260

Open
SnowDiver wants to merge 1 commit into
Silex:mainfrom
SnowDiver:add-sudo-support-on-remotes
Open

Update docker-with-sudo macro to also work on remotes#260
SnowDiver wants to merge 1 commit into
Silex:mainfrom
SnowDiver:add-sudo-support-on-remotes

Conversation

@SnowDiver

Copy link
Copy Markdown

I updated the macro as I wanted to run docker command on a remote wtih elevated privileges. I used the function '"tramp-file-name-with-sudo" to update the default-directory to the sudo variant which works for local and remote paths.

@Silex

Silex commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Seems you forgot a )

Also indenting looks weird. Please verify.

@SnowDiver
SnowDiver force-pushed the add-sudo-support-on-remotes branch from 66cdbbb to 3dd9553 Compare July 30, 2026 07:16
@SnowDiver
SnowDiver force-pushed the add-sudo-support-on-remotes branch from 3dd9553 to d333021 Compare July 30, 2026 07:17
@SnowDiver

Copy link
Copy Markdown
Author

Ah sorry, that's what you get from using the browser :/
I updated it now.

@Silex

Silex commented Aug 3, 2026

Copy link
Copy Markdown
Owner

AI generated so verify 😉


Problem:

CI byte-compile fails with:
Error: the function `tramp-file-name-with-sudo' is not known to be defined.

Solution:

  • Tell the byte-compiler the symbol exists:
    (declare-function tramp-file-name-with-sudo "tramp")
  • Guard runtime use so Emacs without tramp doesn't break:
    wrap the call with (fboundp 'tramp-file-name-with-sudo) and fall back to default-directory.

Suggested patch:

(declare-function tramp-file-name-with-sudo "tramp")

(defmacro docker-with-sudo (&rest body)
  (declare (indent defun))
  `(let ((default-directory (if (and docker-run-as-root
                                     (fboundp 'tramp-file-name-with-sudo))
                                (tramp-file-name-with-sudo default-directory)
                              default-directory)))
     ,@body))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants