6

I'm trying to use AWS CLI to access CodeCommit. And it's sort of working. I am able to use the aws command in the Windows command prompt. However, when I try to access it using the Git Bash shell, it says

"bash: aws: command not found."

Additionally, when I try to do do a git clone in the Windows command promt, trying to access CodeCommit, it tries to use aws using the credentials helper, which also results in "aws: command not found."

enter image description here

I followed the instructions in the AWS documentation, which suggests some directories to add to the PATH:

https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-windows.html#awscli-install-windows-path

Here's what my PATH variable looks like:

C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\;C:\Windows\System32;;C:\Program Files\Docker Toolbox;C:\Users\ddrayton\MyCurl;%USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts;C:\Program Files\Amazon\AWSCLI;C:\Program Files (x86)\Amazon\AWSCLI;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\Scripts

But I'm not sure if it's a PATH problem, since the Windows command prompt has no problem accessing the "aws" command.

Any ideas?

David
  • 1,620
  • 3
  • 20
  • 39

3 Answers3

10

Fixed this by simply installing the AWS CLI again but this time using Git Bash instead of the Windows command prompt.

pip install awscli

If anyone could provide some insight as to why this was necessary, it would be appreciated.

David
  • 1,620
  • 3
  • 20
  • 39
  • This helped me. In my situation i even did not have pip installed. So I had to install Pithon, then use the pip command above. Thank you very much! – Andrey Tagaew Nov 02 '18 at 22:45
  • 2
    I should note that although this solution fixed my problem on one computer, it did NOT fix my problem on my other computer. :-( – David Dec 13 '18 at 13:41
  • It worked for me, i also faced same problem, aws command was working fine in command prompt but not in git bash. – Vishwakant Nov 25 '20 at 20:11
  • 1
    I didn't have to run `pip install awscli` I simply installed awscli via the windows UI installer and then restarted my code editor and terminal and it worked – Olumide Sep 08 '21 at 02:20
7

In my case, I think a recent-to-me update to the AWS CLI changed what's run to being aws.cmd (full path C:\Program Files\Amazon\AWSCLI\bin\aws.cmd)

Git Bash needs the extension aws.cmd to make it work.

In Bash, you could try typing aws.cmd vs aws. If the former works, but not the latter, you can do alias aws='aws.cmd' in your bash startup script. I don't know if it's the best solution, but it worked for me.

FWIW, I think it's related to this: https://unix.stackexchange.com/questions/280528/is-there-a-unix-equivalent-of-the-windows-environment-variable-pathext

Penny
  • 347
  • 4
  • 12
1

On Windows 10 I was installing just once from GitBash via pip install awscli --upgrade --user as described in AWS manual for CLI installation for Linux

It installed aws executables into %USERPROFILE%\AppData\Roaming\Python\Python37\Scripts

After that just add this folder to your PATH. Re-open GitBash or cmd - it should work from both places

Ameba Brain
  • 313
  • 1
  • 7