davila7/claude-code-templates · warning

Warning: Could not read settings file

Error message

Warning: Could not read settings file

What it means

PluginDashboard.readSettings() reads the Claude settings.json (~/.claude/settings.json) and warns when reading or JSON.parse throws — most commonly a syntax error in the file (trailing comma, unquoted key, truncated edit) or EACCES. It resets enabledPlugins and returns {} so the dashboard starts with defaults.

Source

Thrown at cli-tool/src/plugin-dashboard.js:72

        const settings = JSON.parse(content);

        // Extract enabled plugins from settings
        // Plugins are stored in settings.enabledPlugins as "plugin-name@marketplace-name": true
        this.enabledPlugins = new Set();
        if (settings.enabledPlugins && typeof settings.enabledPlugins === 'object') {
          for (const [key, value] of Object.entries(settings.enabledPlugins)) {
            if (value === true) {
              this.enabledPlugins.add(key);
            }
          }
        }

        return settings;
      }
      this.enabledPlugins = new Set();
      return {};
    } catch (error) {
      console.warn(chalk.yellow('Warning: Could not read settings file'), error.message);
      this.enabledPlugins = new Set();
      return {};
    }
  }

  async loadMarketplaces(settings) {
    const marketplaces = [];

    try {
      // Read known_marketplaces.json from plugins directory
      const knownMarketplacesFile = path.join(this.claudeDir, 'plugins', 'known_marketplaces.json');

      if (!(await fs.pathExists(knownMarketplacesFile))) {
        console.warn(chalk.yellow('Warning: known_marketplaces.json not found'));
        return [];
      }

      const content = await fs.readFile(knownMarketplacesFile, 'utf8');

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Validate and fix the JSON: `node -e "JSON.parse(require('fs').readFileSync(process.env.HOME+'/.claude/settings.json','utf8'))"` — the error message pinpoints the position.
  2. Restore from a backup or regenerate the file if it's truncated.
  3. Fix permissions: `chmod 600 ~/.claude/settings.json`.
  4. If parse position is reported, look for trailing commas, comments, or smart quotes pasted from a chat.

Example fix

// before
{ "enabledPlugins": {"foo": true,} }
// after
{ "enabledPlugins": {"foo": true} }
Defensive patterns

Strategy: validation

Validate before calling

const raw = fs.readFileSync(p, 'utf8');
const parsed = JSON.parse(raw); // throws early with a precise position message

Type guard

const isSettings = (v) => v && typeof v === 'object' && !Array.isArray(v);

Try / catch

catch (e) { if (e instanceof SyntaxError) console.warn('settings.json is invalid JSON at', e.message); return {}; }

Prevention

When it happens

Trigger: Calling readSettings() when settings.json contains invalid JSON (manual edit, merge conflict markers, partial write), or when the file/directory lacks read permission. ENOENT is typically handled earlier, so the surviving cases are parse and permission errors.

Common situations: Hand-editing settings.json and leaving a trailing comma, a crashed tool leaving a truncated file, dotfiles sync tools clobbering the file, or restrictive home-directory permissions.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/6809b2e1b778660c. Report an issue: GitHub.