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

fatal error: module 'LuaSkin' not found #22

Open
farzadmf opened this issue Feb 7, 2022 · 28 comments
Open

fatal error: module 'LuaSkin' not found #22

farzadmf opened this issue Feb 7, 2022 · 28 comments

Comments

@farzadmf
Copy link

farzadmf commented Feb 7, 2022

Hi, I'm super new to Hammerspoon, and I saw a post somewhere that required the spaces module from here.

This is how I'm trying to install:

  1. Clone the repo
  2. Go into spaces directory
  3. I have an Intel Mac, so I do make install-x86_64
  4. I get the following error:
Skipping Lua Compile Verification
mkdir -p ~/.hammerspoon/hs/spaces
install -m 0644 init.lua ~/.hammerspoon/hs/spaces
test -f docs.json && install -m 0644 docs.json ~/.hammerspoon/hs/spaces || echo "No docs.json file to install"
spacesObjc.m:2:9: fatal error: module 'LuaSkin' not found
@import LuaSkin ;
 ~~~~~~~^~~~~~~
1 error generated.
make: *** [obj_x86_64/spacesObjc.so] Error 1

Is there something I need to do? Is this module bundled with Hammerspoon or I need to install it from somewhere?

@latenitefilms
Copy link

Probably just easier to download the pre-compiled version here:

https://github.com/asmagill/hammerspoon_asm/blob/master/spaces/spaces-v0.1.2-universal.tar.gz

@farzadmf
Copy link
Author

farzadmf commented Feb 7, 2022

Thank you @latenitefilms for the quick reply,

Sorry for the stupid question, but where should I extract the file? As I mentioned, I'm very new to Hammersppon and trying to learn it 😛

@latenitefilms
Copy link

Just unzip it and put it in your ~/.hammerspoon folder. You can then use it by using require("hs.spaces").

@farzadmf
Copy link
Author

farzadmf commented Feb 7, 2022

Thank you @latenitefilms , will update the issue once I try that

@farzadmf
Copy link
Author

