Aws-sam-cli: SAM is installed but command cannot be found

Created on 22 Oct 2020  路  7Comments  路  Source: aws/aws-sam-cli

Description

I've tried installing aws-sam-cli as recommended in the official documentation but it did not work. I've also tried several other methods including npm and pip, but none of them have made the sam command available for me.

Steps to reproduce

I've ran the commands:

brew tap aws/tap
brew install aws-sam-cl

They finish successfully, but trying to run sam --version afterwards displays:

Observed result

Command 'sam' not found, but there are 18 similar ones.

Expected result

Should display sam's version instead.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Ubuntu 18.04.5 LTS
  2. sam --version: when I try reinstalling brew tells me it's the latest version... but sam --version still does not work.
areinstallation stagneeds-investigation typbug

Most helpful comment

Further investigation is needed. Meanwhile, a workaround is to run brew install aws-sam-cli twice

All 7 comments

(Edit: added reproduced output)

I managed to reproduce the same Observed result, will investigate

ubuntu@ip-172-31-45-176:~$ brew tap aws/tap
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 3 formulae.

==> Tapping aws/tap
Cloning into '/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/aws/homebrew-tap'...
remote: Enumerating objects: 81, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 876 (delta 45), reused 13 (delta 6), pack-reused 795
Receiving objects: 100% (876/876), 174.39 KiB | 8.30 MiB/s, done.
Resolving deltas: 100% (433/433), done.
Tapped 7 formulae (44 files, 336.8KB).
ubuntu@ip-172-31-45-176:~$ brew install aws-sam-cli
==> Installing aws-sam-cli from aws/tap
==> Downloading https://linuxbrew.bintray.com/bottles/gdbm-1.18.1_1.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/dd/dd00a26fa20413f81477af032587de19bb620eef352a6d8dd3d9c3a176f6bd5a?__gda__=exp=1604433745~hmac=28c35e8e3d66bdba62b7c2e7aa1cac2b65f2ca4b371ab6f366ace5520dac9432&response-content-disposition=attachment%3Bfilename%3D%22gdbm-1
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/openssl%401.1-1.1.1h.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/61/61bf82b4b62e07589dec1fdc9eb9eb053da01565581fb18dd5df6232182238ec?__gda__=exp=1604433745~hmac=20ecdd3159d8a5a1be219e329f668d82c80ed87c31491acd85d72141343bbde9&response-content-disposition=attachment%3Bfilename%3D%22openss
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/ncurses-6.2.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/fc/fc5a0983a8afae8ef46945f3bec9dba9d66e81e879027d100d05088ea6f8043d?__gda__=exp=1604433746~hmac=38b53925fdc6cd665f36dc5141f305b9372b0c32c5fef2ed38266c6aa8adb755&response-content-disposition=attachment%3Bfilename%3D%22ncurse
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/readline-8.0.4.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/46/46da47db3da04b2f248e3cf2d6d14c55aa543555d1134f6cbbf07787a5bf0bd6?__gda__=exp=1604433746~hmac=478b2db697a8e4be03c2ebc427012968770ab76efe4df2880d1f37aca4f710b5&response-content-disposition=attachment%3Bfilename%3D%22readli
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/sqlite-3.33.0.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ba/bafd40d3bcbfe8350a04bd65fd2fced3ea98a74b27c6102972eca055d1eca8fe?__gda__=exp=1604433746~hmac=a60c94c8006a648916002292bf42416fea51a0606f8275685cd286036402b5e6&response-content-disposition=attachment%3Bfilename%3D%22sqlite
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/xz-5.2.5.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/67/676b0e178b3e7644f86385cb2497ac5ec490e2222ba3d0147e28bd85aff365cf?__gda__=exp=1604433747~hmac=0081c6b817628f089a8b682f552aa185a7dcd2b8b955d70e468eb8b0081f83df&response-content-disposition=attachment%3Bfilename%3D%22xz-5.2
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/bzip2-1.0.8.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e5/e5fce257b9fee119d28d0e7f7dac9332bd26b248fe35d983ba85104243e4bc2e?__gda__=exp=1604433747~hmac=1ae6cb177f8b33b0ba5e7ee0b20a3b71934af2f0cb70e134fc2db63a89fd4d04&response-content-disposition=attachment%3Bfilename%3D%22bzip2-
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/libffi-3.3.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/unzip-6.0_6.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://linuxbrew.bintray.com/bottles/python%403.8-3.8.6_1.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/5e/5ee32a98b1b9a45c0999f7655a1b5d0ad6336b236ae40bdbc0ff7234387e7f70?__gda__=exp=1604433747~hmac=23f052063d0fd5636b0f1506aeaf30a0c53adf36892fdd057216b77bf83f6436&response-content-disposition=attachment%3Bfilename%3D%22python
######################################################################## 100.0%
==> Downloading https://github.com/aws/aws-sam-cli/releases/download/v1.7.0//aws-sam-cli-1.7.0.x86_64_linux.bottle.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/92205085/21d99b80-1a05-11eb-9a95-8ad348e3c6c4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201103T195028
######################################################################## 100.0%
==> Installing dependencies for aws/tap/aws-sam-cli: gdbm, [email protected], ncurses, readline, sqlite, xz, bzip2, libffi, unzip and [email protected]
==> Installing aws/tap/aws-sam-cli dependency: gdbm
==> Pouring gdbm-1.18.1_1.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/gdbm/1.18.1_1: 40 files, 1MB
==> Installing aws/tap/aws-sam-cli dependency: [email protected]
==> Pouring [email protected]_64_linux.bottle.tar.gz
==> Downloading https://curl.haxx.se/ca/cacert-2020-01-01.pem
######################################################################## 100.0%
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /home/linuxbrew/.linuxbrew/etc/[email protected]/certs

