ipfs/kubo · error
could not get current repo version: %w
Error message
could not get current repo version: %w
What it means
RunHybridMigrations first reads the current repository version from the version file in ipfsDir. If that read fails (RepoVersion error), the migration cannot proceed, and the underlying error is wrapped with this message.
Source
Thrown at repo/fsrepo/migrations/migrations.go:347
// 2. Uses embedded migrations for v16+ steps
// 3. Handles pure external, pure embedded, or mixed migration scenarios
//
// Legacy external migrations (repo versions <16) only support HTTPS downloads.
//
// Parameters:
// - ctx: Context for cancellation and timeouts
// - targetVer: Target repository version to migrate to
// - ipfsDir: Path to the IPFS repository directory
// - allowDowngrade: Whether to allow downgrade migrations
//
// Returns error if migration fails at any step.
func RunHybridMigrations(ctx context.Context, targetVer int, ipfsDir string, allowDowngrade bool) error {
const embeddedMigrationsMinVersion = 16
// Get current repo version
currentVer, err := RepoVersion(ipfsDir)
if err != nil {
return fmt.Errorf("could not get current repo version: %w", err)
}
var logger = log.New(os.Stdout, "", 0)
// Check if migration is needed
if currentVer == targetVer {
logger.Printf("Repository is already at version %d", targetVer)
return nil
}
// Validate downgrade request
if targetVer < currentVer && !allowDowngrade {
return fmt.Errorf("downgrade from version %d to %d requires allowDowngrade=true", currentVer, targetVer)
}
// Determine migration strategy based on version ranges
needsExternal := currentVer < embeddedMigrationsMinVersion
needsEmbedded := targetVer >= embeddedMigrationsMinVersionView on GitHub (pinned to 329838acdf)
Solutions
- Verify IPFS_PATH exists and contains a valid `version` file with an integer
- Run `ipfs repo version` to see if the repo itself is readable
- Fix permissions: ensure the user running the daemon owns IPFS_PATH and its files
- If the repo is uninitialized, run `ipfs init` instead of migrating; never hand-create the version file
Example fix
// before
err := migration.RunHybridMigrations(ctx, 17, "/wrong/path", false)
// after
dir := os.Getenv("IPFS_PATH") // e.g. ~/.ipfs
if _, err := os.Stat(filepath.Join(dir, "version")); err != nil {
log.Fatal("repo missing or uninitialized at ", dir)
}
err := migration.RunHybridMigrations(ctx, 17, dir, false) Defensive patterns
Strategy: validation
Validate before calling
verFile := filepath.Join(ipfsDir, "version")
data, err := os.ReadFile(verFile)
if err != nil { log.Fatalf("repo missing/unreadable: %v", err) }
if _, err := strconv.Atoi(strings.TrimSpace(string(data))); err != nil {
log.Fatalf("corrupt version file %s: %q", verFile, data)
} Try / catch
if err != nil && strings.Contains(err.Error(), "could not get current repo version") {
return fmt.Errorf("check IPFS_PATH (%s): repo may be missing, corrupt, or locked: %w", ipfsDir, err)
} Prevention
- Never hand-edit the repo `version` file
- Run `ipfs repo version` before migrations as a sanity check
- Ensure consistent user ownership of IPFS_PATH
- Confirm the daemon is stopped before migrating
When it happens
Trigger: Calling RunHybridMigrations (or starting the daemon with --migrate) when IPFS_PATH/version is missing, unreadable, corrupted, or contains a non-integer; or ipfsDir points to a non-existent/uninitialized repo.
Common situations: Repo directory deleted or moved while daemon is stopped; manual edits to the version file; permission problems after running the daemon as different users; running migration against the wrong path.
Related errors
- fs-repo requires migration
- abort failed: close: %w, remove: %v
- failed to get temp dir: %s
- could not get repo version: %w
- cannot get migrations from unknown fetcher type
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/e16c5885352879f1.
Report an issue: GitHub.