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

packer.nvim/lua/packer.lua:110: module 'packer.luarocks' not found: #1263

Open
raisfeld-ori opened this issue Oct 27, 2023 · 0 comments
Open
Labels
bug v1 An issue or PR relevant to packer v2

Comments

@raisfeld-ori
Copy link

  • nvim --version: 0.9.4
  • git --version: git 2.42.0
  • Operating system/version: windows 11
  • Terminal name/version: terminal (the microsoft store version of the command line)

Steps to reproduce

install NvChad
create a directory inside the lua directory and require it in init.lua.
in the new directory, add an init.lua file and
install packer according to the docs without luarocks installed before.
add the line vim.o.runtimepath = vim.fn.stdpath('data') .. '/site/pack/*/start/*,' .. vim.o.runtimepath to packer.lua.
try using :PackerSync, this is what resulted for the issue for me.

Actual behaviour

when i try to use PackerSync or PackerCompile i get an error

E5108: Error executing lua: Vim(lua):E5108: Error executing lua ...m-data\site\pack\packer\start\packer.nvim/lua/packer.lua:110: module 'packer.luarocks' not found:
        no field package.preload['packer.luarocks']
cache_loader: module packer.luarocks not found
cache_loader_lib: module packer.luarocks not found
        no file '.\packer\luarocks.lua'
        no file 'C:\Program Files\Neovim\bin\lua\packer\luarocks.lua'
        no file 'C:\Program Files\Neovim\bin\lua\packer\luarocks\init.lua'
        no file '.\packer\luarocks.dll'
        no file 'C:\Program Files\Neovim\bin\packer\luarocks.dll'
        no file 'C:\Program Files\Neovim\bin\loadall.dll'
        no file '.\packer.dll'
        no file 'C:\Program Files\Neovim\bin\packer.dll'
        no file 'C:\Program Files\Neovim\bin\loadall.dll'
stack traceback:
        [C]: in function 'require'
        ...m-data\site\pack\packer\start\packer.nvim/lua/packer.lua:110: in function 'require_and_configure'
        ...m-data\site\pack\packer\start\packer.nvim/lua/packer.lua:576: in function 'sync'
        [string ":lua"]:1: in main chunk
        [C]: at 0x7ff7ce2d8620
stack traceback:
        [C]: at 0x7ff7ce2d8620

Expected behaviour

for :PackerSync to work lol

packer files

here is packer.lua file i'm currently using:

-- This file can be loaded by calling `lua require('plugins')` from your init.vim
vim.o.runtimepath = vim.fn.stdpath('data') .. '/site/pack/*/start/*,' .. vim.o.runtimepath

