{"record":{"id":"4f6379c7824daa01","repo":"ipfs/kubo","slug":"could-not-get-repo-version-w","errorCode":null,"errorMessage":"could not get repo version: %w","messagePattern":"could not get repo version: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/fsrepo/migrations/migrations.go","lineNumber":39,"sourceCode":"\t// Migrations subdirectory in distribution. Empty for root (no subdir).\n\tdistMigsRoot = \"\"\n\tdistFSRM     = \"fs-repo-migrations\"\n)\n\n// RunMigration finds, downloads, and runs the individual migrations needed to\n// migrate the repo from its current version to the target version.\n//\n// Deprecated: This function downloads migration binaries from the internet and will be removed\n// in a future version. Use RunHybridMigrations for modern migrations with embedded support,\n// or RunEmbeddedMigrations for repo versions ≥16.\nfunc RunMigration(ctx context.Context, fetcher Fetcher, targetVer int, ipfsDir string, allowDowngrade bool) error {\n\tipfsDir, err := CheckIpfsDir(ipfsDir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfromVer, err := RepoVersion(ipfsDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not get repo version: %w\", err)\n\t}\n\tif fromVer == targetVer {\n\t\t// repo already at target version number\n\t\treturn nil\n\t}\n\tif fromVer > targetVer && !allowDowngrade {\n\t\treturn fmt.Errorf(\"downgrade not allowed from %d to %d\", fromVer, targetVer)\n\t}\n\n\tlogger := log.New(os.Stdout, \"\", 0)\n\n\tlogger.Print(\"Looking for suitable migration binaries.\")\n\n\tmigrations, binPaths, err := findMigrations(ctx, fromVer, targetVer)\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/repo/fsrepo/migrations/migrations.go#L21-L57","documentation":"RunMigration needs the current fs-repo version (read from the version file in the IPFS directory) to decide whether and how to migrate. This error wraps any failure from RepoVersion, typically because the directory does not exist, is not a valid IPFS repo, or the version file is missing/unreadable.","triggerScenarios":"Calling RunMigration (directly or via RunHybridMigrations) with an ipfsDir that does not contain a version file, has wrong permissions, or whose version number cannot be parsed.","commonSituations":"Pointing IPFS_PATH at an empty or wrong directory; running migrations before ipfs init; a corrupted repo after a failed previous migration or disk issue.","solutions":["Verify ipfsDir points to an initialized IPFS repo containing a readable version file.","Check file permissions on the repo directory and the version file.","If the repo is corrupted, restore from backup or re-init and re-import your data.","Run `ipfs repo version` to confirm the version file is readable before migrating."],"exampleFix":"// before\ncmd.RunMigration(ctx, cfg, \"\", from, to, false) // ipfsDir empty/invalid\n// after\nos.Setenv(\"IPFS_PATH\", \"/home/user/.ipfs\") // ensure valid repo dir first\ncmd.RunMigration(ctx, cfg, \"\", from, to, false)","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(ipfsDir, \"version\")); err != nil {\n    return fmt.Errorf(\"not an initialized IPFS repo at %s\", ipfsDir)\n}","typeGuard":null,"tryCatchPattern":"if err := RunMigration(ctx, cfg, ipfsDir, from, to, false); err != nil {\n    if strings.Contains(err.Error(), \"could not get repo version\") {\n        // check repo dir / run ipfs init\n    }\n}","preventionTips":["Run `ipfs repo version` before invoking migrations","Ensure IPFS_PATH is set and points at an initialized repo","Back up the repo before migrating"],"tags":["migrations","repo-version","go"],"backgroundTag":"missing-repo-version-file","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}