purcell / exec-path-from-shell

Make Emacs use the $PATH set up by the user's shell
Other
1.41k stars 81 forks source link

very slow #75

Closed adrianstaniec closed 6 years ago

adrianstaniec commented 6 years ago

doubles my emacs startup time:

esup

init.el:51  0.755sec   57%
(use-package exec-path-from-shell
:config
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))
purcell commented 6 years ago

That's because it runs a shell, so your shell startup time is added to the emacs startup time, and this isn't an issue that can be fixed in the package. In many cases you can add exec-path-from-shell-initialize to your after-init-hook to defer its initialisation, but that does mean that other packages' startup code cannot rely on exec-path/$PATH having been set correctly, which could cause complications. If your shell is configured to set $PATH correctly even when run non-interactively, you can also try removing -i from exec-path-from-shell-arguments.

adrianstaniec commented 6 years ago

I tried your second suggestion, like this:

(custom-set-variables
 '(exec-path-from-shell-arguments (quote ("-l"))))   ; so without "-i"

but that did not makes thing quicker.

Then I tried the first suggestion like this: ;; Make sure Emacs uses same PATH as in shell

(defun my-exec-path-from-shell-initialize ()
     (when (memq window-system '(mac ns x))
       (exec-path-from-shell-initialize)))

(use-package exec-path-from-shell
  :init
  (add-hook 'after-init-hook 'my-exec-path-from-shell-initialize))

and that indeed speeds the startup 100%. And the functionality still works for me, (finding executables in PATH), so I will stick with that.

Thank you for quick response and a solution!

purcell commented 6 years ago

If you're mostly deferring the loading of other files and features using use-package then this approach should indeed work pretty well. :-)