can1357/oh-my-pi · error · Error
Failed to load share script: ${message}
Error message
Failed to load share script: ${message} What it means
This is the wrapper error produced by loadCustomShare's catch block: any failure while dynamically importing the share script — syntax errors, missing dependencies, runtime errors at module top level, or the missing-default-export contract check — is rethrown as 'Failed to load share script: <original message>'. The original cause is embedded in the message.
Source
Thrown at packages/coding-agent/src/export/custom-share.ts:63
*/
export async function loadCustomShare(): Promise<LoadedCustomShare | null> {
const scriptPath = getCustomSharePath();
if (!scriptPath) {
return null;
}
try {
const module = await import(scriptPath);
const fn = module.default;
if (typeof fn !== "function") {
throw new Error("share script must export a default function");
}
return { path: scriptPath, fn };
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
throw new Error(`Failed to load share script: ${message}`);
}
}
View on GitHub (pinned to 9690622007)
Solutions
- Read the '<message>' suffix — it contains the real cause; fix that first.
- Run the script standalone (bun run ~/.omp/agent/share.ts) to reproduce the import error outside /share.
- Install any missing dependencies the script imports, or vendor them locally.
- Ensure the script exports a default function.
- Temporarily rename the script to fall back to default Gist sharing while debugging.
Example fix
// before
import { render } from "missing-pkg";
export default async () => render();
// after
bun add missing-pkg # or remove the import
export default async () => { /* ... */ }; Defensive patterns
Strategy: try-catch
Validate before calling
// dry-run the import the same way the loader does
try {
const mod = await import(scriptPath);
if (typeof mod.default !== "function") throw new Error("default export must be a function");
} catch (err) {
console.error(`Share script broken: ${(err as Error).message}`);
} Type guard
null
Try / catch
try {
const custom = await loadCustomShare();
} catch (err) {
logger.warn("Custom share script failed to load; using default Gist sharing", {
cause: (err as Error).message,
});
} Prevention
- Test the script with `bun run ~/.omp/agent/share.ts` after every edit.
- Avoid importing packages that aren't resolvable from the agent's runtime.
- Keep module top-level side effects minimal so import never throws.
- Read the inner message after 'Failed to load share script:' — it names the true cause.
When it happens
Trigger: Running /share with a share script present at ~/.omp/agent/share.* that fails to import: syntax error, unresolved import inside the script, thrown module-init error, or no function default export.
Common situations: Script imports a package that isn't installed in the agent's context; TS/JS typo causing a parse failure; script reads env/files at top level and throws; missing default export (error 1343 wrapped).
Related errors
- share script must export a default function
- No model configured
- Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL
- Cannot register custom API "${api}": built-in API names are
- Unable to read OMP_AUTH_BROKER_ACCOUNT_POOL_FILE at ${filePa
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/b2f8067f4b582d7c.
Report an issue: GitHub.