I am using Emacs (config file) on macOS Monterey (12.5).

There is something that I do not understand. After being queried on a specific version of the program called sdkman sdk, eshell and macOS default terminal present different outputs!!

On MacOS default terminal:

pedro@Pedros-MacBook-Air learn-cljs % sdk v

SDKMAN 5.15.0

Now, eshell returns a different output:

Welcome to the Emacs shell

 ~ $ cd projects/
 ~/projects $ cd learn-cljs/
 ~/projects/learn-cljs $ sdk -v
sdk: command not found

I am new to macOS but I have been using Emacs for a while on Linux machines. I was shocked by this behavior. I have never seen such asymmetry.

I know eshell has limited behavior compared to the default terminal even in Linux (for instance, htop does not work - by design). But this was a big surprise.

I have tried following @db48x's kind advice described below, but I can't make it work.

After using set-variable to tweak the value of exec-path, doing describe-variable on exec-path indicates:

("/opt/homebrew/bin" "/opt/homebrew/sbin" "/usr/local/bin" "/Users/pedro/.sdkman/candidates/java/current/bin" "/Users/pedro/.nvm/versions/node/v8.0.0/bin" "/usr/local/bin" "/usr/bin" "/bin" "/usr/sbin" "/sbin" "/opt/X11/bin" "/Applications/Emacs.app/Contents/MacOS/bin-arm64-11" "/Applications/Emacs.app/Contents/MacOS/libexec-arm64-11" "/Applications/Emacs.app/Contents/MacOS/libexec")

As you see, SDKman is the fourth element on exec-path variable. However, eshell still indicates: sdk: command not found.

How can I solve this?

1 Answer 1


Eshell is a shell. It is true that programs that need a terminal, such as htop, won’t work in Eshell. However, that is a separate issue.

When you run a command in a shell, it is customary for the shell to first match the command name against its list of built–in commands, and then to search for executable programs in a configured set of directories. By convention, the list of directories to search is stored in an environment variable called PATH. Most users will set this variable by editing a shell startup file, and most operating systems provide some kind of default value that will be used when the user hasn’t done this yet.

But different shells have different startup files. Anytime you try out a new shell, you will find that your customizations from your old shell aren’t there, because they live in a startup file that your new shell doesn’t know about. This is a good thing, because the command syntax and available customizations might differ greatly between shells.

The default shell on OSX is either bash or zsh (I don’t use OSX so I don’t know for sure which.) Bash looks for ~/.bashrc as a startup file, and zsh looks for ~/.zshrc

Eshell doesn’t have a separate startup file; it just uses variables which can be set or configured as part of your Emacs environment. The values of those variables come from your Emacs init file, which is usually ~/.emacs.d/init.el

To control the PATH in Eshell, customize the exec-path variable. You can do this by tying M-x customize-variable and then entering exec-path when prompted.

Edit: if this is the sdkman you are asking about, then there is simply no way to run it in eshell. It was written entirely in Bash scripts, so it’s not compatible with other shells.

¹: Naturally this is greatly simplified; they both look for multiple files. Check their manpages for the details.

²: Also simplified; see the Emacs manual for details.

  • 1
    You’re trying to let it find the sdk program, so you need to add whatever directory that program lives in to the list.
    – db48x
    Aug 2, 2022 at 20:41
  • 1
    Also, in re the difference between .bash_profile and .bashrc: I said that I was simplifying things :)
    – db48x
    Aug 2, 2022 at 20:42
  • 1
    Oh, and if you don’t know what directory sdk is in, go to the shell where it works and run type sdk. It will tell you that sdk is hashed (/some/path/to/sdk). That’s the directory you want to use.
    – db48x
    Aug 2, 2022 at 20:46
  • 1
    Fascinating. It is quite rare for software to install a shell function like that. For one thing, there are many shells out there and you cannot count on you users to always use the ones you already support.
    – db48x
    Aug 22, 2022 at 21:31
  • 1
    Is there an executable file called sdk in the directory that you added to exec-path? If not, then typing sdk won’t do anything.
    – db48x
    Aug 23, 2022 at 0:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.