I hope to let org-babel can tangle to root permission file with tramp-sudo support like the following format:

#+BEGIN_SRC clojure :dir /sudo:: :tangle "/etc/kk.clj"

But it does not work. How to implement this?

Here is the error:

Debugger entered--Lisp error: (file-error "Removing old name" "Permission denied" "/etc/nginx/conf.d/kk.clj")
  #<subr delete-file>("/etc/nginx/conf.d/kk.clj" nil)
  ad-Advice-delete-file(#<subr delete-file> "/etc/nginx/conf.d/kk.clj")
  apply(ad-Advice-delete-file #<subr delete-file> "/etc/nginx/conf.d/kk.clj")
  ...  [assoc 4] 6 "\n\n(fn SPEC NAME)"] :tangle :shebang 0 :tangle-mode "yes" file-name-sans-extension "no" nil "." :mkdirp file-name-directory make-directory parents file-exists-p mapcar car delete-file generate-new-buffer " *temp*" make-byte-code "
  funcall-interactively(org-babel-tangle (4))
  call-interactively(org-babel-tangle nil nil)
  • Maybe I miss something, but the language setting conf requires loading a package ´ob-conf.el` or something like this. Could you show the complete example and the error message? May 5 '17 at 8:07
  • @MichaelAlbinus I updated my question. Check it out. May 6 '17 at 3:20

You can prefix tangle file path with /sudo::.

#+NAME: privoxy config for convert socks5 to HTTP proxy
#+BEGIN_SRC conf :tangle "/sudo::/etc/privoxy/config"
listen-address localhost:8118
forward-socks5 /  .

The problem is the file name, I believe. /etc/privoxy/config is an absolute file name, the :dir parameter does not count therefore.

If you use a relative file name, like :dir "/sudo::/etc/" :tangle "privoxy/config" it shall work. This is to be preferred, if you have several code blocks applicable to the same directory /sudo::/etc/ via a global header setting for :dir.

  • It does not work. If I use :dir "/sudo::/etc/" :tangle "privoxy/config". Then it will tangle to privoxy/config. May 6 '17 at 9:45
  • Then I suppose :tangle does ignore the :dir setting. Whether this is a bug or a feature I don't know. May 6 '17 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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