Page MenuHomeFreeBSD

resurect lua-language-server
ClosedPublic

Authored by dave_freedave.net on Wed, Dec 3, 6:15 PM.
Tags
None
Referenced Files
F139398880: D54055.id167499.diff
Thu, Dec 11, 4:30 PM
F139398450: D54055.id167499.diff
Thu, Dec 11, 4:26 PM
F139362129: D54055.diff
Thu, Dec 11, 6:09 AM
Unknown Object (File)
Wed, Dec 10, 12:36 PM
Unknown Object (File)
Tue, Dec 9, 12:35 PM
Unknown Object (File)
Tue, Dec 9, 8:54 AM
Unknown Object (File)
Tue, Dec 9, 7:54 AM
Unknown Object (File)
Tue, Dec 9, 7:12 AM
Subscribers

Details

Summary

I guess technically it was building but it would SIGBUS. The fix for that in bee.lua has been merged upstream. Far enough for both the luamake and lua-language-server which are not the same versions.

Test Plan

There is a known flaky test for lua-language-server which I have hit, fairly often actually. But more than half the time make test is going to pass all unit tests.

Diff Detail

Repository
R11 FreeBSD ports repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dave_freedave.net created this revision.

So, what you have at the end there (the .if ${OSVERSION} < 15 block) feels like an antipattern, but I can't think of any better way to do it. I've tried out a couple alternatives and they just made it more complicated. At the end of the day, it's a valid approach and it works, and also it only needs to be in there until 14 goes EOL (now that 15 is out, 14 has a defined death day).

I say, fix those small things, do a final sweep to make sure that the port is where you want it, and then let's get it committed!

devel/lua-language-server/Makefile
15

This block of comments should be removed; they are helpful locally, but not in the ports tree. Plus, 13 is going away in a matter of months.

22

These two (GH_PROJECT / GH_TAGNAME) are defaults and should be removed.

Not that I doubted you, but I did rebuild after removing GH_PROJECT and GH_TAGNAME.

