Install, authorize, or uninstall the Slack CLI

In order to develop on the next-generation platform, your workspace must be on a paid plan.

The Slack CLI is a set of tools critical to building next-generation Slack apps. This is your one-stop shop for those tools.

✨ If you've not used the Slack CLI before, we recommend following our quickstart guide instead. We'll still get your wagon loaded up before you depart for the trail, but we'll also give you some additional guidance.

‡️ If you need to authorize the Slack CLI for use with continuous integrations and continuous deployments (CI/CD), jump down.

Installing the Slack CLI

The minimum required CLI version for Enterprise Grid as of September 19th, 2023 is v2.9.0. If you attempt to log in with an older version, you'll receive a cli_update_required error from the Slack API. Run slack upgrade to get the latest version.

Run the automated installer from your terminal window:

curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash

This will install the Slack CLI and all required dependencies, including Deno, the runtime environment for the next-generation platform. If you have VSCode installed, the VSCode Deno extension will be installed.

Optional: Use an alias for the Slack CLI binary

The installation script will detect existing binaries named slack and bail if it finds one; it will not overwrite your existing slack binary.

If you want to install the Slack CLI as anything other than slack, you can do so by passing the -s argument to the installer script:

curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s <your-preferred-alias>

The alias you use should come after any flags used in the installation script. For example, if you use both flags noted in the Quickstart to pass a version and skip the Deno installation, your install script might look like this:

curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -v 2.2.0 -d <your-preferred-alias>

Optional: customize installation using flags

There are two optional flags available to customize the installation.

  1. Specify a version you'd like to install using the version flag, -v. The absence of this flag will ensure the latest CLI version is installed.
curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -v 2.1.0
  1. Skip the Deno installation by using the -d flag, like this:
curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -d

Troubleshooting

Errors

Failed to create a symbolic link! The installer doesn't have write access to /usr/local/bin. Please check permission and try again...

Sudo actions within the scripts were removed so as not to create any security concerns. The $HOME env var is updated to /root β€” however, the installer is using $HOME for both Deno and the SDK install, which causes the whole install to be placed under /root, making both Deno and the SDK unusuable for users without root permissions.

For users who do not have root permissions, run the sudo actions manually as follows:
sudo mkdir -p -m 775 /usr/local/bin,then sudo ln -sf "$slack_cli_bin_path" "/usr/local/bin/$SLACK_CLI_NAME" where $slack_cli_bin_path is typically $HOME/.slack/bin/slack and $SLACK_CLI_NAME is typically the alias (by default it’s slack).

For users who have root permissions, you can run the installation script as sudo curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh \| bash. In this case, the script is executed as root.

Run the automated installer from Windows PowerShell:

irm https://downloads.slack-edge.com/slack-cli/install-windows.ps1 | iex

PowerShell is required for installing the Slack CLI on Windows machines; an alternative shell will not work.

This will install the Slack CLI and all required dependencies, including Deno, the runtime environment for the next-generation platform. If you have VSCode installed, the VSCode Deno extension will be installed.

Optional: customize installation using flags

There are several flags available to customize the installation. Since flags cannot be passed to remote scripts, you must first download the installation script to a local file:

irm https://downloads.slack-edge.com/slack-cli/install-windows.ps1 -outfile 'install-windows.ps1'

The available flags are:

Flag What it does Example
-Alias Installs the Slack CLI as the provided alias -Alias slackcli will create a binary named slackcli.exe and add it to your path
-Version Installs a specific version of the Slack CLI -Version 2.1.0 installs version 2.1.0 of the Slack CLI
-SkipGit If true, will not attempt to install Git when Git is not present -SkipGit $true
-SkipDeno If true, will not attempt to install Deno when Deno is not present -SkipDeno $true

You can also see all available flags by passing -? to the installation script:

.\install-windows.ps1 -?

Here's an example invocation using every flag:

.\install-windows.ps1 -Version 2.1.0 -Alias slackcli -SkipGit $true -SkipDeno $true