return require('packer').startup(function(use)
  -- Packer can manage itself
  use 'wbthomason/packer.nvim'


end)
packer log file
-- log.lua
--
-- Inspired by rxi/log.lua
-- Modified by tjdevries and can be found at github.com/tjdevries/vlog.nvim
--
-- This library is free software; you can redistribute it and/or modify it
-- under the terms of the MIT license. See LICENSE for details.
-- User configuration section
local default_config = {
  -- Name of the plugin. Prepended to log messages
  plugin = 'packer.nvim',

  -- Should print the output to neovim while running
  use_console = true,

  -- Should highlighting be used in console (using echohl)
  highlights = true,

  -- Should write to a file
  use_file = true,

  -- Any messages above this level will be logged.
  level = 'debug',

  -- Level configuration
  modes = {
    { name = 'trace', hl = 'Comment' },
    { name = 'debug', hl = 'Comment' },
    { name = 'info', hl = 'None' },
    { name = 'warn', hl = 'WarningMsg' },
    { name = 'error', hl = 'ErrorMsg' },
    { name = 'fatal', hl = 'ErrorMsg' },
  },

  -- Which levels should be logged?
  active_levels = { [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true },

  -- Can limit the number of decimals displayed for floats
  float_precision = 0.01,
}

-- {{{ NO NEED TO CHANGE
local log = {}

local unpack = unpack or table.unpack

local level_ids = { trace = 1, debug = 2, info = 3, warn = 4, error = 5, fatal = 6 }
log.cfg = function(_config)
  local min_active_level = level_ids[_config.log.level]
  local config = { active_levels = {} }
  if min_active_level then
    for i = min_active_level, 6 do
      config.active_levels[i] = true
    end
  end
  log.new(config, true)
end

log.new = function(config, standalone)
  config = vim.tbl_deep_extend('force', default_config, config)
  local outfile = string.format('%s/%s.log', vim.fn.stdpath 'cache', config.plugin)
  vim.fn.mkdir(vim.fn.stdpath 'cache', 'p')
  local obj
  if standalone then
    obj = log
  else
    obj = {}
  end

  local levels = {}
  for i, v in ipairs(config.modes) do
    levels[v.name] = i
  end

  local round = function(x, increment)
    increment = increment or 1
    x = x / increment
    return (x > 0 and math.floor(x + 0.5) or math.ceil(x - 0.5)) * increment
  end

  local make_string = function(...)
    local t = {}
    for i = 1, select('#', ...) do
      local x = select(i, ...)

      if type(x) == 'number' and config.float_precision then
        x = tostring(round(x, config.float_precision))
      elseif type(x) == 'table' then
        x = vim.inspect(x)
      else
        x = tostring(x)
      end

      t[#t + 1] = x
    end
    return table.concat(t, ' ')
  end

  local console_output = vim.schedule_wrap(function(level_config, info, nameupper, msg)
    local console_lineinfo = vim.fn.fnamemodify(info.short_src, ':t') .. ':' .. info.currentline
    local console_string = string.format('[%-6s%s] %s: %s', nameupper, os.date '%H:%M:%S', console_lineinfo, msg)
    -- Heuristic to check for nvim-notify
    local is_fancy_notify = type(vim.notify) == 'table'
    vim.notify(
      string.format([[%s%s]], is_fancy_notify and '' or ('[' .. config.plugin .. '] '), console_string),
      vim.log.levels[level_config.name:upper()],
      { title = config.plugin }
    )
  end)

  local log_at_level = function(level, level_config, message_maker, ...)
    -- Return early if we're below the config.level
    if level < levels[config.level] then
      return
    end
    local nameupper = level_config.name:upper()

    local msg = message_maker(...)
    local info = debug.getinfo(2, 'Sl')
    local lineinfo = info.short_src .. ':' .. info.currentline

    -- Output to console
    if config.use_console and config.active_levels[level] then
      console_output(level_config, info, nameupper, msg)
    end

    -- Output to log file
    if config.use_file and config.active_levels[level] then
      local fp, err = io.open(outfile, 'a')
      if not fp then
        print(err)
        return
      end

      local str = string.format('[%-6s%s %s] %s: %s\n', nameupper, os.date(), vim.loop.hrtime(), lineinfo, msg)
      fp:write(str)
      fp:close()
    end
  end

  for i, x in ipairs(config.modes) do
    obj[x.name] = function(...)
      return log_at_level(i, x, make_string, ...)
    end

    obj[('fmt_%s'):format(x.name)] = function()
      return log_at_level(i, x, function(...)
        local passed = { ... }
        local fmt = table.remove(passed, 1)
        local inspected = {}
        for _, v in ipairs(passed) do
          table.insert(inspected, vim.inspect(v))
        end
        return string.format(fmt, unpack(inspected))
      end)
    end
  end
end

log.new(default_config, true)
-- }}}

return log
packer compiled file ``` -- Automatically generated packer.nvim plugin loader code

if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end

vim.api.nvim_command('packadd packer.nvim')

local no_errors, error_msg = pcall(function()

_G._packer = _G._packer or {}
_G._packer.inside_compile = true

local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end

local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end

_G._packer.profile_output = results
end

time([[Luarocks path setup]], true)
local package_path_str = "C:\Users\raisf\AppData\Local\Temp\nvim\packer_hererocks\2.1.1696883897\share\lua\5.1\?.lua;C:\Users\raisf\AppData\Local\Temp\nvim\packer_hererocks\2.1.1696883897\share\lua\5.1\?\init.lua;C:\Users\raisf\AppData\Local\Temp\nvim\packer_hererocks\2.1.1696883897\lib\luarocks\rocks-5.1\?.lua;C:\Users\raisf\AppData\Local\Temp\nvim\packer_hererocks\2.1.1696883897\lib\luarocks\rocks-5.1\?\init.lua"
local install_cpath_pattern = "C:\Users\raisf\AppData\Local\Temp\nvim\packer_hererocks\2.1.1696883897\lib\lua\5.1\?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end

if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end

time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end

time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
["packer.nvim"] = {
loaded = true,
path = "C:\Users\raisf\AppData\Local\nvim-data\site\pack\packer\start\packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
}
}

time([[Defining packer_plugins]], false)

_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false

if should_profile then save_profiles() end

end)

if not no_errors then
error_msg = error_msg:gsub('"', '\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end

</details>
@raisfeld-ori raisfeld-ori added bug v1 An issue or PR relevant to packer v2 labels Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v1 An issue or PR relevant to packer v2
Projects
None yet
Development

No branches or pull requests

1 participant