Hey @latenitefilms , sorry to bother you if this is a stupid question (I'm new to Mac)

I downloaded and extracted the zip file, copied the files to ~/.hammerspoon/hs/spaces, and when I try to import it, I see the following:
image

I've learned how to get around that for applications, but I'm not sure how to do that with individual files likes this. Can you please help me?

@farzadmf
Copy link
Author

@latenitefilms pinging you again just in case you missed my last message 😝

@latenitefilms
Copy link

Pinging @cmsj as he might have some ideas as @asmagill seems very busy at the moment.

I think you might have to code sign this extension yourself to get around macOS's security requirements.

@farzadmf
Copy link
Author

Thank you @latenitefilms . Not sure who to tag here, but that's something I don't know how to do and I'd really appreciate if someone can give some pointers as to where I can find instructions on how to do it

@asmagill
Copy link
Owner

Sorry, yeah, I'm out of town and somewhat limited in access at the moment...

A while back I did finally get an Apple code signing key, so I guess I should start signing the universal binaries in these repos if I'm going to continue offering prebuilt versions.

In the mean time, I think the following should work for you, though I haven't actually tried it on just a module yet (just the Hammerspoon app when I made local development builds)...

Before I bit the bullet and purchased an Apple developer key, I used a local privately signed key... I used this link for a guide on creating the key... it's a bit dated, I think there are a couple of extra steps now, but if I remember correctly, the defaults should be ok to just click through.

https://bd808.com/blog/2013/10/21/creating-a-self-signed-code-certificate-for-xcode/

Once that's done, you can sign a file (usually only the binary files require it, so for modules, anything that ends with .so after building or downloading) with the following command:

$ codesign --verbose --sign "<SIGNING_CERT>" "internal.so"

<SIGNING_CERT> should match the name given to the key you created in the key chain, and internal.so would be the binary component you're needing to sign.

@farzadmf
Copy link
Author

Thank you very much @asmagill for the detailed answer.

I'm not in a rush for this, so I was wondering if you have a timeframe of when you'll be signing the pre-built packages (if you're gonna do it of course).

If not, I can look into the link and try to do it myself.

@latenitefilms
Copy link

@asmagill / @cmsj - Curious, if this is an extension that people really want/need - any reason we can't bring into the Hammerspoon core?

@cmsj
Copy link

cmsj commented Feb 17, 2022

@asmagill / @cmsj - Curious, if this is an extension that people really want/need - any reason we can't bring into the Hammerspoon core?

We've resisted putting Spaces into the core because it's private API that has had a history of changing a lot, unfortunately.

@asmagill
Copy link
Owner

As I recall, this version was one I was considering suggesting for core as it mostly leverages accessibility elements of the Dock, and the private API elements it uses are the ones that have remained pretty constant since about 10.8 or so.

Then I got distracted and haven't had a chance to get back to it...

I'm hoping to be back home late Sunday so hopefully I can take a look at Hammerspoon again next week and come up with a timeframe for getting back to maintaining things like this.

@farzadmf
Copy link
Author

Hey @asmagill , I hope you got back to your home safe and sound 🙂

Just wondering if there's any update on this

@latenitefilms
Copy link

I believe he's been working hard to bring this across to Hammerspoon's core!

@asmagill
Copy link
Owner

Yes, it's currently in pull Hammerspoon/hammerspoon#3154 waiting for @cmsj to sign off on an internal target name change. I fully expect it to be in the next Hammerspoon release, barring any unexpected problems.

The module has also been reorganized to follow the recent changes in module organization and the standalone version can now be found at https://github.com/asmagill/hs._asm.spaces/tree/master. I have just uploaded a signed version, but if you have the time, I'd really like for you to try the unsigned (the one with "universal" in the archive name) first and see if it makes a difference... if it does, then we need to figure out whats different between our environments... I don't mind providing signed versions, but it would be nice to add verbiage indicating whether it's needed or not for a given user's setup.

@farzadmf
Copy link
Author

Hey @asmagill , sorry, I was occupied and I didn't get a chance to check here.

I'd really like for you to try the unsigned (the one with "universal" in the archive name)

You mean downloading spaces-v0.2-universal.tar.gz from the spaces folder and trying it again?

And thank you @latenitefilms for your reply

@asmagill
Copy link
Owner

Yes, that one's unsigned, but built against the latest LuaSkin and Hammerspoon... I'd like to see if it loads on your machine. If it doesn't, try the signed one (https://github.com/asmagill/hs._asm.spaces/blob/master/spaces-v0.2-signed.tar.gz). If your system still requires third party libraries to be signed, I'd like to dig deeper at some point and find out why -- none of the machines I have access to seem to require it.

@farzadmf
Copy link
Author

farzadmf commented Mar 22, 2022

Hey @asmagill , what tar command(s) should I use to extract the files? I tried with tar zxvf ... and tar xvf ..., but I get errors. I installed gnu gzip from brew, and I still see errors.

Errors before installing gzip from brew (gzip --version gives Apple gzip 353.100.22):

# with zxvf
gzip: unknown compression format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
# with xvf
gzip: unknown compression format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

Errors after installing gzip from brew (gzip --version gives gzip 1.11):

# with zxvf
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
# with xvf
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

I also tried the GUI version (double click in Finder), but that also shows an error:
image

@asmagill
Copy link
Owner

That is really odd... both my originals and the copies made with git clone https://github.com/asmagill/hs._asm.spaces.git worked with tar -tzvf spaces-... so I'm not sure... how did you download them?

which tar returns /usr/bin/tar and which gzip (which I use to compress the archive, rather than having tar do it during archival) returns /usr/bin/gzip, so its not some version oddity due to homebrew or ports...

@asmagill
Copy link
Owner

More detail:

amagill@Erasmus:.../t/hs._asm.spaces:%0:% which tar
/usr/bin/tar
amagill@Erasmus:.../t/hs._asm.spaces:%0:% tar --version
bsdtar 3.5.1 - libarchive 3.5.1 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 
amagill@Erasmus:.../t/hs._asm.spaces:%0:% which gzip
/usr/bin/gzip
amagill@Erasmus:.../t/hs._asm.spaces:%0:% gzip --version
Apple gzip 352.40.6

@farzadmf
Copy link
Author

farzadmf commented Mar 23, 2022

OK, that's weird indeed, I did a git clone of the repo and it seems to be working, although I see the following errors/warnings:

tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.com.apple.lastuseddate#PS'
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.com.apple.TextEncoding'

which should be because I'm using the gnu tar. I don't think they create any issues because seems like I can extract the files.

As for how I downloaded them, I used wget to get them directly:

wget https://github.com/asmagill/hs._asm.spaces/blob/master/spaces-v0.2-signed.tar.gz
wget https://github.com/asmagill/hs._asm.spaces/blob/master/spaces-v0.2-universal.tar.gz

Not sure why they don't work 🤔

One question: it creates an hs folder when extracted; do I need to move all the files to ~/.hammerspoon/hs or a subset of files is enough (if so, which ones?)

@asmagill
Copy link
Owner

The assumption (which I probably need to spell out more clearly in the installation instructions -- it has been awhile since the boilerplate I use has been updated) is that you expand the archive within your hammerspoon config directory, so yes, move everything into the ~/.hammerspoon/hs directory.

Technically, you can skip the folders ending in .dSYM if you don't care about getting detail in crash reports (there shouldn't be any at this point, but it can help during development) and you can skip spaces.docs.json if you don't care about adding the additional documentation to the internal help system -- the only required files are the lua and dylib files, but its usually easiest to just move them all.

@farzadmf
Copy link
Author

Thank you very much @asmagill , it's very late at night for me right now, I'm gonna give it a try tomorrow morning as soon as I get the chance and will keep you in the loop

@farzadmf
Copy link
Author

Hey again @asmagill , so I did extract the universal one (after git cloneing the repo), and it seems to be working 🚀🚀🚀 .

That's so good, I think, ATM, hammerspoon is the only tool exposing a spaces API, and I'm so excited to try it.

Just one thing: there are some resources and bookmarks that I have that use spaces.activeSpace(), but I think the newer API has spaces.activeSpaces() only. Just wondering what the recommended way would be to get the space the mouse is currently located (for example, for toggling a window in that specific space).

And sorry if it's a "lazy" question, and I can search the docs to figure this out, but I'd appreciate if you make my life easier by telling me 😛

@asmagill
Copy link
Owner

It depends upon what you mean by "space the mouse is currently located [in]"...

If you mean the currently active screen which has the window with the current focus (i.e. that the user is typing into or interacting with), then hs.spaces.focusedSpace() should give you what you want.

If you mean the screen where the mouse is hovering, even if no window in that screen is currently focused or active, then you have to do something a little more creative:

local spaces = require("hs.spaces")
local screen = require("hs.screen")
local geometry = require("hs.geometry")
local mouse = require("hs.mouse")

mouseCursorSpace = function()
    local mousePos = geometry.new(mouse.absolutePosition())
    local answer = nil
    for _, scr in ipairs(screen.allScreens()) do
        if mousePos:inside(scr:fullFrame()) then
            answer = spaces.activeSpaceOnScreen(scr)
            break
        end
    end
    return answer
end

Now, invoking the function mouseCursorSpace() should give you the id of the space the mouse is hovering in.

@asmagill
Copy link
Owner

And thinking more about it, your earlier wget commands were getting the HTML for the page which describes the gzipped tar file in question... to get the raw file, the github URL is a little different -- e.g. instead of using https://github.com/asmagill/hs._asm.spaces/blob/master/spaces-v0.2-signed.tar.gz, you should have used https://github.com/asmagill/hs._asm.spaces/raw/master/spaces-v0.2-signed.tar.gz (note the raw sub-directory, instead of blob).

If you go to https://github.com/asmagill/hs._asm.spaces/blob/master/spaces-v0.2-signed.tar.gz your web browser and hover over the Download button, you should see the "correct" URL for downloading (assuming you have View Status Bar enabled... otherwise right click on Download and select copy URL to get the correct URL).

@farzadmf
Copy link
Author

your earlier wget commands were getting the HTML for the page which describes the gzipped tar file in question

Wow, so sorry about that, what a stupid mistake 🤦‍♂️

And thank you so much for the code, I'm just starting to get familiar with hammerspoon, and it really helps 🙏

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

No branches or pull requests

4 participants