0

I have two versions of AWS SAM CLI installed on my MacOS. I got the following result when running where sam in zsh:

$ where sam  
/Users/MyName/.pyenv/shims/sam
/usr/local/bin/sam

When running sam command, MacOS runs the sam under /Users/MyName/.pyenv/shims/.

Is it possible to configure my zsh terminal so that sam runs the version under /usr/local/bin?

The reason I want to do this is that /Users/MyName/.pyenv/shims/sam returns an error after I execute it.

I'd like to avoid this problem by running the sam under /usr/local/bin/.

Brian
  • 12,145
  • 20
  • 90
  • 153

1 Answers1

2

A simple way to override PATH lookup is to create an alias:

alias sam=/usr/local/bin/sam

The alias will get priority, so /usr/local/bin/sam will be run instead of whichever executable comes first in PATH lookup.

You could also make /usr/local/bin come first in PATH:

PATH=/usr/local/bin:$PATH

But then you might want other programs in /Users/MyName/.pyenv/shims to have still have priority, in which case the alias would be better.

muru
  • 4,723
  • 1
  • 34
  • 78