and run
  /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/c_rehash
==> Summary
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/[email protected]/1.1.1h: 8,308 files, 23.4MB
==> Installing aws/tap/aws-sam-cli dependency: ncurses
==> Pouring ncurses-6.2.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/ncurses/6.2: 3,901 files, 9.5MB
==> Installing aws/tap/aws-sam-cli dependency: readline
==> Pouring readline-8.0.4.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/readline/8.0.4: 53 files, 1.9MB
==> Installing aws/tap/aws-sam-cli dependency: sqlite
==> Pouring sqlite-3.33.0.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/sqlite/3.33.0: 12 files, 4.9MB
==> Installing aws/tap/aws-sam-cli dependency: xz
==> Pouring xz-5.2.5.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/xz/5.2.5: 128 files, 1.8MB
==> Installing aws/tap/aws-sam-cli dependency: bzip2
==> Pouring bzip2-1.0.8.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/bzip2/1.0.8: 30 files, 549.3KB
==> Installing aws/tap/aws-sam-cli dependency: libffi
==> Pouring libffi-3.3.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/libffi/3.3: 17 files, 552.7KB
==> Installing aws/tap/aws-sam-cli dependency: unzip
==> Pouring unzip-6.0_6.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/unzip/6.0_6: 17 files, 581.8KB
==> Installing aws/tap/aws-sam-cli dependency: [email protected]
==> Pouring [email protected]_1.x86_64_linux.bottle.tar.gz
==> /home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.8.6_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.8.6_1/bin --install-lib=/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages --sing
==> /home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.8.6_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.8.6_1/bin --install-lib=/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages --sing
==> /home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.8.6_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.8.6_1/bin --install-lib=/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages --sing
==> Caveats
Python has been installed as
  /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /home/linuxbrew/.linuxbrew/opt/[email protected]/libexec/bin

You can install Python packages with
  /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/pip3 install <package>
They will install into the site-package directory
  /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

[email protected] is keg-only, which means it was not symlinked into /home/linuxbrew/.linuxbrew,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/[email protected]/bin:$PATH"' >> ~/.profile

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/[email protected]/lib"
  export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/[email protected]/include"

==> Summary
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.8.6_1: 3,978 files, 73.5MB
==> Installing aws/tap/aws-sam-cli
==> Pouring aws-sam-cli-1.7.0.x86_64_linux.bottle.tar.gz
馃嵑  /home/linuxbrew/.linuxbrew/Cellar/aws-sam-cli/1.7.0: 4,092 files, 99MB
==> No outdated dependents to upgrade!
==> Checking for dependents of upgraded formulae...
==> Reinstalling 1 broken dependent from source:
aws/tap/aws-sam-cli
==> Caveats
==> [email protected]
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /home/linuxbrew/.linuxbrew/etc/[email protected]/certs

and run
  /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/c_rehash
==> [email protected]
Python has been installed as
  /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /home/linuxbrew/.linuxbrew/opt/[email protected]/libexec/bin

You can install Python packages with
  /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/pip3 install <package>
They will install into the site-package directory
  /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

[email protected] is keg-only, which means it was not symlinked into /home/linuxbrew/.linuxbrew,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/[email protected]/bin:$PATH"' >> ~/.profile

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/[email protected]/lib"
  export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/[email protected]/include"

ubuntu@ip-172-31-45-176:~$ sam

Command 'sam' not found, but there are 18 similar ones.

Running brew install aws-sam-cli twice "fixes" the issue as a work-around.
This is the same issue as here and here

Further investigation is needed. Meanwhile, a workaround is to run brew install aws-sam-cli twice

You need to symlink it: brew link aws-sam-cli

I had 1.0.0 installed and working fine for months, but after upgrading to the latest (1.10.0) (brew upgrade aws-sam-cli), I got this command not found error. As @hawflau mentioned, running brew install aws-sam-cli after this fixed it for me.

Install, uninstall, then install again works for me (Ubuntu 20):

brew install aws-sam-cli
brew uninstall aws-sam-cli
brew install aws-sam-cli

Issue persist with Homebrew 2.7.1 and brew install twice fixes the issue. During first install getting following logs.

==> Installing aws/tap/aws-sam-cli
==> Pouring aws-sam-cli-1.15.0.x86_64_linux.bottle.tar.gz
馃嵑 /home/ec2-user/.linuxbrew/Cellar/aws-sam-cli/1.15.0: 3,951 files, 87.9MB
==> No outdated dependents to upgrade!
==> Checking for dependents of upgraded formulae...
==> Reinstalling 1 broken dependent from source:
aws/tap/aws-sam-cli
==> Caveats
==> [email protected]

However, the path /home/ec2-user/.linuxbrew/Cellar/aws-sam-cli/1.15.0 did not exist. The actual path getting created was /home/ec2-user/.linuxbrew/Cellar/aws-sam-cli/1.15.0.reinstall

After second run of brew install, /home/ec2-user/.linuxbrew/Cellar/aws-sam-cli/1.15.0 gets created and everything works as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

walkerlangley picture walkerlangley  路  41Comments

chrisfosterelli picture chrisfosterelli  路  31Comments

ericallam picture ericallam  路  24Comments

charsleysa picture charsleysa  路  33Comments

sanathkr picture sanathkr  路  37Comments