Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoload not picking up files if ~/.local/share/nvim/site directory not present at startup #28128

Open
clebs opened this issue Mar 31, 2024 · 4 comments
Labels
bug issues reporting wrong behavior has:workaround issue is not fixed but can be circumvented until then runtime funtime startup Nvim startup sequence (`:h startup`)
Milestone

Comments

@clebs
Copy link

clebs commented Mar 31, 2024

Problem

I use plug-vim on neovim and have the plugin recommends the following snippet on the config to automatically install Plug on the first startup: junegunn/vim-plug#1270 (comment)

After reporting, the plugin author found the cause of the issue: junegunn/vim-plug#1270 (comment)

I suggested a workaround by manually sourcing Plug after installing it (junegunn/vim-plug#1270) but maybe this is an actual bug in neovim.

Steps to reproduce

With a fresh install of neovim:

  • Add the snippet to automatically install Plug to the init.lua file
  • Start neovim

Expected behavior

On first startup, Plug should be installed and the :PlugInstall command should install all plugins.

Instead the :PlugInstall command is not found.

Neovim version (nvim -v)

v0.9.5

Vim (not Nvim) behaves the same?

no

Operating system/version

macOS 14.4

Terminal name/version

tmux 3.4

$TERM environment variable

screen-256color

Installation

Homebrew

@clebs clebs added the bug issues reporting wrong behavior label Mar 31, 2024
@zeertzjq zeertzjq added the startup Nvim startup sequence (`:h startup`) label Mar 31, 2024
@zeertzjq
Copy link
Member

Cannot reproduce. But I think adding a :let &runtimepath = &runtimepath after the mkdir() (or the :!curl --create-dirs) to invalidate the cache will fix the problem.

@mamekoro
Copy link

mamekoro commented Apr 1, 2024

I can reproduce with Neovim 0.9.5 on Ubuntu 22.04. Please see junegunn/vim-plug#1270 (comment) for more details.

This error will not occur if Neovim's data directory already exists, so to reproduce it, make sure that the ~/.local/share/nvim/site directory does not exist.

This problem is often encountered when installing Neovim in a Docker image. This is because when the Docker image is built, the Neovim data directory does not exist in its sandbox.

@zeertzjq
Copy link
Member

zeertzjq commented Apr 1, 2024

I still cannot reproduce this with any of the init.lua or init.vim I can find from that issue. But does let &runtimepath = &runtimepath work?

@zeertzjq
Copy link
Member

zeertzjq commented Apr 1, 2024

Oh, I can reproduce this if another autoload function is called before:

vim.fn['msgpack#is_int'](0)

local data_dir = vim.fn.stdpath('data')
if vim.fn.empty(vim.fn.glob(data_dir .. '/site/autoload/plug.vim')) == 1 then
	vim.cmd('silent !curl -fLo ' ..
		data_dir ..
		'/site/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
	vim.cmd('autocmd VimEnter * PlugInstall --sync | source $MYVIMRC')
end

local vim = vim
local Plug = vim.fn['plug#']

vim.fn['plug#begin']()
Plug('junegunn/vim-easy-align')
vim.fn['plug#end']()

And let &runtimepath = &runtimepath does work:

vim.fn['msgpack#is_int'](0)

local data_dir = vim.fn.stdpath('data')
if vim.fn.empty(vim.fn.glob(data_dir .. '/site/autoload/plug.vim')) == 1 then
	vim.cmd('silent !curl -fLo ' ..
		data_dir ..
		'/site/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
	vim.o.runtimepath = vim.o.runtimepath
	vim.cmd('autocmd VimEnter * PlugInstall --sync | source $MYVIMRC')
end

local vim = vim
local Plug = vim.fn['plug#']

vim.fn['plug#begin']()
Plug('junegunn/vim-easy-align')
vim.fn['plug#end']()

@zeertzjq zeertzjq added the has:workaround issue is not fixed but can be circumvented until then label Apr 1, 2024
@justinmk justinmk added the runtime funtime label Apr 7, 2024
@justinmk justinmk added this to the backlog milestone Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior has:workaround issue is not fixed but can be circumvented until then runtime funtime startup Nvim startup sequence (`:h startup`)
Projects
None yet
Development

No branches or pull requests

4 participants