Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

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

Open
jeffbowman opened this issue Aug 5, 2020 · 12 comments
Open

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

jeffbowman opened this issue Aug 5, 2020 · 12 comments

Comments

@jeffbowman
Copy link

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.

@hoelzro
Copy link
Owner

hoelzro commented Aug 6, 2020

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
Copy link
Owner

hoelzro commented Aug 9, 2020

@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!

@jeffbowman
Copy link
Author

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
Copy link
Author

jeffbowman commented Aug 10, 2020

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?

@hoelzro
Copy link
Owner

hoelzro commented Aug 11, 2020

@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. 😄

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!

@jeffbowman
Copy link
Author

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!

@vonpupp
Copy link

vonpupp commented Aug 12, 2020

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.

@jeffbowman
Copy link
Author

@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.

@hoelzro
Copy link
Owner

hoelzro commented Aug 12, 2020 via email

@vonpupp
Copy link

vonpupp commented Aug 14, 2020

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.

@jeffbowman
Copy link
Author

@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).

@vonpupp
Copy link

vonpupp commented Aug 14, 2020

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants