Installation
Prerequisites
- GitHub account with active Copilot subscription (Pro, Pro+, Business, or Enterprise)
- Node.js v22+ and npm v10+ (for npm method)
- macOS, Linux, or Windows
- Terminal access
Learning Objectives
- Install Copilot CLI using your preferred method
- Authenticate with your GitHub account
- Verify the installation is working
- Understand subscription requirements
Concepts
Subscription Requirements
Before installing, ensure you have one of:
- Copilot Pro - Individual subscription
- Copilot Pro+ - Enhanced individual subscription
- Copilot Business - Organization subscription
- Copilot Enterprise - Enterprise subscription
For organization members, your admin must enable the Copilot CLI policy.
Installation Methods
Copilot CLI supports multiple installation methods:
| Method | Command | Best For |
|---|---|---|
| Script | curl -fsSL https://gh.io/copilot-install | bash | Quick setup |
| npm | npm install -g @github/copilot | Node.js developers |
| Homebrew | brew install copilot-cli | macOS/Linux users |
| WinGet | winget install GitHub.Copilot | Windows users |
| Dev Container | Built-in | Codespaces users |
Updating Copilot CLI
💡 Already have Copilot CLI installed? To update to the latest version, simply run:
copilot update
Hands-On Exercises
Exercise 1a: Install via Script (Quick Method) - Recommended option
Goal: Use the automated installation script.
Steps:
-
Run the installation script:
curl -fsSL https://gh.io/copilot-install | bash -
Follow any prompts to add to your PATH.
-
Restart your terminal or source your profile:
source ~/.bashrc # or ~/.zshrc -
Verify:
copilot --version
Expected Outcome:
GitHub Copilot CLI 0.0.415
Exercise 1b: Install via npm option
Goal: Install Copilot CLI globally using npm.
Steps:
-
Verify Node.js and npm versions:
node --version # Should be v22.0.0 or higher
npm --version # Should be v10.0.0 or higher -
If Node.js needs updating, use nvm:
# Install or update nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Install Node.js v22
nvm install 22
nvm use 22 -
Install Copilot CLI globally:
npm install -g @github/copilot -
Verify installation:
copilot --version
Expected Outcome:
GitHub Copilot CLI 0.0.415
Exercise 1c: Install via Homebrew (macOS/Linux) option
Goal: Install using Homebrew package manager.
Steps:
-
Ensure Homebrew is installed:
brew --version -
Install Copilot CLI:
brew install copilot-cli -
Verify installation:
copilot --version
Expected Outcome:
@github/copilot version X.X.X
Exercise 2: Authenticate with GitHub
Goal: Connect Copilot CLI to your GitHub account.
Steps:
-
Start Copilot CLI:
copilot -
When prompted, press Enter to authenticate.
-
A browser window opens. Sign in to GitHub if needed.
-
Authorize the application when prompted.
-
Return to your terminal. You should see the Copilot prompt:
>
Expected Outcome:
Interactive session starts with > prompt ready for input.
Exercise 3: Verify Setup with First Prompt
Goal: Test that everything works with a simple query.
Steps:
-
In the interactive session, type:
What directory am I in? -
Copilot should use the shell tool and report your current directory.
-
When prompted to approve the tool, select:
- Yes - Allow this time only
- Or Yes, and approve for session - Allow for the entire session
-
Type
/helpto see available commands. -
Type
/exitor pressCtrl+Cto exit.
Expected Outcome: Copilot correctly identifies your working directory and shows available commands.
Exercise 1d: Windows Installation (WinGet)
Goal: Install Copilot CLI on Windows.
Steps:
-
Open PowerShell or Windows Terminal.
-
Install via WinGet:
winget install GitHub.Copilot -
Restart your terminal.
-
Verify installation:
copilot --version
Expected Outcome:
@github/copilot version X.X.X
Troubleshooting
Common Issues
| Problem | Solution |
|---|---|
command not found: copilot | Ensure npm global bin is in PATH: npm config get prefix |
| Node.js version too old | Use nvm to install v22+: nvm install 22 |
| Authentication fails | Check subscription status at github.com/settings/copilot |
| Permission denied (npm) | Don't use sudo; fix npm permissions instead |
| Organization policy error | Ask your admin to enable Copilot CLI policy |
| Auth fails in Docker/container | Use PAT auth: export GH_TOKEN="ghp_...". See Authentication in Containers below |
Fixing npm Permissions
If you get permission errors with npm:
# Create a directory for global packages
mkdir ~/.npm-global
# Configure npm to use it
npm config set prefix '~/.npm-global'
# Add to PATH (add to ~/.bashrc or ~/.zshrc)
export PATH=~/.npm-global/bin:$PATH
# Reload shell
source ~/.bashrc
Checking Subscription Status
- Go to github.com/settings/copilot
- Verify your subscription is active
- Check that CLI access is enabled
Authentication in Containers and CI/CD
-
Create a fine-grained PAT at github.com/settings/personal-access-tokens
-
Under "Permissions," add "Copilot Requests"
-
Export the token:
export GH_TOKEN="ghp_your_token_here"
# or
export GITHUB_TOKEN="ghp_your_token_here" -
Start Copilot CLI; it will authenticate automatically without a browser
Summary
- ✅ Copilot CLI requires Node.js v22+ for npm installation
- ✅ Multiple installation methods: npm, Homebrew, script, WinGet
- ✅ Authentication uses GitHub OAuth in your browser
- ✅ Organization members need admin-enabled CLI policy
- ✅ Dev Containers and Codespaces include Copilot CLI by default
Next Steps
→ Continue to Module 2: Operating Modes