"bash: aws: command not found" on Windows 7 in Git Bash

Viewed 18105

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?

3 Answers

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.

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

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

Related