linera-io/linera-protocol · error
GITHUB_REPOSITORY is not set! This must be run from within C
Error message
GITHUB_REPOSITORY is not set! This must be run from within CI
What it means
GithubRepository::from_env in linera-summary resolves the target repository. In CI mode (is_local = false) it reads GITHUB_REPOSITORY — normally injected by GitHub Actions — and hard-fails when it is unset, since without it the tool cannot know which repo to query.
Source
Thrown at linera-summary/src/github.rs:45
impl GithubRepository {
/// Returns the repository owner.
pub fn owner(&self) -> &str {
&self.owner
}
/// Returns the repository name.
pub fn name(&self) -> &str {
&self.name
}
fn from_env(is_local: bool) -> Result<Self> {
let env_repository = env::var("GITHUB_REPOSITORY");
let repository = if is_local {
env_repository.unwrap_or_else(|_| "linera-io/linera-protocol".to_string())
} else {
env_repository.map_err(|_| {
anyhow!("GITHUB_REPOSITORY is not set! This must be run from within CI")
})?
};
let parts = repository.split('/').collect::<Vec<_>>();
assert_eq!(parts.len(), 2);
let owner = parts[0].to_string();
let name = parts[1].to_string();
Ok(Self { owner, name })
}
}
/// The GitHub context for the PR being analyzed: repository, branches, commit and PR number.
pub struct GithubContext {
repository: GithubRepository,
pr_commit_hash: String,
pr_branch: String,
base_branch: String,
pr_number: u64,
}View on GitHub (pinned to 6c226ddcb3)
Solutions
- Run inside GitHub Actions, where GITHUB_REPOSITORY is set automatically (format 'owner/repo')
- Or export it manually: GITHUB_REPOSITORY=owner/repo <command>
- Or switch the tool to local mode, which falls back to linera-io/linera-protocol when the variable is missing
Example fix
# before GITHUB_PR_NUMBER=7 linera-summary ... # after GITHUB_REPOSITORY=linera-io/linera-protocol GITHUB_PR_NUMBER=7 linera-summary ...
Defensive patterns
Strategy: validation
Validate before calling
// Rust: verify CI env before constructing
for var in ["GITHUB_REPOSITORY"] {
if std::env::var(var).is_err() {
anyhow::bail!("{var} is required in CI mode; export it or run with local mode");
}
} Try / catch
if let Err(e) = Github::new(false, None) {
if e.to_string().contains("GITHUB_REPOSITORY") {
eprintln!("missing CI env; set GITHUB_REPOSITORY=owner/repo or use --local");
}
return Err(e.into());
} Prevention
- Gate CI-mode invocations on a quick env-var presence check
- In local testing, use the local mode flag instead of hand-faking CI variables
- Keep a checklist of required GITHUB_* variables next to workflow definitions
When it happens
Trigger: Running linera-summary in non-local mode outside a GitHub Actions runner: bare `cargo run`, docker, cron. Any environment lacking GITHUB_REPOSITORY aborts before any API call.
Common situations: Testing the summary tool locally while forgetting the local-mode flag; moving a workflow step to a self-hosted script; CI runners that scrub environment variables.
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_NUMBER is not set! This must be run from within CI
- GITHUB_PR_COMMIT_HASH is not set! This must be run from with
- GITHUB_PR_BRANCH is not set! This must be run from within CI
- GITHUB_BASE_BRANCH is not set! This must be run from within
- No base jobs found!
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/8b20c75b1291b970.
Report an issue: GitHub.