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

Luarocks fails to install on macOS BigSur #180

Open
akinsho opened this issue Jan 26, 2021 · 26 comments
Open

Luarocks fails to install on macOS BigSur #180

akinsho opened this issue Jan 26, 2021 · 26 comments

Comments

@akinsho
Copy link
Collaborator

akinsho commented Jan 26, 2021

Just tried out my config (which I recently added a rock to) on my work mac (running BigSur not sure if that matters) and found that although the same install process seems to happen to setup luarocks via packer, the install process appears to finish but I don't think luarocks is correctly installed since further calls to install try to install luarocks again. The rock I also specified (penlight) is also not installed.

@wbthomason
Copy link
Owner

wbthomason commented Jan 26, 2021

Yeah, that's nvim-lua/plenary.nvim#4 (and the same fix - setting env var MACOSX_DEPLOYMENT_TARGET to 10.15 - works to fix it). I'm considering setting that env var by default in packer, but I want to know how that value was found first, so I can have confidence I won't cause more problems by setting it.

@clason
Copy link

clason commented Jan 27, 2021

Note that you only need to set that variable once when you install the first rock (because that's when hererocks builds luajit, which requires the flag to build correctly). Once luajit is installed (locally), using rocks (and adding further rocks if they don't need a complicated build) works fine without it.

So doing this manually with MACOSX_DEPLOYMENT_TARGET=10.15 nvim and then calling PackerSync once should suffice (until you wipe the cache directory).

@akinsho
Copy link
Collaborator Author

akinsho commented Jan 27, 2021

@wbthomason that resolved the issue for me, I'm happy to close this or otherwise leave it here so you can track against doing something automagically for users or maybe to track against documenting the fix if not, whatever you prefer.

@clason
Copy link

clason commented Jan 27, 2021

Might be good to leave open (and pin?) for now, at least until the Readme is finalized with such instructions?

@wbthomason wbthomason pinned this issue Jan 27, 2021
@mherna
Copy link

mherna commented Feb 2, 2021

Hi, I am having trouble running PackerSync I think it is related to this issue since it fails to spawn a plenary.nvim process and I am running macOS BigSur with the m1 chip.

Any ideas on how to solve this issue?

Error executing vim.schedule lua callback: .../site/pack/packer/start/plenary.nv
im/lua/plenary/job.lua:374: Failed to spawn process...

stack traceback:
        .../site/pack/packer/start/plenary.nvim/lua/plenary/job.lua:374: in func
tion '_execute'
        .../site/pack/packer/start/plenary.nvim/lua/plenary/job.lua:417: in func
tion 'start'
        ...im/site/pack/packer/start/gitsigns.nvim/lua/gitsigns.lua:77: in funct
ion 'run_job'
        ...im/site/pack/packer/start/gitsigns.nvim/lua/gitsigns.lua:204: in func
tion 'ret'
        ...e/pack/packer/start/gitsigns.nvim/lua/gitsigns/async.lua:59: in funct
ion 'step'
        ...e/pack/packer/start/gitsigns.nvim/lua/gitsigns/async.lua:62: in funct
ion <...e/pack/packer/start/gitsigns.nvim/lua/gitsigns/async.lua:49>
        ...e/pack/packer/start/gitsigns.nvim/lua/gitsigns/async.lua:70: in funct
ion 'cb'
        vim.lua:243: in function <vim.lua:243>
NVIM v0.5.0-dev+nightly-17-gcc1851c9f
Build type: Release
LuaJIT 2.1.0-beta3

@wbthomason
Copy link
Owner

@mherna: this error occurs when you run PackerSync? I'm a bit confused, as packer doesn't use plenary at all, and your stack trace seems to point to an issue in plenary.

@mherna
Copy link

mherna commented Feb 3, 2021

@wbthomason, thanks for the reply. I reinstalled neovim, and the issue got solved. Weirdly it was happening just when I ran PackerSync, which led me to believed it had something to with packer, but good to know that packer doesn't use plenary for future reference.

@matu3ba
Copy link
Contributor

matu3ba commented Feb 12, 2021

@mherna Did you only reinstall neovim or did you also clean any packer packages in $HOME/.local/share/nvim/site/pack/start $HOME/.local/share/nvim/site/pack/opt ?

@mherna
Copy link

mherna commented Feb 13, 2021

