linera-io/linera-protocol · error
GITHUB_BASE_BRANCH is not set! This must be run from within…
Error message
GITHUB_BASE_BRANCH is not set! This must be run from within CI
What it means
In CI mode, from_env reads GITHUB_BASE_BRANCH — the target branch of the pull request (usually main) — and fails when it is unset. The summary compares PR results against this base, so an unknown base branch makes the run ambiguous and the constructor refuses to continue.
Solutions
- Export the base branch in the workflow: GITHUB_BASE_BRANCH: ${{ github.base_ref }}
- Or set it manually with the other three GITHUB_PR_*/BASE variables when running outside Actions
- Grep the workflow env block for typos — the other three sibling variables fail with their own messages, so fix all that appear
Example fix
# before
env:
GITHUB_BASE: ${{ github.base_ref }}
# after
env:
GITHUB_BASE_BRANCH: ${{ github.base_ref }} Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
: "${GITHUB_BASE_BRANCH:?GITHUB_BASE_BRANCH is required (PR target branch)}" Try / catch
if let Err(e) = Github::new(false, None) {
if e.to_string().contains("GITHUB_BASE_BRANCH") {
eprintln!("export GITHUB_BASE_BRANCH=${{ github.base_ref }} in the workflow env");
}
return Err(e.into());
} Prevention
- Map github.base_ref to GITHUB_BASE_BRANCH in the workflow env block
- Keep the full set of required GITHUB_* variables in one documented template
- Validate env completeness at job start so failures happen before any GitHub API calls
When it happens
Trigger: Running the tool in CI mode without GITHUB_BASE_BRANCH exported; workflows that map github.base_ref to a differently-named variable; local emulation missing one of the four required variables.
Common situations: Incomplete hand-maintained workflow env blocks; running the summary step in a reusable workflow that did not forward the variables; CI environments that strip GITHUB_-prefixed vars for security.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- GITHUB_PR_BRANCH is not set! This must be run from within CI
- GITHUB_PR_COMMIT_HASH is not set! This must be run from…
- GITHUB_PR_NUMBER is not set! This must be run from within CI
- GITHUB_REPOSITORY is not set! This must be run from within…
- Failed to get current branch name
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/70d31864c106ebda.
Report an issue: GitHub.
Appendix: source
Thrown at linera-summary/src/github.rs:130
(
commit_hash,
branch_name,
base,
pr_number.ok_or_else(|| anyhow!("pr_number is None"))?,
)
} else {
let pr_string = env_pr_number.map_err(|_| {
anyhow!("GITHUB_PR_NUMBER is not set! This must be run from within CI")
})?;
(
env_pr_commit_hash.map_err(|_| {
anyhow!("GITHUB_PR_COMMIT_HASH is not set! This must be run from within CI")
})?,
env_pr_branch.map_err(|_| {
anyhow!("GITHUB_PR_BRANCH is not set! This must be run from within CI")
})?,
env_base_branch.map_err(|_| {
anyhow!("GITHUB_BASE_BRANCH is not set! This must be run from within CI")
})?,
pr_string
.parse()
.map_err(|_| anyhow!("GITHUB_PR_NUMBER is not a valid number: {pr_string}"))?,
)
};
Ok(Self {
repository: GithubRepository::from_env(is_local)?,
pr_commit_hash,
pr_branch,
base_branch,
pr_number,
})
}
}
/// A GitHub client bound to a PR context, used to query workflow runs/jobs and post comments.View on GitHub (pinned to 6c226ddcb3)