grepai-troubleshooting

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GrepAI Troubleshooting

GrepAI故障排除

This skill provides solutions for common GrepAI issues and diagnostic procedures.
此技能提供GrepAI常见问题的解决方案和诊断流程。

When to Use This Skill

何时使用此技能

  • GrepAI not working as expected
  • Search returning poor results
  • Index not updating
  • Connection or configuration errors
  • GrepAI未按预期工作
  • 搜索返回的结果质量差
  • 索引未更新
  • 连接或配置错误

Quick Diagnostics

快速诊断

Run these commands to understand your setup:
bash
undefined
运行以下命令了解你的设置:
bash
undefined

Check GrepAI version

Check GrepAI version

grepai version
grepai version

Check project status

Check project status

grepai status
grepai status

Check Ollama (if using)

Check Ollama (if using)

Check config

Check config

cat .grepai/config.yaml
undefined
cat .grepai/config.yaml
undefined

Common Issues

常见问题



Issue: "Index not found"

问题:"索引未找到"

Symptom:
Error: Index not found. Run 'grepai watch' first.
Cause: No index has been created for this project.
Solution:
bash
undefined
症状:
Error: Index not found. Run 'grepai watch' first.
原因: 此项目尚未创建索引。
解决方案:
bash
undefined

Initialize if needed

Initialize if needed

grepai init
grepai init

Create the index

Create the index

grepai watch

---
grepai watch

---

Issue: "Cannot connect to embedding provider"

问题:"无法连接到嵌入提供商"

Symptom:
Error: Cannot connect to Ollama at http://localhost:11434
Causes:
  1. Ollama not running
  2. Wrong endpoint configured
  3. Firewall blocking connection
Solutions:
  1. Start Ollama:
bash
ollama serve
  1. Check endpoint in config:
yaml
embedder:
  endpoint: http://localhost:11434  # Verify this
  1. Test connection:
bash
curl http://localhost:11434/api/tags

症状:
Error: Cannot connect to Ollama at http://localhost:11434
原因:
  1. Ollama未运行
  2. 配置的端点错误
  3. 防火墙阻止了连接
解决方案:
  1. 启动Ollama:
bash
ollama serve
  1. 检查配置中的端点:
yaml
embedder:
  endpoint: http://localhost:11434  # Verify this
  1. 测试连接:
bash
curl http://localhost:11434/api/tags

Issue: "Model not found"

问题:"模型未找到"

Symptom:
Error: Model 'nomic-embed-text' not found
Cause: The embedding model hasn't been downloaded.
Solution:
bash
undefined
症状:
Error: Model 'nomic-embed-text' not found
原因: 嵌入模型尚未下载。
解决方案:
bash
undefined

Download the model

Download the model

ollama pull nomic-embed-text
ollama pull nomic-embed-text

Verify

Verify

ollama list

---
ollama list

---

Issue: Search returns no results

问题:搜索无结果返回

Symptom: Searches return empty or very few results.
Causes:
  1. Index is empty
  2. Files are being ignored
  3. Query too specific
Solutions:
  1. Check index status:
bash
grepai status
症状: 搜索返回空结果或结果极少。
原因:
  1. 索引为空
  2. 文件被忽略
  3. 查询过于具体
解决方案:
  1. 检查索引状态:
bash
grepai status

Should show files > 0 and chunks > 0

Should show files > 0 and chunks > 0


2. Verify files are being indexed:
```bash

2. 验证文件是否被索引:
```bash

Check ignore patterns in config

Check ignore patterns in config

cat .grepai/config.yaml | grep -A 20 "ignore:"

3. Try broader query:
```bash
grepai search "function"  # Very broad test

cat .grepai/config.yaml | grep -A 20 "ignore:"

3. 尝试更宽泛的查询:
```bash
grepai search "function"  # Very broad test

Issue: Search returns irrelevant results

问题:搜索返回不相关结果

Symptom: Results don't match what you're looking for.
Causes:
  1. Query too vague
  2. Boosting not configured
  3. Wrong content indexed
Solutions:
  1. Improve query (see
    grepai-search-tips
    skill):
bash
undefined
症状: 结果与你要查找的内容不匹配。
原因:
  1. 查询过于模糊
  2. 未配置权重调整
  3. 索引了错误的内容
解决方案:
  1. 优化查询(参考
    grepai-search-tips
    技能):
bash
undefined

Bad

Bad

grepai search "auth"
grepai search "auth"

Good

Good

grepai search "user authentication middleware"

2. Configure boosting to penalize tests:
```yaml
search:
  boost:
    enabled: true
    penalties:
      - pattern: /tests/
        factor: 0.5
  1. Check what's indexed:
bash
grepai status

grepai search "user authentication middleware"

2. 配置权重调整以降低测试文件的优先级:
```yaml
search:
  boost:
    enabled: true
    penalties:
      - pattern: /tests/
        factor: 0.5
  1. 检查索引内容:
bash
grepai status

Issue: Index is outdated

问题:索引已过时

Symptom: Recent file changes aren't appearing in search results.
Causes:
  1. Watch daemon not running
  2. Debounce delay
  3. File not in indexed extensions
Solutions:
  1. Check daemon status:
bash
grepai watch --status
  1. Restart daemon:
bash
grepai watch --stop
grepai watch --background
  1. Force re-index:
bash
rm .grepai/index.gob
grepai watch

症状: 最近的文件更改未出现在搜索结果中。
原因:
  1. 监听守护进程未运行
  2. 防抖延迟
  3. 文件不在索引支持的扩展名范围内
解决方案:
  1. 检查守护进程状态:
bash
grepai watch --status
  1. 重启守护进程:
bash
grepai watch --stop
grepai watch --background
  1. 强制重新索引:
bash
rm .grepai/index.gob
grepai watch

Issue: "Config not found"

问题:"配置未找到"

Symptom:
Error: Config file not found at .grepai/config.yaml
Cause: GrepAI not initialized in this directory.
Solution:
bash
grepai init

症状:
Error: Config file not found at .grepai/config.yaml
原因: 此目录中未初始化GrepAI。
解决方案:
bash
grepai init

Issue: Slow indexing

问题:索引速度慢

Symptom: Initial indexing takes very long.
Causes:
  1. Large codebase
  2. Slow embedding provider
  3. Not enough ignore patterns
Solutions:
  1. Add ignore patterns:
yaml
ignore:
  - node_modules
  - vendor
  - dist
  - build
  - "*.min.js"
  1. Use faster model:
yaml
embedder:
  model: nomic-embed-text  # Smaller, faster
  1. Use OpenAI for speed (if privacy allows):
yaml
embedder:
  provider: openai
  model: text-embedding-3-small
  parallelism: 8

症状: 初始索引耗时极长。
原因:
  1. 代码库庞大
  2. 嵌入提供商速度慢
  3. 忽略规则不足
解决方案:
  1. 添加忽略规则:
yaml
ignore:
  - node_modules
  - vendor
  - dist
  - build
  - "*.min.js"
  1. 使用更快的模型:
yaml
embedder:
  model: nomic-embed-text  # Smaller, faster
  1. 若隐私允许,使用OpenAI以提升速度:
yaml
embedder:
  provider: openai
  model: text-embedding-3-small
  parallelism: 8

Issue: Slow searches

问题:搜索速度慢

Symptom: Search queries take several seconds.
Causes:
  1. Very large index
  2. GOB storage on large codebase
  3. Embedding provider slow
Solutions:
  1. Check index size:
bash
ls -lh .grepai/index.gob
  1. For large indices, use Qdrant:
yaml
store:
  backend: qdrant
  1. Limit results:
bash
grepai search "query" --limit 5

症状: 搜索查询耗时数秒。
原因:
  1. 索引规模极大
  2. 大型代码库使用GOB存储
  3. 嵌入提供商速度慢
解决方案:
  1. 检查索引大小:
bash
ls -lh .grepai/index.gob
  1. 对于大型索引,使用Qdrant:
yaml
store:
  backend: qdrant
  1. 限制结果数量:
bash
grepai search "query" --limit 5

Issue: Trace not finding symbols

问题:Trace无法找到符号

Symptom:
grepai trace callers
returns no results.
Causes:
  1. Function name spelled wrong
  2. Language not enabled for trace
  3. Symbols index out of date
Solutions:
  1. Check exact function name (case-sensitive)
  2. Enable language in config:
yaml
trace:
  enabled_languages:
    - .go
    - .js
    - .ts
  1. Re-build symbol index:
bash
rm .grepai/symbols.gob
grepai watch

症状:
grepai trace callers
无结果返回。
原因:
  1. 函数名称拼写错误
  2. Trace未启用对应语言
  3. 符号索引已过时
解决方案:
  1. 检查精确的函数名称(区分大小写)
  2. 在配置中启用对应语言:
yaml
trace:
  enabled_languages:
    - .go
    - .js
    - .ts
  1. 重新构建符号索引:
bash
rm .grepai/symbols.gob
grepai watch

Issue: MCP not working

问题:MCP无法工作

Symptom: AI assistant can't use GrepAI tools.
Causes:
  1. MCP config incorrect
  2. GrepAI not in PATH
  3. Working directory wrong
Solutions:
  1. Test MCP server manually:
bash
grepai mcp-serve
  1. Check GrepAI is in PATH:
bash
which grepai
  1. Verify MCP config:
bash
undefined
症状: AI助手无法使用GrepAI工具。
原因:
  1. MCP配置错误
  2. GrepAI不在PATH中
  3. 工作目录错误
解决方案:
  1. 手动测试MCP服务器:
bash
grepai mcp-serve
  1. 检查GrepAI是否在PATH中:
bash
which grepai
  1. 验证MCP配置:
bash
undefined

Claude Code

Claude Code

cat ~/.claude/mcp.json
cat ~/.claude/mcp.json

Cursor

Cursor

cat .cursor/mcp.json

---
cat .cursor/mcp.json

---

Issue: Out of memory