@matu3ba I cleaned$HOME/.local/share/nvim/site/pack/start and $HOME/.local/share/nvim/site/pack/opt

@matu3ba
Copy link
Contributor

matu3ba commented Feb 15, 2021

@wbthomason I feel like "clean $HOME/.local/share/nvim/site/pack/start and $HOME/.local/share/nvim/site/pack/opt" belongs to the FAQ. The alternative is to have logging+instructions, if you want to investigate further.

@wbthomason
Copy link
Owner

Notes from discussion with @clason on Gitter/Matrix:

  1. The default for python_cmd is wrong on macOS; should be python3
  2. We should set the env var that fixes this problem by default (at least on macOS)
  3. packer may think that the hererocks install job succeeds even when it fails. Need to figure out why

@garymh
Copy link

garymh commented Apr 20, 2021

I think I'm getting something related to this:

Error in packer_compiled: ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:10: attempt to index local 'plugin' (a nil value)
Please check your config for correctness

As far as I can tell, the hererocks installation craps out at some point but without an error. (I'm guessing, since I don't have a packer_hererocks directory in ~/.cache/nvim)

The PackerSync trick with MACOSX_DEPLOYMENT_TARGET doesn't seem to work for me, though 😞 Is there a way to manually install hererocks in that directory to at least have a temporary fix?

@wbthomason
Copy link
Owner

@garymh Your error message doesn't seem obviously related to luarocks. What makes you think the problem lies there rather than with a config or compiled file issue?

@garymh
Copy link

garymh commented Apr 20, 2021

@wbthomason I guess it could be something different- I'm just using a very slimmed down packer setup and still getting it. The only thing I could pick out that looked off from my packer compiled file was the luarocks path.

Here is my packer loading code:

local packer = nil

local function init()
    if packer == nil then
        packer = require('packer')
        util = require("packer/util")
        packer.init({
            compile_path = util.join_paths(vim.fn.stdpath("config"),
                                           "vimscript", "packer_compiled.vim"),
            max_jobs = 10
        })
    end

    local use = packer.use
    packer.reset()

    use {"wbthomason/packer.nvim", opt = true}

    use {
        "AndrewRadev/switch.vim",
        cmd = {"Switch", "SwitchReverse"},
        config = function()
            vim.g.switch_custom_definitions =
                {
                    {"assert", "refute"}, {"if", "unless"}, {"[ ]", "[x]"},
                    {"yes", "no"}, {"let g:", "vim.g."}
                }
        end
    }
end

local plugins = setmetatable({}, {
    __index = function(_, key)
        init()
        return packer[key]
    end
})

return plugins

The error message comes up when I use the :Switch command. It seems to work fine when not lazy-loaded... maybe it's a problem with that?

@garymh
Copy link

garymh commented Apr 20, 2021

Yeah - it seems to be something with lazy loading? 🤷 I removed all the keys and cmd triggers from my packer loading code and everything seems to be working... 🤔

@jacksonludwig
Copy link

I had this issue on linux. For me, the issue was that the python_cmd default is python, whereas my python executable is named python3. Switching it to python3 allows things to install correctly.

There was no error on my end though, even though things weren't working. The hererocks install just went infinitely.

@wbthomason
Copy link
Owner

@jacksonludwig: Thanks for the report. Could you please start a new issue with the contents of ~/.cache/nvim/packer.nvim.log? I suspect that we're missing an early return in the hererocks install function.

@jacksonludwig
Copy link

I just set my python_cmd back to the default to try to make the error happen again but it did not. Is there some sort of cache or something? I don't know why it would suddenly not hang with the wrong python_cmd

@wbthomason
Copy link
Owner

If you already have Luarocks installed via hererocks, packer won't try to reinstall it. Using hererocks should be the only place that we use python_cmd.

@folke
Copy link

folke commented Jun 30, 2021

You can add vim.fn.setenv("MACOSX_DEPLOYMENT_TARGET", "10.15") on top of your plugins.lua

@gegoune
Copy link

gegoune commented Jul 14, 2021

Which is proper solution here? Setting up python3 in config.luarocks.python_cmd or MACOSX_DEPLOYMENT_TARGET?

@clason
Copy link

clason commented Jul 14, 2021

The environment variable is the easiest fix. Note that it is only needed to be set the very first time you install something for the luarocks installation itself; adding more rocks after it will work fine without it.

