Still on a never ending quest to get per project settings working for python using tramp and .dir-locals.

Hitting a strange problem when I open a buffer I am asked if i would like to run my .dir-locals.el to which I reply yes, everything applies and I do not see any errors.

How ever they are not applied, if how ever I create an org file and setq all the parameters everything works.

Currently using this minimal example generated by emacs.

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

Also had this format originally both of which should be valid ?

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

My only thought is that its because its a remote tramp setting I am applying although the files are stored locally.

I can tell the parameters are not set because any python interpreter command errors with a local path as opposed to the org applied version which just works.

Any suggestions on what to check or possible source of my issue ?

  • You shouldn't be attempting to infer whether the dir-local values are set based on other behaviour -- you can check the values directly. What does M-: python-shell-interpreter RET tell you in a python-mode buffer when using that .dir-locals.el? If it's set to the intended value, you know that your problem actually lies elsewhere. – phils Apr 9 '18 at 22:59
  • Also, what does an org file have to do with this? Maybe you are executing python scripts via org babel, but without details it's a strange comparison to make. If you are going to compare using dir-locals with setting variables manually, I would expect you to be testing both approaches in the same mode. – phils Apr 9 '18 at 22:59
  • Okay this has confused me even more now, running M-: python-shell-interpreter on the current buffer shows the correct value but its definitely not using that value as I get a my local project location in the debug. – Oly Apr 10 '18 at 6:10
  • no real significance to the org file other than I use it to test emacs lisp snippets by loading and running the block between saves for testing. In this instance executing (setq python-shell-interpreter "/docker:root@hackdev_django_1:/usr/local/bin/python") makes everything work which is very perculiar. – Oly Apr 10 '18 at 6:14
  • I suspect that the code which is using python-shell-interpreter is not running in the context of a buffer which has that directory-local (buffer-local) value. If you're setting the global value of that variable in your org file, that would corroborate this theory. – phils Apr 10 '18 at 7:02

Your Answer

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

Browse other questions tagged or ask your own question.