fix: always run uv sync to recover from partial installs
Problem: setup_python_env() skips uv sync when .venv/ exists. If a previous sync was interrupted (e.g. network timeout), the directory exists but is broken, and every subsequent session silently uses a corrupt environment. Solution: remove the isdirectory guard and always run uv sync. It is idempotent and near-instant when dependencies are already installed, so the only cost is one subprocess call per session.
This commit is contained in:
parent
06f72bbe2b
commit
976838d981
1 changed files with 10 additions and 15 deletions
|
|
@ -175,22 +175,17 @@ function M.setup_python_env()
|
||||||
|
|
||||||
if vim.fn.executable('uv') == 1 then
|
if vim.fn.executable('uv') == 1 then
|
||||||
local plugin_path = M.get_plugin_path()
|
local plugin_path = M.get_plugin_path()
|
||||||
local venv_dir = plugin_path .. '/.venv'
|
|
||||||
|
|
||||||
if vim.fn.isdirectory(venv_dir) == 0 then
|
local env = vim.fn.environ()
|
||||||
logger.log('Setting up Python environment for scrapers...')
|
env.VIRTUAL_ENV = ''
|
||||||
local env = vim.fn.environ()
|
env.PYTHONPATH = ''
|
||||||
env.VIRTUAL_ENV = ''
|
env.CONDA_PREFIX = ''
|
||||||
env.PYTHONPATH = ''
|
local result = vim
|
||||||
env.CONDA_PREFIX = ''
|
.system({ 'uv', 'sync' }, { cwd = plugin_path, text = true, env = env })
|
||||||
local result = vim
|
:wait()
|
||||||
.system({ 'uv', 'sync' }, { cwd = plugin_path, text = true, env = env })
|
if result.code ~= 0 then
|
||||||
:wait()
|
logger.log('Failed to setup Python environment: ' .. result.stderr, vim.log.levels.ERROR)
|
||||||
if result.code ~= 0 then
|
return false
|
||||||
logger.log('Failed to setup Python environment: ' .. result.stderr, vim.log.levels.ERROR)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
logger.log('Python environment setup complete.')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
python_env_setup = true
|
python_env_setup = true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue