Closed daUnknownCoder closed 1 year ago
Same issue on Windows - seems to be a problem with how Lazy.nvim applies the update. Clean, then reinstall fixed the issue for me.
I'm getting something similar:
You have local changes in `$HOME/.local/share/nvim/lazy/markdown-preview.nvim`:
* app/index.js
* app/package.json
* app/yarn.lock
Please remove them to update.
You can also press `x` to remove the plugin and then `I` to install it again.
I think it has something to do with the yarn
version on your machine.
I tested using yarn v3.6.4
(latest stable) and v4.0.0-rc.53
(latest canary).
In both cases, running yarn install
modifies the following files:
index.js
package.json
yarn.lock
These files are tracked by the git repo, so that's probably what's blocking the update.
I did test with yarn v1.22.19
(the latest 1.x version), and it did not change any tracked files.
Workarounds
v1.22.19
of yarnLonger term - I have some ideas for the maintainers:
v1.x
of yarn for it to work properly.Thoughts?
Same issue here on macOS, super annoying to see the error message every time when doing an update.
um i reinstalled about 3-4 times and every few hours of pushing an update, i get this idk why
Same issue here.
I've found a slightly hacky workaround that may work for others. I'm not a web dev, so the yarn's and the npm's really don't mean a whole lot to me.
Looking at the error message and the git status of the plugin directory, I can see npm install
is making changes to tracked files, so every time lazy.nvim does a fetch, it's returning this message because there are local changes.
To fix this, I've added a git restore .
to my install command, which resets the repo with the remote and stops lazy.nvim raising alarms when running updates. Here's my current config:
return {
"iamcco/markdown-preview.nvim",
version = "0.0.10",
cmd = { "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewToggle" },
init = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
config = function()
-- Can't get lazy build to work ¯\_(ツ)_/¯
-- This first time loading the plugin, there will be a significant delay becuase the function is synchronous, but after that it shouldn't be noticeable
-- TODO: Either figure out how to get lazy build to work, or figure out how to make this asynchronous
local install_path = vim.fn.stdpath("data") .. "/lazy/markdown-preview.nvim/app"
local node_modules = install_path .. "/node_modules"
if vim.fn.empty(vim.fn.glob(node_modules)) > 0 then
vim.cmd("!cd " .. install_path .. " && npm install && git restore .")
end
-- Options
vim.g.mkdp_auto_close = 0
end,
}
{ "iamcco/markdown-preview.nvim", version = "0.0.10", cmd = { "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewToggle" }, init = function() vim.g.mkdp_filetypes = { "markdown" } end, ft = { "markdown" }, config = function() -- Can't get lazy build to work ¯\_(ツ)_/¯ -- This first time loading the plugin, there will be a significant delay becuase the function is synchronous, but after that it shouldn't be noticeable -- TODO: Either figure out how to get lazy build to work, or figure out how to make this asynchronous local install_path = vim.fn.stdpath("data") .. "/lazy/markdown-preview.nvim/app" local node_modules = install_path .. "/node_modules" if vim.fn.empty(vim.fn.glob(node_modules)) > 0 then vim.cmd("!cd " .. install_path .. " && npm install && git restore .") end -- Options vim.g.mkdp_auto_close = 0 end, }
tried this got this thing:
:!cd /home/daUnknownCoder/.local/share/nvim/lazy/markdown-preview.nvim/app && npm install && git restore .
npm
WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, flatted is its successor.
npm
WARN deprecated date-format@1.2.0: 1.x is no longer supported. Please upgrade to 4.x or higher.
npm
WARN deprecated streamroller@0.7.0: 0.x is no longer supported. Please upgrade to 3.x or higher.
npm
WARN deprecated log4js@3.0.6: 3.x is no longer supported. Please upgrade to 6.x or higher.
added 70 packages, and audited 71 packages in 10s
1 package is looking for funding
run `npm fund` for details
7 vulnerabilities (1 moderate, 2 high, 4 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
i m doin this for now:
{
"iamcco/markdown-preview.nvim",
version = "0.0.10",
cmd = { "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewToggle" },
init = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
keys = {
{ "<leader>mp", "<cmd>MarkdownPreview<CR>", desc = "MarkdownPreview" },
},
config = function()
local install_path = vim.fn.stdpath("data") .. "/lazy/markdown-preview.nvim/app"
local file_path = install_path .. "/yarn.lock"
-- Check if the file exists
local f = io.open(file_path, "r")
if f ~= nil then
io.close(f)
-- Delete the file
os.remove(file_path)
end
local node_modules = install_path .. "/node_modules"
if vim.fn.empty(vim.fn.glob(node_modules)) > 0 then
vim.cmd("!cd " .. install_path .. " && npm install && git restore .")
end
-- Options
vim.g.mkdp_auto_close = 0
end,
},
ig @iamcco should check this out
@scottmckendry Creative solution!
I'm just curious, is there a reason for doing npm install
instead of yarn install
?
@toh995 thanks! As I mentioned I'm not into web dev or javascript, so I have no interest in installing any extra dependencies for NodeJS. Unless I'm mistaken and yarn now ships with node?
@scottmckendry Creative solution!
I'm just curious, is there a reason for doing
npm install
instead ofyarn install
?
npm is mostly installed with all distributions [linux] and i checked speed of both and they are both almost similar, while yarn gives a little bit more user friendly interface, npm is better
@toh995 thanks! As I mentioned I'm not into web dev or javascript, so I have no interest in installing any extra dependencies for NodeJS. Unless I'm mistaken and yarn now ships with node?
10:47:20 PM msg_show.echo Notifications 2023-10-17T22:44:48 Messages INFO :!cd /home/daUnknownCoder/.local/share/nvim/lazy/markdown-preview.nvim/app && npm install && git restore .
npm
WARN deprecated
date-format@1.2.0: 1.x is no longer supported. Please upgrade to 4.x or higher.
npm
WARN deprecated streamroller@0.7.0: 0.x is no longer supported. Please upgrade to 3.x or higher.
npm
WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, flatted is its successor.
npm
WARN deprecated log4js@3.0.6: 3.x is no longer supported. Please upgrade to 6.x or higher.
added 68 packages, and audited 69 packages in 15s
2 packages are looking for funding
run `npm fund` for details
7 vulnerabilities (1 moderate, 2 high, 4 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
idk what is this, i dont use npm much, i tried all that npm fund
, npm audit
both return me found 0 vulnerabilities
idk, upgraded npm to the natest version... any help is appreciated + i still get that status failed sometimes thingy, and to resolve that i always have to do x
and I
i just updated yarn and npm and node and now markdown-preview
is not starting says the node version and quits idk
Check the commit above for an updated (temporary) fix for this. It's asynchronous now so it won't be blocking opening any markdown files and it also suppresses the big long output that comes from npm (which is benign anyway).
I've tested this on both Windows and Linux and it works as intended. Should be enough to keep the lazy.nvim warnings at bay until a permanent fix is in place.
Check the commit above for an updated (temporary) fix for this. It's asynchronous now so it won't be blocking opening any markdown files and it also suppresses the big long output that comes from npm (which is benign anyway).
I've tested this on both Windows and Linux and it works as intended. Should be enough to keep the lazy.nvim warnings at bay until a permanent fix is in place.
+1 for u
ig @iamcco isnt available for now, and the issue seems to be resolved [for now] so i m closing this issue
Why not put npm install
/yarn install
and git restore
part in the build
property which is dedicated to the plugin post-installation or post-update. There seems no need to use a async job.
I couldn't get build to play nicely with node on my machine. But you're right, It's definitely the simpler approach.
I did a test with the following on my Linux machine and found nothing wrong with node.js v18.18 and npm v9.8.1.
build = function()
--vim.fn["mkdp#util#install"]()
-- Temp fix for the yarn.lock issue on update (assuming npm available on the system)
local install_path = vim.fn.stdpath("data") .. "/lazy/markdown-preview.nvim/app"
local node_modules = install_path .. "/node_modules"
local cmd = not require("util").is_win() and "bash" or "pwsh"
if vim.fn.empty(vim.fn.glob(node_modules)) > 0 then
vim.cmd("!cd " .. install_path .. " && npm install")
end
end,
This is nice! I think part of my problem was not using a function for the build. I've managed to simplify my config a lot based on your example, This is working on my Windows machine.
return {
"iamcco/markdown-preview.nvim",
ft = { "markdown" },
cmd = { "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewToggle" },
build = function()
local install_path = vim.fn.stdpath("data") .. "/lazy/markdown-preview.nvim/app"
vim.cmd("silent !cd " .. install_path .. " && npm install && git restore .")
end,
init = function()
vim.g.mkdp_filetypes = { "markdown" }
vim.g.mkdp_auto_close = 0
end,
}
Thank you!
This is nice! I think part of my problem was not using a function for the build. I've managed to simplify my config a lot based on your example, This is working on my Windows machine.
return { "iamcco/markdown-preview.nvim", ft = { "markdown" }, cmd = { "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewToggle" }, build = function() local install_path = vim.fn.stdpath("data") .. "/lazy/markdown-preview.nvim/app" vim.cmd("silent !cd " .. install_path .. " && npm install && git restore .") end, init = function() vim.g.mkdp_filetypes = { "markdown" } vim.g.mkdp_auto_close = 0 end, }
Thank you!
this still doesnt work for me, the plenary is quite stable [for now]
{
"iamcco/markdown-preview.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
cmd = { "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewToggle" },
init = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
config = function()
local job = require("plenary.job")
local install_path = vim.fn.stdpath("data") .. "/lazy/markdown-preview.nvim/app"
local cmd = "bash"
if vim.fn.has("win64") == 1 then
cmd = "pwsh"
end
job
:new({
command = cmd,
args = { "-c", "npm install && git restore ." },
cwd = install_path,
on_exit = function()
print("Finished installing markdown-preview.nvim")
end,
on_stderr = function(_, data)
print(data)
end,
})
:start()
-- Options
vim.g.mkdp_auto_close = 0
end,
},
This still works, will check out the new one snip soon, anyway, u should update the Readme so new users won't find this error
Why not put
npm install
/yarn install
andgit restore
part in thebuild
property which is dedicated to the plugin post-installation or post-update. There seems no need to use a async job.
This worked well for me.
I had:
build = "cd app && npm install",
And changed it to:
build = "cd app && npm install && git restore .",
One uninstall & reinstall later, no more complaints.
done
Describe the bug A clear and concise description of what the bug is.
um lazy doesnt update the plugin and it says status failed
Expected behavior A clear and concise description of what you expected to happen. um it should update
Desktop (please complete the following information):
Config