Skip to content

Latest commit

 

History

History
124 lines (80 loc) · 5.44 KB

sam-cli-install-linux-alt.md

File metadata and controls

124 lines (80 loc) · 5.44 KB

Installing the AWS SAM CLI on Linux using Homebrew

To install the AWS SAM CLI on Linux, you can use the Homebrew package manager. For more information about Homebrew, see Homebrew on Linux on the Homebrew Documentation website.

Note
Installing Homebrew changes your environment's default Python version to the one that Homebrew installs.

To install Homebrew, you must first install Git. Git is available on many different operating systems, including most modern Linux distributions. For instructions about installing Git on your particular operating system, see Installing Git on the Git website.

Install Homebrew

After successfully installing Git, to install Homebrew, run the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Next, add Homebrew to your PATH by running the following commands. These commands work on all major flavors of Linux by adding either ~/.profile on Debian and Ubuntu, or ~/.bash_profile on CentOS, Fedora, and Red Hat.

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

Verify that Homebrew is installed.

brew --version

On successful installation of Homebrew, you should see output like the following:

 
 Homebrew 2.1.6 
 Homebrew/homebrew-core (git revision ef21; last commit 2019-06-19)

Install the AWS SAM CLI using Homebrew

To install the AWS SAM CLI using Homebrew, run the following commands:

brew tap aws/tap
brew install aws-sam-cli

Verify the installation.

sam --version

On successful installation of the AWS SAM CLI, you should see output like the following:

 
 SAM CLI, version 1.15.0

Upgrading the AWS SAM CLI using Homebrew

To upgrade the AWS SAM CLI using Homebrew, replace install with upgrade as follows:

brew upgrade aws-sam-cli

Nightly build using Homebrew

A nightly build of the AWS SAM CLI is available for you to install. Once installed, you can use the nightly build using the sam-nightly command. You can install and use both the production and nightly build versions of the AWS SAM CLI at the same time.

The nightly build contains a pre-release version of AWS SAM CLI code that may be less stable than the production version. Note that the nightly build does not contain pre-release version of the build image, so building a serverless application with the --use-container option uses the latest production version of the build image.

To install the nightly build version of the AWS SAM CLI, run the following commands:

brew tap aws/tap
brew install aws-sam-cli-nightly

To verify you have installed the nightly build version, run the sam-nightly --version command. The output of this command is in the form 1.X.Y.dev<YYYYMMDDHHmm>, for example:

SAM CLI, version 1.20.0.dev202103151200

Troubleshooting

Installing Homebrew message: "Enter your password to install to /home/linuxbrew/.linuxbrew"

During the Install Homebrew step, by default you're prompted to provide a password. However, you might not want to set up a password for the current user, for example, when you're setting up a non-interactive environment like CI/CD systems.

If you don't want to set up a password for the current user, you can install Homebrew in non-interactive mode by setting the environment variable CI=1. For example:

CI=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Installing AWS SAM CLI error: "The following formulae cannot be installed from bottles and must be built from source. pkg-config, gdbm, [email protected], ncurses, xz and [email protected]"

If you see this error while installing the AWS SAM CLI, you don't have the gcc module installed. Install the gcc module for your Linux distribution.

# for Amazon Linux, Amazon Linux 2, CentOS and Red Hat:
sudo yum install gcc
# for Debian and Ubuntu:
sudo apt-get update
sudo apt-get install gcc

After installing the gcc module, run the commands in the Install the AWS SAM CLI using Homebrew section again.

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.

For example, if you used the instructions in this topic to both install Homebrew and use Homebrew to install the AWS SAM CLI, then the AWS SAM CLI executable is installed to the following location:

 /home/linuxbrew/.linuxbrew/bin/sam