devel/Makefile
1630 โ†—(On Diff #167499)

I see I didn't sort this right, should I update diff or is that fixable on merge?

devel/Makefile
1630 โ†—(On Diff #167499)

So first off, I loved seeing it there, as it shows you've put a lot of work into understanding how the ports build system works. Great job!

But, it's actually not helpful to have in a patch. Category Makefiles get out-of-date pretty quickly, and I'd much rather yyp it in neovim than have it fail in patch(1) and need to recover it by hand anyway.

So, while you absolutely did the right thing including it here, I'd actually appreciate if you could remove it from the patch entirely ๐Ÿ˜„

removed change to ports/devel/Makefile

devel/lua-language-server/Makefile
69โ€“73

it looks like deve/glib20 relied upon the existence of the header file. That also doesn't appear to need bsd.port.[pre|post].mk and can use bsd.port.mk like normal.

Not looking for ways to slow down commit, but consistency helps everybody. Thoughts?

Oh relying upon the header file would also help in case inotify gets backported to stable/14 in the future.

Oh relying upon the header file would also help in case inotify gets backported to stable/14 in the future.

Yeah, I really dig the approach they took. It's much better to do a capability check than a version check. I'd vote for that approach, though to be clear, either approach works and is acceptable. But the header test has a much lower chance of false negatives.

Change to mimic strategy used in devel/glib20. Also I think portclippy didn't see the variables on stable/15 before so I had to change them to have leading '_' and at that point they can be up by LIB_DEPENDS.

I actually started with the submodules asset. I moved back to github tuples as I feel it provides more knobs to adjust moving forward.

Good catch, diizzy. I'm glad to see Dave's response that he actively engaged that approach and made an informed decision about it.

Based on my own experience with the port, I think Dave is making a sound decision. I had to adjust each component separately on multiple occasions.

The consequence of upstream using both luamake and raw ninja is that the build is incredibly brittle. FreeBSD support of each component is the most after of afterthoughts, and one component or another has a habit of breaking the FreeBSD build (much less the runtime) and, in my own experience, needed to be adjusted to different versions.

It's definitely more work up-front, but my guess is that Dave is going to be very glad he took the time to deal with tuples.

Dave: I did the following:

/usr/ports$ curl <diff URL> | patch -p1
/usr/ports$ cd devel/lua-language-server
/usr/ports/devel/lua-language-server$ portlint -A

And I am getting a lot of stuff:

WARN: Makefile: [4]: whitespace before end of line.
WARN: Makefile: [4]: use tab (not space) to make indentation
WARN: Makefile: [13]: use a tab (not space) after a variable name
FATAL: Makefile: [19]: use a tab (not space) after a variable name
FATAL: Makefile: extra item "                                                       " placed in the PORTNAME section.
FATAL: Makefile: extra item "MAINTAINER" placed in the PORTNAME section.
FATAL: Makefile: extra item "COMMENT" placed in the PORTNAME section.
FATAL: Makefile: extra item "WWW" placed in the PORTNAME section.
FATAL: Makefile: extra item "LICENSE" placed in the MAINTAINER section.
FATAL: Makefile: extra item "LICENSE_FILE" placed in the MAINTAINER section.
WARN: Makefile: COMMENT is set externally to this port's Makefile, but this port is not configured as a slave port.
FATAL: Makefile: extra item "LIB_DEPENDS" placed in the LICENSE section.
FATAL: Makefile: extra item "_INOTIFY_" placed in the LICENSE section.
FATAL: Makefile: extra item "_LINK_INOTIFY_" placed in the LICENSE section.
FATAL: distinfo not under git.
FATAL: Makefile not under git.
FATAL: pkg-descr not under git.
FATAL: files/patch-3rd_bee.lua_compile_common.lua not under git.
FATAL: files/patch-3rd_luamake_compile_ninja_freebsd.ninja not under git.
FATAL: files/patch-3rd_bee.lua_test_test.lua not under git.
FATAL: files/lua-language-server.in not under git.
FATAL: files/patch-3rd_luamake_bee.lua_test_test.lua not under git.
18 fatal errors and 4 warnings found.

Clearly, not being under git is expected, and I have no clue what its issue is with your perfectly correct COMMENT. And, because this is a relatively complicated build, you get a lot of latitude for organizing things in a sensible way. But, the ordering of things is a big part of idiomaticity (my spellchecker says it's not a word, which baffles me). You should resolve the majority of those. Tabs vs. spaces and trailing whitespace is absolutely a problem and we need to be really diligent about it.

In my nvim config, I have:

vim.api.nvim_create_autocmd("Filetype", {
    pattern = "make",
    callback = function()
        vim.opt_local.tabstop    = 8
        vim.opt_local.shiftwidth = 8
        vim.opt_local.expandtab  = true
    end,
})

Additionally, I use mini.trailspace from the incredible mini.nvim plugin (https://github.com/nvim-mini/mini.nvim/blob/main/readmes/mini-trailspace.md) to automatically highlight trailing whitespace. I highly recommend it (or anything like it; search for "whitespace" in https://github.com/rockerBOO/awesome-neovim) for FreeBSD development; with it, I could see the issue as soon as I opened the file:

image.png (1ร—1 px, 673 KB)

edit: And don't forget about set list to see spaces vs. tabs. If you haven't used it before, you'll want to set up listchars with something like set listchars=eol:โ†ฒ,extends:โ€ฆ,nbsp:โฃ,precedes:โ€ฆ,space:โ—ฆ,tab:ยป ,trail:ยท.

Totally forgot, I also have this guy:

vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
    pattern = {"*/ports/*", "/etc/*", "/usr/local/etc/*",
    callback = function()
        vim.opt_local.tabstop    = 8
        vim.opt_local.shiftwidth = 8
        vim.opt_local.expandtab  = true
    end,
})

So, everything in /usr/ports (or any other ports tree), /etc, and /usr/local/etc will automatically get 8-width non-expanded tabs unless it matches some other known filetype. That has saved my bacon more times than I can count.

I only ran portclippy before. I'll go find portlint and track down the other errors too.

devel/lua-language-server/Makefile
2
12

Please use this approach https://cgit.freebsd.org/ports/tree/dns/aardvark-dns/Makefile#n22
Much easier to check for rather than searching for random file names when doing treewide cleanups.

18

USES= tar is incorrect

I only ran portclippy before. I'll go find portlint and track down the other errors too.

I ran it too. I am actually pretty shocked that portclippy had nothing to say! Either it doesn't care about whitespace or it's buggy.

portclippy is newer, but both are actively maintained. They are both opinionated, and they disagree about as much as they agree. Neither of them are static analyzers, so use them as like, inspiration.

devel/lua-language-server/Makefile
2

Dave: A little background here, DISTVERSION defaults to PORTVERSION, so semantically it doesn't matter which you use.

But, especially when using the GitHub fetch system or any other programmatic fetch (like Go and Rust ports), DISTVERSION has become the preferred idiom, and there are things that DISTVERSION can do that PORTVERSION can't.

12

I urged him to switch to the path check, actually. All things being equal, I always prefer checking capability over version. Dave, diizzy just reminded us why things aren't actually equal here.

Background: when a FreeBSD version becomes unsupported, we grep through the tree to find checks that no longer apply, and we generally do it by looking for /${OSVERSION} < 15/ (conceptually).

Dave, the choice of approach is yours, but if you stick with the path add a comment above so that future greps will catch it. Does that make sense?

I didn't get nearly as many errors from portlint. But it may be I fixed the end of line spaces first. Anyway both portclippy --strict and portlint -A seem happy now.

Additionally I changed to use DISTVERSION and remove tar from USES.

I kinda prefer the file test which I got from devel/glib20. I am a fan of consistency but it doesn't appear there is one true way yet.

If only I'd been slower. I prefer the file check but can add comment. Before I do though, is the check in 2 places acceptable?

If only I'd been slower. I prefer the file check but can add comment. Before I do though, is the check in 2 places acceptable?

OK, I'm behind that approach. Keep in mind that your goal there is to guess what future us will grep for. Good luck!

It is, but not ideal. If it were an OSVERSION check, it'd be trivial, but each filesystem check contributes to I/O latency. Maybe in the upper block, set BASE_LIBINOTIFY := true (make sure to use := there) and change the check to .if ! ${BASE_LIBINOTIFY}?

I'm considering asking portmgr about Mk/Uses/libinotify.mk. Dave, I'll Cc: you if I do that so you can see the process.

one sec I'm changing it to the way requested because both portlint and portclippy like it. so it has that plus grep going for it.

changed to check for inotify the way dns/aardvark-dns does. it passes both portclippy and portlint and keeps all the variables in one place.

Dave, we're getting there, I promise!

I'm not sure how you're testing, but your build testing should be centered around poudriere testport:
poudriere testport -j <your_jail_name> devel/lua-language-server

Running it under there, I get the following:

===========================================================================
====> Running Q/A tests (stage-qa)
====> Checking for pkg-plist issues (check-plist)
===> Parsing plist
===> Checking for items in STAGEDIR missing from pkg-plist
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/Cocos4.0
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/Defold
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/Jass
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/OpenResty
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/bee
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/busted
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/ffi-reflect
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/lfs
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/love2d
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/lovr
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/luaecs
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/luassert
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/luv
Error: Orphaned: @dir %%DATADIR%%/meta/3rd/skynet
===> Checking for items in pkg-plist which are not in STAGEDIR
===> Error: Plist issues found.
*** Error code 1

Stop.
make: stopped making "check-plist" in /usr/ports/devel/lua-language-server
=>> Error: check-plist failures detected

Each of those dirs is most likely empty (otherwise it would have registered those dirs automatically). For each of them, you'll need to decide whether they need to exist (in which case they must be added to pkg-plist):

@dir foo
@dir(<owner>,<group>,<mode>) bar
@dir(,,750) some/dir
@dir(adamw,wheel) another/dir

Or, if any shouldn't exist, then you'll need to explicitly ${RMDIR} them in post-install:.

Looking into it. I just got poudriere running in a bhyve VM. I can see the same errors so next update should be clean.

Those empty directories are LuaCATS modules. They are extra type annotations for popular libraries. They don't get built (or tested it would seem) but they are nice to have.

This also makes it so lua-language-server knows about vim.g... and vim.uv... so welcome addition for me.

And now I am running poudriere testport -j 15p0 -p local devel/lua-language-server on my own. I could have saved us all some time doing that sooner, apologies.

There it is! It's looking great, Dave. I'm just doing some final tests and--barring anything wacky--I'll get it committed shortly.

There it is! It's looking great, Dave. I'm just doing some final tests and--barring anything wacky--I'll get it committed shortly.

I feel like I just got the "Sensei Ishikawa" treatment. Where you look up at the hill with footholds while I start climbing... only to find you on the top of the hill that you walked around to the gentle path up the hill. But you know, it worked: I'm sold. I will be using poudriere going forward.

This revision was not accepted when it landed; it landed in state Needs Review.Mon, Dec 8, 3:03 PM
This revision was automatically updated to reflect the committed changes.

There it is! It's looking great, Dave. I'm just doing some final tests and--barring anything wacky--I'll get it committed shortly.

I feel like I just got the "Sensei Ishikawa" treatment. Where you look up at the hill with footholds while I start climbing... only to find you on the top of the hill that you walked around to the gentle path up the hill. But you know, it worked: I'm sold. I will be using poudriere going forward.

Wow that's quite the vivid simile!

Honestly, there's a lot to be said for learning the system closer to the metal before stepping into an automated system. It'll pay dividends in the long run.

Seriously, man, great work on this. You should be proud of yourself.

Some ideas for next steps:

  1. Make the luamake build support ccache
  2. Make the luaLS build support ccache
  3. See whether you can coax a verbose build (if we can see the actual commands rather than just "compiling foo/bar/baz.c" it makes debugging much easier)
  4. Ensure the build is reproducible (IIRC, it used to include some opinionated timestamp that busted caches, dunno if that's still the case)
  5. Be sure to dogfood updates before submitting update PRs (LuaLS updates used to have a 50/50 chance of building fine and crashing at runtime. I had to skip at least half of the updates)