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

[Bug] Installation error #232

Open
S1M0N38 opened this issue Sep 5, 2024 · 7 comments
Open

[Bug] Installation error #232

S1M0N38 opened this issue Sep 5, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@S1M0N38
Copy link

S1M0N38 commented Sep 5, 2024

  • OS: MacOs Sonoma 14.4.1
  • NeoVim Version: NVIM v0.10.1 Build type: Release LuaJIT 2.1.1725453128 (installed with brew)
  • Python Version: Python 3.11.9 (main, Apr 30 2024, 13:08:46) [Clang 15.0.0 (clang-1500.3.9.4)]
  • Python is installed with: compile from source with pyenv. Create new virtualenv with venv. See later.
  • Health checks
`:checkhealth molten`
molten: require("molten.health").check()

molten-nvim ~
- OK NeoVim >=0.9
- OK Python >=3.10
- OK Python module pynvim found
- OK Python module jupyter-client found
- WARNING Optional python module cairosvg not found
  - ADVICE:
    - pip install cairosvg
- WARNING Optional python module pnglatex not found
  - ADVICE:
    - pip install pnglatex
- WARNING Optional python module plotly not found
  - ADVICE:
    - pip install plotly
- WARNING Optional python module kaleido not found
  - ADVICE:
    - pip install kaleido
- WARNING Optional python module pyperclip not found
  - ADVICE:
    - pip install pyperclip
- WARNING Optional python module nbformat not found
  - ADVICE:
    - pip install nbformat
- WARNING Optional python module pillow not found
  - ADVICE:
    - pip install pillow
`:checkhealth provider` (the python parts)
provider.python: require("provider.python.health").check()

Python 3 provider (optional) ~
- pyenv: Path: /opt/homebrew/Cellar/pyenv/2.4.10/libexec/pyenv
- pyenv: Root: /Users/simo/.local/share/pyenv
- Using: g:python3_host_prog = "/Users/simo/.local/share/venvs/test-nvim/bin/python3"
- Executable: /Users/simo/.local/share/venvs/test-nvim/bin/python3
- Python version: 3.11.9
- pynvim version: 0.5.0
- OK Latest pynvim is installed.

Python virtualenv ~
- $VIRTUAL_ENV is set to: /Users/simo/.local/share/venvs/test-nvim
- Python version: 3.11.9
- OK $VIRTUAL_ENV provides :!python.

Description

I've tried to install molten.nvim with lazy.nvim but I wasn't successful.
Molten commands (e.g. :MoltenInfo) are not available.

Reproduction Steps

  1. Create Python environment and test installation
python -m venv $XDG_DATA_HOME/venvs/test-nvim
source $XDG_DATA_HOME/venvs/test-nvim/bin/activate
pip install pynvim jupyter_client --no-cache-dir
python -c "import neovim, jupyter_client"
  1. Create minimal.lua
vim.g.python3_host_prog = vim.fn.expand("$XDG_DATA_HOME") .. "/venvs/test-nvim/bin/python3"

-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
  if vim.v.shell_error ~= 0 then
    vim.api.nvim_echo({
      { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
      { out, "WarningMsg" },
      { "\nPress any key to exit..." },
    }, true, {})
    vim.fn.getchar()
    os.exit(1)
  end
end
vim.opt.rtp:prepend(lazypath)

-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Setup lazy.nvim
require("lazy").setup({
  spec = {
    {
      "benlubas/molten-nvim",
      version = "^1.0.0", -- use version <2.0.0 to avoid breaking changes
      build = ":UpdateRemotePlugins",
      init = function()
        vim.g.molten_output_win_max_height = 12
      end,
    },
  },
  checker = { enabled = true },
})
  1. Run Neovim using just minimal.lua as config and use test-nvim as APPNAME
NVIM_APPNAME=test-nvim nvim --clean -u minimal.lua

Result (same behaviour after update lazy.nvim as well)
Screenshot 2024-09-05 at 15 19 15

Manually running :UpdateRemotePlugins result in this error

remote/host: python3 host registered plugins ['molten']
Error detected while processing function remote#host#UpdateRemotePlugins:
line   16:
E482: Can't open file /path/to/manifest for writing: no such file or directory
@S1M0N38 S1M0N38 added the bug Something isn't working label Sep 5, 2024
@benlubas
Copy link
Owner

benlubas commented Sep 5, 2024

can you check for a file at $HOME/.local/share/$NVIM_APPNAME/rplugin.vim

If that doesn't exist, you could try creating it (or at least creating the folder that it's supposed to be in). I honestly don't know why you're getting this error. It seems like yet another remote plugin failure (ie. neovim bug), but we can try and figure it out