Troubleshooting

Errors

Not working? You may need to update your session's Language Mode.

For the installer to work correctly, your PowerShell session's language mode will need to be set to FullLanguage.

To check your session's language mode, run the following in your PowerShell window: ps $ExecutionContext.SessionState.LanguageMode. To run the installer, your session's language mode will need to be FullLanguage. If it's not, you can set your session's language mode to FullLanguage with the following command: ps $ExecutionContext.SessionState.LanguageMode = "FullLanguage"

1. Download and install Deno. Refer to Install Deno for more details.

2. Verify that Deno is installed and in your path:

$ deno --version
deno 1.31.1* (release, x86_64-apple-darwin)
v8 10.*
typescript 4.*

The minimum version of Deno runtime required for developing on the next-generation platform is currently at version 1.37.0.

3. Download and install Git, a dependency of the slack CLI.

4. Download the slack CLI installer for your environment.

The slack CLI is currently at version 2.18.0. See the changelog for details.

Β  Download for macOS (.tar.gz)

Β  Download for Linux (.tar.gz)

Β  Download for Windows (.zip)

5. Add the slack CLI to your path.

Existing slack binary in path?

If you have another CLI tool in your path called slack, we recommend renaming our slack binary to a different name before adding it to your path.

  • Mac/Linux: Copy the Slack CLI into any folder that is already in your path (such as /usr/local/bin) or add a new folder to your path by listing the folder you installed the Slack CLI to in /etc/paths.

  • Windows: Copy the Slack CLI into any folder that is already in your path, or add a new folder to your path by listing the folder you installed the Slack CLI to in your Environment Variables. You may not have access to edit System variables, so you might need to add it to your account's User variables. You can open the Environment Variables dialog by pressing the Win+R keys to open the Run window, and entering the following command: rundll32.exe sysdm.cpl,EditEnvironmentVariables.

6. Verify that slack is installed and in your path:

$ slack version
Using slack v2.18.0

7. Verify that all dependencies have been installed:

$ slack doctor

8. Install the VSCode extension for Deno (recommended).


✨ For uninstallation instructions, refer to uninstalling the Slack CLI.

Authorizing the Slack CLI

With the Slack CLI installed, authorize the Slack CLI in your workspace with the following command:

slack login

In your terminal window, you should see an authorization ticket in the form of a slash command, and a prompt to enter a challenge code:

$ slack login

πŸ“‹ Run the following slash command in any Slack channel or DM
   This will open a modal with user permissions for you to approve
   Once approved, a challenge code will be generated in Slack

/slackauthticket ABC123defABC123defABC123defABC123defXYZ

? Enter challenge code

Copy the slash command and paste it into any Slack conversation in the workspace you will be developing in.

When you send the message containing the slash command, a modal will pop up, prompting you to grant certain permissions to the Slack CLI. Click the Confirm button in the modal to move to the next step.

A new modal with a challenge code will appear. Copy that challenge code, and paste it back into your terminal:

? Enter challenge code eXaMpLeCoDe

βœ… You've successfully authenticated! πŸŽ‰
   Authorization data was saved to ~/.slack/credentials.json

πŸ’‘ Get started by creating a new app with slack create my-app
   Explore the details of available commands with slack help

Verify that your CLI is set up by running slack auth list in your terminal window:

$ slack auth list

myworkspace (Team ID: T123ABC456)
User ID: U123ABC456
Last updated: 2023-01-01 12:00:00 -07:00
Authorization Level: Workspace

You should see an entry for the workspace you just authorized. If you don't, get a new authorization ticket with slack login to try again.

You're now ready to begin building next-generation Slack apps!

Version update notifications

Once a day, the Slack CLI checks for updates after running any command. When an update is available, a notification will be displayed with a link where you can find and download the new version.

Update notifications can be disabled using a command-line flag or an environment variable. When running any command, you can append the --skip-update or -s flag. Alternatively, you can set the SLACK_SKIP_UPDATE environment variable and assign it any value.

