Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git bash will not resolve "sam" command

I am using Win10 latest. After installing AWS-SAM-CLI and testing the installation with:

sam --version

I get the message

bash: sam: command not found

however, when I use Powershell, cmd or ConEmu they can all resolve "sam".

the path is "e/Program Files/Amazon/AWSSAMCLI/bin" but other commands like "yarn" work fine which is also installed at "e/Program Files/..."

Any ideas? Thanks

like image 765
Blobafet Avatar asked Jul 19 '20 22:07

Blobafet


People also ask

What is the latest version of Sam?

The current version of SAM is SAM 2021.12. 02 Revision 2, SSC 274. Use the Download buttons below to download the current version for Windows, Mac, or Linux.

What is the Sam build command?

The sam build command processes your AWS SAM template file, application code, and any applicable language-specific files and dependencies. The command also copies build artifacts in the format and location expected for subsequent steps in your workflow.

Why is the AWS Sam CLI command not found?

Shell error: "command not found" If you receive this error, your shell can't locate the AWS SAM CLI executable in the path. Verify the location of the directory where you installed the AWS SAM CLI executable, and then verify that the directory is on your path.

How do I Run Sam CLI from CMD?

You can use alias sam="sam.cmd" if it works in normal cmd. Now sam --version should work. The windows version of the SAM CLI does not have a direct executable binary. It is instead a .cmd script that echos your options to the python executable. @rem @echo off setlocal "%~dp0/../runtime/python.exe" -m samcli %*


Video Answer


3 Answers

sam.cmd --version

The windows version of the SAM CLI does not have a direct executable binary. It is instead a .cmd script that echos your options to the python executable.

@rem
@echo off

setlocal

"%~dp0/../runtime/python.exe" -m samcli %*

I haven't figured out how to make it work with

sam --version

My assumption is that powershell and command prompt see .cmd as an executable not requiring an extension where git bash does not.

like image 119
James Pickett Avatar answered Nov 12 '22 19:11

James Pickett


Here is how I got it work with an alias. alias sam="/c/Program\ Files/Amazon/AWSSAMCLI/bin/sam.cmd"

like image 21
Clinton White Avatar answered Nov 12 '22 19:11

Clinton White


$ vi ~/.bashrc  # or favorite editor

Add:

alias sam='sam.cmd'

Then:

$ source ./.bashrc # can use '. ./.bashrc
like image 42
SpiesInOrbit Avatar answered Nov 12 '22 19:11

SpiesInOrbit