@S1M0N38
Copy link
Author

S1M0N38 commented Sep 6, 2024

if [ -d $HOME/.local/share/test-nvim ]; then
  echo "Directory exists."
else
  echo "Directory does not exist."
fi
# ->  Directory exists

if [ -e $HOME/.local/share/test-nvim/rplugin.vim ]; then
  echo "File exists."
else
  echo "File does not exist."
fi
# -> File does not exists.

So I try to create manually

touch $HOME/.local/share/test-nvim/rplugin.vim

I've opened nvim as before and run :UpdateRemotePlugins.
Still same error :(

@S1M0N38
Copy link
Author

S1M0N38 commented Sep 6, 2024

btw, I've recap the aforementioned setup in the following script for easy reproducibility
https://gist.github.com/S1M0N38/0abb1fc43a41af5c3b1882006212c8c8

@S1M0N38
Copy link
Author

S1M0N38 commented Sep 6, 2024

I've also uninstall neovim (brew uninstall neovim) and compile from source for my platform (macOS)

brew install ninja cmake gettext curl
git clone https://github.com/neovim/neovim
cd neovim
make CMAKE_BUILD_TYPE=Release
sudo make install
NVIM v0.11.0-dev-722+g9570ad24f
Build type: Release
LuaJIT 2.1.1724512491
Run "nvim -V1 -v" for more info

Still same error

@benlubas
Copy link
Owner

benlubas commented Sep 7, 2024

seems like the file write is failing here: https://github.com/neovim/neovim/blob/3d1110674ec330138ad6675f828673ca32575d4b/runtime/autoload/remote/host.vim#L172

Maybe chmod 777 that directory temporarily? I have no idea why the write would be failing. If you're familiar with vimscript you could add some log statements to try and figure out if all the args to writefile look normal. You shouldn't have to recompile b/c it's a runtime file.

@S1M0N38
Copy link
Author

S1M0N38 commented Sep 11, 2024

Setup

I've created new-minimal.lua following the suggestion by lazy.nvim

vim.g.python3_host_prog = vim.fn.expand("$XDG_DATA_HOME") .. "/venvs/test-nvim/bin/python3"

-- This takes care of redefining the XDG variables
vim.env.LAZY_STDPATH = ".repro"

load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
  spec = {
    {
      "benlubas/molten-nvim",
      build = ":UpdateRemotePlugins",
      init = function()
        vim.g.molten_use_border_highlights = true
      end,
    },
  },
})

-- Print this to show a strange behavior...
vim.cmd('echo stdpath("data")  ')
vim.cmd('echo stdpath("config")')
vim.cmd('echo stdpath("cache") ')
vim.cmd('echo stdpath("state") ')

Debug

I then start Neovim with

nvim -u new-minimal.lua

Using the flag --clean was one source of error!

Even though the .repro and its subdirectories were successfully created and the molten plugin downloaded by lazy.nvim in the correct location (``.repro/data/nvim/lazy/molten-nvim```), the output of the echo stdpath commands was

/Users/my-user/Developer/test-molten/.repro//data/nvim
/Users/my-user/Developer/test-molten/.repro//config/nvim
/Users/my-user/Developer/test-molten/.repro//cache/nvim
/Users/my-user/Developer/test-molten/.repro//state/nvim

An extra backslash between .repro and its subdirectories!

maybe it's a lazy.nvim issue 🤷‍♂️

Solution

In the file ...share/nvim/runtime/plugin/rplugin.vim, this path with an extra backslash was considered invalid. However, Neovim allows you to manually define the location of the rplugin.vim manifest with the environment variable NVIM_RPLUGIN_MANIFEST.

So, I was finally able to install and run molten with

NVIM_RPLUGIN_MANIFEST=".repro/data/nvim/rplugin.vim" nvim -u new-minimal.lua

@S1M0N38
Copy link
Author

S1M0N38 commented Sep 12, 2024

In the README or documentation, we could suggest to users experiencing the same installation bug that they try manually defining the environment variable NVIM_RPLUGIN_MANIFEST.

@S1M0N38 S1M0N38 closed this as completed Sep 12, 2024
@S1M0N38 S1M0N38 reopened this Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@S1M0N38 @benlubas and others