obvious icon indicating copy to clipboard operation
obvious copied to clipboard

Module no long loads with AwesomeWM 4.3, Lua 5.3 or 5.4.

Open jeffbowman opened this issue 3 years ago • 12 comments

Using this code:

local obvious = require("obvious")

gives the following error:

Error during execution: /usr/share/awesome/lib/obvious/lib/mpd/init.lua:53: attempt to call a nil value (global 'module')

It appears the module function does not exist in Lua 5.3 or Lua 5.4. I tried substituting module with require but then I was getting an error on when doing something like:

local myvolume = obvious.volume_alsa() that said:

attempt to index a boolean value (local 'obvious')

I'm not sure how to fix it as I'm not quite that strong in Lua, so thought I'd at least post an issue here.

jeffbowman avatar Aug 05 '20 21:08 jeffbowman

Hi @jeffbowman, thanks for the report!

module was indeed removed in Lua 5.2 - a lot of distributions will include a backwards-compatability shim, though, which is probably how I haven't noticed this until you brought it to my attention!

I've gone through and removed module whenever I've seen it while working on other things, but this hasn't happened for all of obvious since I myself only use a subset of it, and I didn't want to mistakenly break anything others might be using. I don't have a lot of time for obvious these days, but if I find time I might be able to get the basics working. I know you said you're not very strong with Lua, but if you find the time, patches fixing any module invocations would be very much appreciated!

hoelzro avatar Aug 06 '20 04:08 hoelzro

@jeffbowman I managed to carve out some time this weekend and remove all calls to module() that I could find - please give it a shot and let me know if I broke anything!

hoelzro avatar Aug 09 '20 22:08 hoelzro

Thanks @hoelzro !!

I did download and try the package, it didn't work, but for a different reason.

I use Arch Linux, which packages the awesome windowmanager with a dependency on Lua 5.3, which does not have a 'socket.http' library it seems. I did find a package to install: lua53-socket which got me past that one, then it failed on this line: (also in the gps module) local json = require 'json' which I resolved (I think) by installing the lua53-dkjson package. I had to change require statements in both gps and weather to point to that library instead (ala local json = require 'dkjson') but the weather module now fails on this line: local http_request = require 'http.request' which doesn't seem to exist and I can't find a lua53 package for it in Arch.

I'm still trying different things, going to Lua 5.4 may resolve most of those problems, so I may look into building my own awesome package and see if I can make it depend on Lua 5.4... I really like the way awesome works, but the Lua changes usually borks things for me, sadly. I really appreciate your effort on this package and (when it is working) I use it quite a bit! Huge thanks your efforts here.

jeffbowman avatar Aug 10 '20 02:08 jeffbowman

omigosh!

Okay, so after that last post, I did some more digging and I have it working now. Here is the recipe:

Packages needed in Arch Linux:

  • lua53-dkjson
  • lua-http
  • lua53-lpeg
  • lua53-cqueues

Change lines in obvious/gps/init.lua and obvious/weather/forecast.lua like this (this worked for me on Arch Linux, YMMV on other distributions - not necessarily suggesting a code change, just documenting what I did to get it working for me):

local json = require 'json' ==> local json = require 'dkjson'

I get a warning that says:

Obvious Not using native Unicode library for obvious - it is highly recommended to compile the native library for accuracy

Not sure where that is coming from though. Also, does the effort on this issue resolve #36?

jeffbowman avatar Aug 10 '20 02:08 jeffbowman

@jeffbowman Wow, thanks for digging into this and sticking with it! I'm also an Arch user, and the http.request dependency is my doing - I'm glad you were able to find packages to get it working. I ended up making a package for http://luaforge.net/projects/luajson/, but I don't think I ever distributed it anywhere. If dkjson is compatible with that library, a good solution would probably be something like this:

local json = pcall(require, 'json') or pcall(require, 'dkjson')

To be honest, obvious shouldn't fail to load if one of those dependencies is missing - it should issue a warning and just fail the widget that needs it.

Regarding the current warning you're seeing regarding Unicode, if you just run make in the obvious directory it should build everything you need. If not, you know where to find me. :smile:

I completely forgot about #36 - I've been using Obvious with 5.3 for a long time now, so I think I'll just close that.

Thanks again for your sleuthing efforts!

hoelzro avatar Aug 11 '20 02:08 hoelzro

Thanks for the tip with pcall! I've updated my version with your suggestion.

I ran make in the obvious directory, it compiled native.so but it doesn't seem to be recognized. I still get the same error. Not sure this issue is the correct forum for that though, is there a mailing list/irc/wiki (the wiki here appears non-existent) I could use to chat about it?

For this particular issue, I think the original problem has been resolved and we can close this one (always feels like progress when closing issues to me ;-) )

Thanks for being so responsive and helpful!

jeffbowman avatar Aug 11 '20 23:08 jeffbowman

Hello,

I don't want to be unpolite and get into the conversation but I think since it is related it might be worth to report it here also. I am having the same issue error: .../obvious/lib/mpd/init.lua:53: attempt to call a nil value (global 'module'), so I went to the file at line 53 and there is a module("obvious.lib.mpd") if I change it with require I get too many recursions. I am sorry, I don't know lua.

Best regards.

vonpupp avatar Aug 12 '20 01:08 vonpupp

@vonpupp you might need to git pull again as there have been changes related to that on this issue. Looking at the code here, line 53 in lib/mpd/init.lua is a blank line. If you are using a package from your Linux distribution, it is likely out-of-date since the changes related to this branch occurred very recently.

Hope that helps some.

jeffbowman avatar Aug 12 '20 15:08 jeffbowman

@jeffbowman Ah, I bet you need to update Lua's module search path - that looks something like this: https://github.com/hoelzro/awesome-config/blob/d843dde47d8af2a922ba6201f44681419f9a8192/rc.lua#L32

On Tue, Aug 11, 2020, at 6:11 PM, Jeff Bowman wrote:

Thanks for the tip with pcall! I've updated my version with your suggestion.

I ran make in the obvious directory, it compiled native.so but it doesn't seem to be recognized. I still get the same error. Not sure this issue is the correct forum for that though, is there a mailing list/irc/wiki (the wiki here appears non-existent) I could use to chat about it?

For this particular issue, I think the original problem has been resolved and we can close this one (always feels like progress when closing issues to me ;-) )

Thanks for being so responsive and helpful!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hoelzro/obvious/issues/43#issuecomment-672345590, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2KHGRQAGSSTIZ5N2L2STSAHFZRANCNFSM4PV5YCNQ.

hoelzro avatar Aug 12 '20 22:08 hoelzro

Thanks @jeffbowman, I just noticed there is a "main" branch which is more updated than the master. I guess you are referring to that one. I will keep an eye on this issue, since it seems I am having the same issue also. I am also using Arch Linux, but the awesome package that I am using is the following: community/awesome 4.3-2.

vonpupp avatar Aug 14 '20 21:08 vonpupp

@vonpupp same here, pretty much everything related to my awesomewm setup is from packages in the main repo (as opposed to AUR). However, see my list of packages from above, and then I installed this repo directly in .config/awesome as the AUR obvious-git wasn't picking up the changes make by @hoelzro, and I made a few local changes as well (notably the dkjson reference since I missed finding the luajson package beforehand).

jeffbowman avatar Aug 14 '20 22:08 jeffbowman

@jeffbowman, I was using obvious from the master branch cloned manually within my .config/awesome and so far so good until the latest package updates. I will follow your suggestions on this thread.

vonpupp avatar Aug 14 '20 23:08 vonpupp