CI/CD authorization

Setting up a CI/CD pipeline requires authorization using a service token. Service tokens are long-lived, non-rotatable user tokens β€” they won't expire, so they can be used to perform any Slack CLI action without the need to refresh tokens.

To get a service token, you'll use the slack auth token command to get a slackauthticket, which you'll copy and paste into your workspace to exchange for the service token. The service token will not be saved to your credentials.json file; instead, it is presented in the terminal for you to copy and paste for use in your CI/CD pipeline. Once copied, you'll use the slack login --auth <your-service-token> command to authorize your Slack CLI. Detailed instructions are below.

The service token will not conflict with your regular authentication token; you can continue using your regular authentication token within the Slack CLI while using the service token for your CI/CD pipeline.

Best practices for service tokens

Since a service token obtained via the Slack CLI is tied to the developer who requested it, it is recommended β€” especially for those who are part of large enterprises β€” to create a "Slack service account" within your workspace for the purpose of obtaining service tokens.

This "Slack service account" will be identical to other user accounts, but service tokens can now be associated with this account rather than an individual organization member. This can reduce the security risk of an individual developer's token being compromised, as well as lessening the dependence on a single individual for service token access and management.

Obtaining a service token

Run the following command to get a slackauthticket:

slack auth token

Then, copy and paste the /slackauthticket <your-auth-ticket> slash command into the message composer anywhere within your Slack workspace.

Copy the given challenge code, and paste it into the Slack CLI prompt.

Securely store the given service token, as this authorization information will not be saved to your local credentials.json file.

Using a service token

Run the following command to authorize your Slack CLI with the service token:

slack --token <your-service-token>

The Slack CLI will attempt to verify the token and use it to log in.

The --token global flag allows you to pass the service token with any Slack CLI command; for example:

slack deploy --token <your-service-token>

Revoking a service token

Run the following command to revoke a service token:

slack auth revoke --token <your-service-token>

Deno Slack SDK

You can the Deno Slack SDK in tandem with the Slack CLI to access the API, additional documentation, and code libraries.

To use the Deno Slack SDK, you'll first need to download and install Deno. If you're using VSCode for development, make sure to also download the Deno extension for VSCode.

✨ To start creating an app, check out the create or remove an app page.

Uninstalling the Slack CLI

All good things come to an end! If you need to uninstall the Slack CLI, follow the instructions below.

✨ Just need to uninstall an app? Refer to uninstall an app from your workspace.

Run the following from your terminal window:

$ rm -rf ~/.slack  # Delete the download binary
$ rm /usr/local/bin/slack  # Delete the command alias (replacing `slack` with a command name)

Run the following commands in PowerShell:

The command binary is stored in $HOME\AppData\Local\slack-cli or $HOME\.slack-cli. This binary can be removed with the following command:

rd -r $HOME\AppData\Local\slack-cli

where $HOME is substituted for the full path, e.g. C:\Users\<your_username>.

PowerShell is required for uninstalling the Slack CLI from Windows machines; an alternative shell will not work.

Removing the command from the $env:path can be done with the following command:

$env:Path = ($env:Path -split ';' -ne Β "$HOME\AppData\Local\slack-cli\bin") -join ';'

Removing the command from the system path can be done with the following command:

[System.Environment]::SetEnvironmentVariable('Path', (([System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::User) -split ';' -ne '$HOME\AppData\Local\slack-cli\bin') -join ';'), [System.EnvironmentVariableTarget]::User)

Finally, general configurations can be removed with the following command:

rd -r $HOME\.slack

To check that uninstallation was successful, run the following commands and verify that you receive an error β€” in this case, that's a good thing!

slack version
echo $env:path

These instructions will uninstall the Slack CLI, but not its dependencies. Follow these instructions to uninstall Deno.

Until next time!


Have 2 minutes to provide some feedback?

We'd love to hear about your experience building modular Slack apps. Please complete our short survey so we can use your feedback to improve.