If use iTerm
on macOS, we can set env values in its terminal. It also set path such as /usr/local/bin/
in ~/.bashrc
.
But in emacs' terminal as eshell
, run kubectl
shown kubectl: No such file or directory
.
It seems that it didn't find the command's path.
How to set path for emacs? For example, in spacemacs
.
I found this exec-path-from-shell
M-x package-install exec-path-from-shell RET
Edit ~/.emacs.d/init.el
to add
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
to the bottom.
Copy PATH
from .bashrc
to .profile
.
$ cat ~/.profile
export PATH=/usr/local/bin:/usr/bin:/bin
Start GNU Emacs For Max OS X still can't find the command's path in eshell. The spacemacs
alert:
Warning (initialization): An error occurred while loading ‘/Users/user/.emacs.d/init.el’:
Symbol's function definition is void: exec-path-from-shell-initialize
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
The full file of ~/.emacs.d/init.el
:
;;; init.el --- Spacemacs Initialization File -*- no-byte-compile: t -*-
;;
;; Copyright (c) 2012-2020 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;; Without this comment emacs25 adds (package-initialize) here
;; (package-initialize)
;; Avoid garbage collection during startup.
;; see `SPC h . dotspacemacs-gc-cons' for more info
(defconst emacs-start-time (current-time))
(setq gc-cons-threshold 402653184 gc-cons-percentage 0.6)
(load (concat (file-name-directory load-file-name)
"core/core-versions.el")
nil (not init-file-debug))
(load (concat (file-name-directory load-file-name)
"core/core-load-paths.el")
nil (not init-file-debug))
(load (concat spacemacs-core-directory "core-dumper.el")
nil (not init-file-debug))
;; Clean compiled files if they become stale or Emacs version has changed.
(load (concat spacemacs-core-directory "core-compilation.el")
nil (not init-file-debug))
(load spacemacs--last-emacs-version-file t (not init-file-debug))
(let ((default-directory spacemacs-start-directory))
(when (or (not (string= spacemacs--last-emacs-version emacs-version))
(spacemacs//contains-newer-than-byte-compiled-p
spacemacs--compiled-files))
(spacemacs//remove-byte-compiled-files spacemacs--compiled-files)))
(when (not (string= spacemacs--last-emacs-version emacs-version))
(spacemacs//update-last-emacs-version))
(if (not (version<= spacemacs-emacs-min-version emacs-version))
(error (concat "Your version of Emacs (%s) is too old. "
"Spacemacs requires Emacs version %s or above.")
emacs-version spacemacs-emacs-min-version)
;; Disable file-name-handlers for a speed boost during init
(let ((file-name-handler-alist nil))
(require 'core-spacemacs)
(spacemacs/dump-restore-load-path)
(configuration-layer/load-lock-file)
(spacemacs/init)
(configuration-layer/stable-elpa-init)
(configuration-layer/load)
(spacemacs-buffer/display-startup-note)
(spacemacs/setup-startup-hook)
(spacemacs/dump-eval-delayed-functions)
(when (and dotspacemacs-enable-server (not (spacemacs-is-dumping-p)))
(require 'server)
(when dotspacemacs-server-socket-dir
(setq server-socket-dir dotspacemacs-server-socket-dir))
(unless (server-running-p)
(message "Starting a server...")
(server-start)))))
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))