Trying to set up .dir-locals to use a custom python interpreter inside a container so i can use run-python and get the REPL inside the container.

I have this setup which seems to partially work in that its trying to use the interpreter i have specified.

((nil . (
        (python-shell-interpreter . "/docker:hackdev_django_1:/usr/local/bin/python")

However I just get the below error. I assume its something to do with the added slashes.

tramp-error: Not a Tramp file name: "/docker\:hackdev_django_1\:/usr/local/bin/python"

If I use find-file and navigate to the bin folder that works, and using the which command tells me that the path is correct inside the container. So I am at a bit of a loss.

GNU Emacs 25.2.2
Tramp version built in

I tried upgrading but I could not convince Emacs to use my downloaded version over the built-in version.

Looking for next thing to try. Is this perhaps a known bug ?

Update 01

The python shell calculate command runs the docker command through shell-quote-argument which is adding the slashes and breaking things.

I then have to add (setq tramp-histfile-override "/dev/null") to get around another issue where it looks for a history file which does not exist.

Currently running the code below to progress.

  (setq tramp-verbose 6)
  (defun python-shell-calculate-command ()
    "Calculate the string used to execute the inferior Python process."
    (format "%s %s"
  (setq python-shell-interpreter "/docker:hackdev_django_1:/usr/local/bin/python")
  (setq tramp-histfile-override "/dev/null")

using C-x C-f I can type /docker:hackdev_django_1:/usrlocal/bin/py tab and have it list python.

tramp buffer output

  • Do you load docker-tramp in your init file? – Michael Albinus Apr 5 '18 at 19:37
  • I do indeed, and the fact I can open files uing /docker tells me that docker tramp itself is working. seems it something todo with run-python integration perhaps ? – Oly Apr 5 '18 at 21:51
  • Perhaps. Set debug-on-error to t, and show the backtrace. – Michael Albinus Apr 6 '18 at 6:48
  • I take you meant debug-on-entry this does nothing, most likely because its a handled error I assume ? – Oly Apr 6 '18 at 7:30
  • Actually you meant set the variable, same effect with that defined as true – Oly Apr 6 '18 at 7:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.