@gegoune
Copy link

gegoune commented Jul 14, 2021

Thanks @clason, will add what Folke posted above. I do understand importance of it on initial install only, want to have it in my dots for fresh installations anyway. Thanks guys!

@kkharji
Copy link

kkharji commented Jul 29, 2021

🤔 still facing the same issue ✗ Failed to install package tried to a number of stuff but no luck, I tired both MACOSX_DEPLOYMENT_TARGET and setting python command.

@beauwilliams
Copy link

You can add vim.fn.setenv("MACOSX_DEPLOYMENT_TARGET", "10.15") on top of your plugins.lua

This works for me. Cheers!

@YodaEmbedding
Copy link

YodaEmbedding commented Jul 3, 2022

NOTE: Use your own Mac version. I had MACOSX_DEPLOYMENT_TARGET=12.3.1!

# Possibly optional.
ln -s /usr/local/bin/python3 /usr/local/bin/python

# Start from scratch.
rm -rf ~/.cache/nvim

nvim
:lua vim.fn.setenv("MACOSX_DEPLOYMENT_TARGET", "10.15")
:PackerSync
:qa!

# If the above fails, install manually:
export MACOSX_DEPLOYMENT_TARGET=10.15
cd ~/.cache/nvim/packer_hererocks
rm -rf 2.1.0-beta3
python3 hererocks.py -j "2.1.0-beta3" "2.1.0-beta3"

# Reattempt:
nvim
:PackerSync
:qa!

EDIT: The :PackerSync indicates that a rock fzy was installed, but importing it still fails... So I had to do some unholy hackery to force lua 5.1 which somehow was then using lua 5.4, and so I sinned and symlinked them:

# Pretend that Lua 5.1 is LuaJIT 2.1.0-beta3:
export MACOSX_DEPLOYMENT_TARGET=10.15
cd ~/.cache/nvim/packer_hererocks
rm -rf 2.1.0-beta3
python3 hererocks.py -l "5.1" "2.1.0-beta3"

# Install rock (e.g. fzy):
nvim
:PackerSync
:qa!

# Pretend 5.4 is 5.1 is 2.1.0-beta3:
ln -s ~/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.4 \
      ~/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1

# Repent:
echo "Father, I repent."

jvcarli added a commit to jvcarli/cosmonauta.nvim that referenced this issue Jan 2, 2023
[packer.nvim](https://github.com/wbthomason/packer.nvim)
has some anti-features and bugs that were a deal breaker for me:

- Bootstrapping is not straightforward
- Snapshots are fundamentally broken, i.e.
if I removed a plugin I tried to restore a snapshot packer would not work.
- Luarocks install doesn't work on macos
- Packer compilation step is annoying and sometimes makes config files out of sync
with the current setup, which makes debugging and plugin development awkward

[lazy.nvim](https://github.com/folke/lazy.nvim) doesn't have a compilation step,
doesn't require [impatient.nvim](https://github.com/lewis6991/impatient.nvim) for speeding up
modules initialization, has a straightforward bootstrap process and in general has a better design than
[packer.nvim](https://github.com/wbthomason/packer.nvim).

SEE: wbthomason/packer.nvim#814
SEE: wbthomason/packer.nvim#1010
SEE: wbthomason/packer.nvim#180
jvcarli added a commit to jvcarli/cosmonauta.nvim that referenced this issue Jan 2, 2023
[packer.nvim](https://github.com/wbthomason/packer.nvim)
has some anti-features and bugs that were a deal breaker for me:

- Bootstrapping is not straightforward
- Snapshots are fundamentally broken, i.e.
if I removed a plugin I tried to restore a snapshot packer would not work.
- Luarocks install doesn't work on macos
- Packer compilation step is annoying and sometimes makes config files out of sync
with the current setup, which makes debugging and plugin development awkward

[lazy.nvim](https://github.com/folke/lazy.nvim) doesn't have a compilation step,
doesn't require [impatient.nvim](https://github.com/lewis6991/impatient.nvim) for speeding up
modules initialization, has a straightforward bootstrap process and in general has a better design than
[packer.nvim](https://github.com/wbthomason/packer.nvim).

SEE: wbthomason/packer.nvim#814
SEE: wbthomason/packer.nvim#1010
SEE: wbthomason/packer.nvim#180
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests