You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Neovim中Telescope历史路径创建失败问题求助

问题解决:Telescope在Windows下无法创建历史文件报错

问题现象

打开Telescope后执行任意操作均返回以下错误:

E5108: Error executing lua:
...sers/josqu/.vim/bundle/plenary.nvim/lua/plenary/path.lua:635: Could
not create file:
C:\Users\josqu\C:/Users/josqu/AppData/Local/nvim-data/telescope_history
stack traceback: [C]: in function 'error'
...sers/josqu/.vim/bundle/plenary.nvim/lua/plenary/path.lua:635: in
function 'touch'
.../bundle/telescope.nvim/lua/telescope/actions/history.lua:183: in
function 'init'
.../bundle/telescope.nvim/lua/telescope/actions/history.lua:81: in
function 'handler'
...im/bundle/telescope.nvim/lua/telescope/actions/state.lua:50: in
function 'get_current_history'
...squ/.vim/bundle/telescope.nvim/lua/telescope/pickers.lua:1443: in
function 'on_close_prompt'
...vim/bundle/telescope.nvim/lua/telescope/actions/init.lua:386: in
function 'run_replace_or_original'
.../.vim/bundle/telescope.nvim/lua/telescope/actions/mt.lua:65: in
function 'key_func'
...qu/.vim/bundle/telescope.nvim/lua/telescope/mappings.lua:257: in
function
<...qu/.vim/bundle/telescope.nvim/lua/telescope/mappings.lua:256>

执行路径检查命令:

:lua print(require("plenary.path"):new(vim.fn.expand(vim.fn.stdpath("data") .. "/telescope_history")):absolute())

返回无效拼接路径:

C:\Users\josqu\C:/Users/josqu/AppData/Local/nvim-data/telescope_history

执行存在性检查:

:lua print(require("plenary.path"):new(vim.fn.expand(vim.fn.stdpath("data") .. "/telescope_history")):exists())

返回false,且telescope checkhealth无异常。

问题原因

路径拼接逻辑错误,C:\Users\josqu与完整的C:/Users/josqu/AppData/Local/nvim-data/telescope_history被重复拼接,生成了不存在的无效路径,导致Telescope无法创建历史文件。

解决方案

1. 手动创建正确的历史文件

  • 打开文件管理器,导航到C:\Users\josqu\AppData\Local\nvim-data目录
  • 在该目录下创建空白文件,命名为telescope_history

2. 修正Telescope配置中的路径设置

检查你的Telescope配置,确保历史文件路径没有重复添加绝对路径前缀:

require('telescope').setup{
  defaults = {
    history = {
      path = vim.fn.stdpath('data') .. '/telescope_history',
      limit = 100,
    },
  }
}

vim.fn.stdpath('data')已经返回完整的绝对路径,无需额外添加用户目录前缀。

3. 临时禁用历史功能(紧急方案)

如果上述方法无效,可临时关闭历史功能避免报错:

require('telescope').setup{
  defaults = {
    history = {
      path = nil,
    },
  }
}

内容的提问来源于stack exchange,提问作者Esmail Alberto Ghassemi Shuaki

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 10:42:59