necaris / conda.el

Emacs helper library (and minor mode) to work with conda environments
MIT License
153 stars 49 forks source link

exec-path not set with activate #65

Closed gmoutso closed 2 years ago

gmoutso commented 4 years ago

exec-path was not set up correctly so I commented the following line

(let ((path-prefix (conda--get-path-prefix env-dir)))
          ;; setup emacs exec-path
          ;; (dolist (env-exec-dir (parse-colon-path path-prefix))  ; comment out
            (add-to-list 'exec-path env-exec-dir)
        ;; )  ;; comment out
          ;; setup the environment for subprocesses, eshell, etc
          (setenv "PATH" (concat path-prefix path-separator (getenv "PATH"))))

I am not sure what conda--get-path-prefix is meant to do, but it gives me the empty string in linux on my env dir (or any directory). And the previous env-exec-dir let would have been lost

(let* ((env-dir (conda-env-name-to-dir env-name))
             (env-exec-dir (concat (file-name-as-directory env-dir)
                                   conda-env-executables-dir)))
....
gmoutso commented 4 years ago

;; Package-Version: 20200120.1721 ;; Version: 0.4

necaris commented 4 years ago

@gmoutso how are you activating the environment? Are you using conda-env-activate or the autoactivate-mode?

gmoutso commented 4 years ago

I was using (conda-env-autoactivate-mode) but I have the wrong exec-path even without autoactivate (after conda-env-activate).

gmoutso commented 4 years ago

It works with emacs -Q (setting conda-anaconda-home and conda-env-home-directory to ~/miniconda). I will try to find what the issue is in my configuration.

gmoutso commented 4 years ago

After a frantic search, I realised that my init.el works perfectly well when loaded with emacs --daemon or emacs -q -l ~/.emacs.d/init.el where I have:

(require 'conda)
(custom-set-variables '(conda-anaconda-home "/home/moutsopoulosg/miniconda/"))
(conda-env-initialize-interactive-shells)
;; if you want eshell support, include:
(conda-env-initialize-eshell)
;; if you want auto-activation (see below for details), include:
(conda-env-autoactivate-mode)
(setq conda-env-home-directory "/home/moutsopoulosg/miniconda/")

It fails when I run the daemon (as I usually do) with a systemctl unit systemctl start --user emacs where under .config/systemd/user/emacs.service

[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure

[Install]
WantedBy=default.target

I have no idea why. Close the bug if you think it is not in conda.el's. In any case, thank you for the package and for your prompt response.

necaris commented 4 years ago

@gmoutso can you confirm if conda-env-activate works if you're not in daemon mode? I'd be happy to look into the daemon issue too but if it's not affecting conda.el functionality I probably won't have any more knowledge than you do on how to start debugging :smile:

gmoutso commented 4 years ago

Both daemon and non-daemon are working now, but unfortunately I cannot find the critical change I made in my init.el between not working and working (whether daemon or not).

necaris commented 2 years ago

With the changes to JSON activation this should be fixed; closing as inactive for now, but if this is still relevant please reopen!