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

How to access "resources"? #53

Open
toshi0383 opened this issue Feb 17, 2018 · 6 comments
Open

How to access "resources"? #53

toshi0383 opened this issue Feb 17, 2018 · 6 comments

Comments

@toshi0383
Copy link
Contributor

toshi0383 commented Feb 17, 2018

I have a script file embedded using Package.resources.

scripts

I created example project at https://github.com/toshi0383/package-resources-sample

How should I execute the script from the main executable?
Looks like Bundle.main.executablePath does not follow symlink and returns symlink's location instead of the actual binary's directory path.

If this file is found in you repo, then all those directories will be copied into the same path as the executable.

IMO, it would be a lot easier when assets from Package.resources goes under /usr/local/lib/${tool}/resources/ regardless of global, local, or binary install.
By the way /usr/local can be changed by allowing PREFIX install (maybe by adding --prefix option).

@yonaskolb
Copy link
Owner

Any resources can just be accessed with relative paths eg "scripts" or "../scripts".
Let me know if that doesn't work

@yonaskolb
Copy link
Owner

Actually that might be incorrect, perhaps it's Bundle.main.bundlePath + "/scripts"

@yonaskolb
Copy link
Owner

yonaskolb commented Feb 26, 2018

I think that setting the RESOURCE_PATH to an absolute path will make it more easily usuable.

In regards to where the resources should be linked to, this should be changed due to this symlink issue and if people aren't using the RESOURCE_PATH env (we can't expect them to).

The usual place to put resources from my undestanding is /usr/local/share/$tool. Your suggested /usr/local/lib/${tool}/resources/ is another option though not standard I belive. In either case these resources could be symlinked back to Mint's installation directory, similar to how homebrew does it.

@toshi0383
Copy link
Contributor Author

Thanks. Let's put symlink in the standard place 👌

@amichnia
Copy link
Contributor

amichnia commented May 7, 2019

Hi, what is the status here? I had some issues recently trying to access the resources. I ended up with following symlink to find "real" binary location, and so the resources folder.

This is what I ended up with:

import PathKit

...

var tool = Path("$tool") // swiftymocky in my case
var bundlePath = Path(Bundle.main.bundlePath)
var resourcesPath: Path {
    return (try? (bundlePath + tool).symlinkDestination())?.removingLastComponent() ?? bundlePath
}

I'm just a bit concerned if it would keep working? As far as I got, when you move the stuff to /usr/local/share/$tool it would still be symlinked in the mint directory, right?

@yonaskolb
Copy link
Owner

I haven't had time to work on this. But yes, the directories would probably still be symlinked back to the mint directory

mizozobu added a commit to ramble-inc/pixelmatch that referenced this issue Mar 6, 2021
Mint has some issue with resources.
see yonaskolb/Mint#53
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

3 participants