问题:内存不足

Symptom: GrepAI crashes or system becomes slow.
Causes:
  1. Large embedding model
  2. Very large index in GOB format
  3. Too many parallel requests
Solutions:
  1. Use smaller model:
yaml
embedder:
  model: nomic-embed-text  # Smaller
  1. Use PostgreSQL or Qdrant instead of GOB
  2. Reduce parallelism:
yaml
embedder:
  parallelism: 2

症状: GrepAI崩溃或系统运行缓慢。
原因:
  1. 嵌入模型过大
  2. GOB格式的索引规模极大
  3. 并行请求过多
解决方案:
  1. 使用更小的模型:
yaml
embedder:
  model: nomic-embed-text  # Smaller
  1. 使用PostgreSQL或Qdrant替代GOB
  2. 减少并行数:
yaml
embedder:
  parallelism: 2

Issue: API key errors (OpenAI)

问题:API密钥错误(OpenAI)

Symptom:
Error: 401 Unauthorized - Invalid API key
Solutions:
  1. Check environment variable:
bash
echo $OPENAI_API_KEY
  1. Ensure variable is exported:
bash
export OPENAI_API_KEY="sk-..."
  1. Check key format in config:
yaml
embedder:
  api_key: ${OPENAI_API_KEY}  # Uses env var

症状:
Error: 401 Unauthorized - Invalid API key
解决方案:
  1. 检查环境变量:
bash
echo $OPENAI_API_KEY
  1. 确保变量已导出:
bash
export OPENAI_API_KEY="sk-..."
  1. 检查配置中的密钥格式:
yaml
embedder:
  api_key: ${OPENAI_API_KEY}  # Uses env var

Diagnostic Commands

诊断命令

Full System Check

完整系统检查

bash
#!/bin/bash
echo "=== GrepAI Diagnostics ==="

echo -e "\n1. Version:"
grepai version

echo -e "\n2. Status:"
grepai status

echo -e "\n3. Config:"
cat .grepai/config.yaml 2>/dev/null || echo "No config found"

echo -e "\n4. Index files:"
ls -la .grepai/ 2>/dev/null || echo "No .grepai directory"

echo -e "\n5. Ollama (if using):"
curl -s http://localhost:11434/api/tags | head -5 || echo "Ollama not responding"

echo -e "\n6. Daemon:"
grepai watch --status 2>/dev/null || echo "Daemon not running"
bash
#!/bin/bash
echo "=== GrepAI Diagnostics ==="

echo -e "\
1. Version:"
grepai version

echo -e "\
2. Status:"
grepai status

echo -e "\
3. Config:"
cat .grepai/config.yaml 2>/dev/null || echo "No config found"

echo -e "\
4. Index files:"
ls -la .grepai/ 2>/dev/null || echo "No .grepai directory"

echo -e "\
5. Ollama (if using):"
curl -s http://localhost:11434/api/tags | head -5 || echo "Ollama not responding"

echo -e "\
6. Daemon:"
grepai watch --status 2>/dev/null || echo "Daemon not running"

Reset Everything

完全重置

If all else fails, complete reset:
bash
undefined
如果所有方法都无效,执行完全重置:
bash
undefined

Remove all GrepAI data

Remove all GrepAI data

rm -rf .grepai
rm -rf .grepai

Re-initialize

Re-initialize

grepai init
grepai init

Start fresh index

Start fresh index

grepai watch
undefined
grepai watch
undefined

Getting Help

获取帮助

If issues persist:
  1. Check GrepAI documentation: https://yoanbernabeu.github.io/grepai/
  2. Search issues: https://github.com/yoanbernabeu/grepai/issues
  3. Create new issue with:
    • GrepAI version (
      grepai version
      )
    • OS and architecture
    • Config file (remove secrets)
    • Error message
    • Steps to reproduce
如果问题仍然存在:
  1. 查看GrepAI文档:https://yoanbernabeu.github.io/grepai/
  2. 搜索已有问题:https://github.com/yoanbernabeu/grepai/issues
  3. 创建新问题,包含以下信息:
    • GrepAI版本(
      grepai version
    • 操作系统和架构
    • 配置文件(移除敏感信息)
    • 错误信息
    • 复现步骤

Output Format

输出格式

Diagnostic summary:
🔍 GrepAI Diagnostics

Version: 0.24.0
Project: /path/to/project

✅ Config: Found (.grepai/config.yaml)
✅ Index: 245 files, 1,234 chunks
✅ Embedder: Ollama (connected)
✅ Daemon: Running (PID 12345)
❌ Issue: [Description if any]

Recommended actions:
1. [Action item]
2. [Action item]
诊断摘要:
🔍 GrepAI Diagnostics

Version: 0.24.0
Project: /path/to/project

✅ Config: Found (.grepai/config.yaml)
✅ Index: 245 files, 1,234 chunks
✅ Embedder: Ollama (connected)
✅ Daemon: Running (PID 12345)
❌ Issue: [Description if any]

Recommended actions:
1. [Action item]
2. [Action item]
",