wasmerio/wasmer · error · anyhow::Error
Cannot create app from template in offline mode
Error message
Cannot create app from template in offline mode
What it means
create_from_template requires a WasmerClient because templates are fetched from the registry. When the client is None (offline mode / not connected), it bails with 'Cannot create app from template in offline mode'. The library throws it since remote template download is impossible without a connection.
Source
Thrown at lib/cli/src/commands/app/create.rs:653
let mut path_root_dir = PathBuf::from(root_dir);
if path_root_dir.is_absolute() {
path_root_dir = path_root_dir.strip_prefix("/")?.to_path_buf();
}
return Ok((url, Some(path_root_dir)));
}
Ok((url, None))
}
async fn create_from_template(
&self,
client: Option<&WasmerClient>,
owner: &str,
app_name: &str,
) -> anyhow::Result<bool> {
let client = match client {
Some(client) => client,
None => anyhow::bail!("Cannot create app from template in offline mode"),
};
let (url, mut root_dir) = self.get_template_url(client).await?;
root_dir = root_dir.map(|v| v.clean());
let root_dir_str = if let Some(ref root_dir) = root_dir {
root_dir.display().to_string()
} else {
"./".to_string()
};
tracing::info!("Downloading template from url {url}, using root dir {root_dir_str}");
let output_path = self.get_output_dir(app_name).await?;
let pb = indicatif::ProgressBar::new_spinner();
pb.enable_steady_tick(std::time::Duration::from_millis(500));
pb.set_style(
indicatif::ProgressStyle::with_template("{spinner:.magenta} {msg}")
.unwrap()View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Remove the --offline flag and ensure network access to the registry so a client can be created.
- Log in / fix registry configuration (WASMER_REGISTRY, tokens) so a WasmerClient is available.
- Pre-scaffold locally (e.g. --use-local-manifest or a checked-in template) instead of fetching a template while offline.
Example fix
// before // wasmer app create --offline --template wasmer/hello-world // after // wasmer app create --template wasmer/hello-world
Defensive patterns
Strategy: validation
Validate before calling
if (args.offline && args.template) {
throw new Error('cannot fetch a registry template in offline mode');
} Type guard
fn can_fetch_templates(client: &Option<WasmerClient>) -> bool {
client.is_some()
} Try / catch
match result {
Err(e) if e.to_string().contains("offline mode") => {
eprintln!("retry with network access or use a local manifest");
// fall back to --use-local-manifest flow
}
other => other?,
} Prevention
- Never combine --offline with --template.
- Check network/registry connectivity and login before template-based creates.
- Keep a local template/manifest path for air-gapped environments.
When it happens
Trigger: Running `wasmer app create --template <slug>` while offline (--offline flag, no network, or no registry client could be constructed), so run_async passes client: None into create_from_template.
Common situations: Air-gapped/CI environments using --offline; network outage or blocked registry host; unauthenticated setups where client resolution failed.
Related errors
- Stopping as the directory is not empty
- The --use_local_manifest flag was passed, but path {} does n
- No template selected
- No app name specified: use --name <app_name>
- No owner specified: use --owner <owner>
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/495482a3061b0c76.
Report an issue: GitHub.