wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.88k stars 264 forks source link

Luarocks: new-version and build capabilities #580

Open f3fora opened 3 years ago

f3fora commented 3 years ago

Describe the feature

luarocks build

Use packer to build a .rockspec with luarocks build, such that one can define something like

use_rocks('my-package-dev-1.rockspec')

luarocks new-version

When one executes :PackerUpdade, packer should call also luarocks new-version my-rock to update rocks, where my-rock is each luarocks dependency installed with packer.

wbthomason commented 3 years ago

See @teto's comment on #526 for the first part.

Re: new-version: My understanding was that this command only updates the rockspec for a given rock, and does not actually update rocks. Is this incorrect?

teto commented 3 years ago

first time I see new-version. I dont see why this would be needed ? just install the rockspecs from the different repos ? they may have conflicting requirements but as a first approach that should be fine.

wbthomason commented 3 years ago

Yes; I'm not sure that new-version solves any problems for us here (though I do want to find a way to update installed rocks, which we currently lack).

f3fora commented 3 years ago

Sorry. I misunderstood new version function. I was stupid, because I use it something for its real purpose.

I actually need a easy way to update rocks.

Maybe, comparing results of luarocks show myrock --mversion and luarocks search myrock can be useful.

Alternatively, using the entry version in use_rocks such that one can explicitly choose the rock version can solve the issue, leaving to the user the job of checking when a new version is released.

f3fora commented 3 years ago

Alternatively, using the entry version in use_rocks such that one can explicitly choose the rock version can solve the issue, leaving to the user the job of checking when a new version is released.

However, version argument raises the following error

Usage: luarocks install [-h] [--keep] [--force] [--force-fast]
       [--only-deps] [--no-doc] [--verify] [--check-lua-versions]
       [--deps-mode <mode>] [--no-manifest] <rock> [<version>]

Error: option '--version' does not take arguments
teto commented 3 years ago

using luarocks commands with just the package name wont be practical because most plugin authors won't upload their rockspec to luarocks.org, we just need the builiding blocks to be there (nvim-plenary, lush.nvim etc). So I believe packer will have to pass an explicit path to the rockspec. Btw your report is missing the actual command you ran but I can guess the issue anyway. Try: luarocks install plenary.nvim 1.2 instead (replace the entries, you just pass the version number directly)

f3fora commented 3 years ago

using luarocks commands with just the package name wont be practical because most plugin authors won't upload their rockspec to luarocks.org, we just need the builiding blocks to be there (nvim-plenary, lush.nvim etc). So I believe packer will have to pass an explicit path to the rockspec.

Ok! I didn't even think about this. I just use it with some luarocks.org packages.

Btw your report is missing the actual command you ran but I can guess the issue anyway. Try: luarocks install plenary.nvim 1.2 instead (replace the entries, you just pass the version number directly)

This was a report about packer.nvim when using

use_rocks {'my_package' , version='my_version'}
akinsho commented 3 years ago

FWIW the use_rocks keys get converted into flags like --<key> but I guess version needs to be special cased to just pass in the value without the flag prefix.

f3fora commented 3 years ago

FWIW the use_rocks keys get converted into flags like --<key> but I guess version needs to be special cased to just pass in the value without the flag prefix.

So, this is actually a bug!

akinsho commented 3 years ago

Yeah, version isn't special cased like env so it falls into https://github.com/wbthomason/packer.nvim/blob/3fdea07bec6cb733d2f82e50a10829528b0ed4a9/lua/packer/luarocks.lua#L219

f3fora commented 3 years ago

Actually the solution is to change this line https://github.com/wbthomason/packer.nvim/blob/3fdea07bec6cb733d2f82e50a10829528b0ed4a9/lua/packer/luarocks.lua#L207

adding or key == 'version'

I can fix this but I prefer not to open a PR for just few words.

akinsho commented 3 years ago

@f3fora I don't actually that's the best solution. That line is intended to prevent users being able to mess with how the luarocks are installed since packer is already using those and a user messing with those two keys specifically would cause breakage. Whilst adding it there would allow it to work, it would muddy the waters about what that function is for. I think it would be better to explicitly special case the version key to just pass the value without a flag