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

rice append when rice.MustFindBox is in package #4

Closed
matrixik opened this issue Mar 30, 2014 · 6 comments
Closed

rice append when rice.MustFindBox is in package #4

matrixik opened this issue Mar 30, 2014 · 6 comments

Comments

@matrixik
Copy link

Hello,

thank you for great package.

Could you make rice tool recursive? So that it could embed resources if rice.MustFindBox is called in package in subdirectory and not in main program.

For example I would like to change https://github.com/pksunkara/alpaca so that it will use go.rice:
https://github.com/matrixik/alpaca/blob/master/alpaca/template.go#L11
But it's package and not main program. It's working fine when I just build main program but when I try to run rice append --exec alpaca.exe I got error:

no calls to rice.FindBox() found
Error setting zip offset: exit status 13

Or maybe there is some way for it to work that I don't know?

Best regards,
Dobrosław Żybort

@GeertJohan
Copy link
Owner

Hi,
Thanks for reporting this :)

You can currently do this by using rice --import-path <import-path> append --exec alpaca.exe. But that will only allow you to append/embed one package.

Doing a recursive find in all imported packages is something I thought about before.. Simply finding boxes recursively in packages probably won't work since rice allows relative paths, and so you might get multiple different folders with the same name (e.g. templates folder in different packages). It'll probably require some breaking changes in the way a package is appended/embedded and loaded during execution. Maybe need to append with full (absolute) path's to avoid duplicates.
I hope the rice with --import-path will solve your problem. I'll add 'finding boxes in imported packages' to the TODO list.

@matrixik
Copy link
Author

Hi,

--import-path did the trick. Thank you very much!
I use rice --import-path github.com/pksunkara/alpaca/alpaca embed now.

because rice append is not working on Windows even with zip installed with Cygwin:

Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
This is Zip 3.0 (July 5th 2008), by Info-ZIP.
D:\Golibs\forks\src\github.com\pksunkara\alpaca>go build -o alpaca-full.exe

D:\Golibs\forks\src\github.com\pksunkara\alpaca>rice -v --import-path github.com/pksunkara/alpaca/alpaca append --exec alpaca-full.exe
#### WARNING ! ####
`rice append` is known not to work under windows because the `zip` command is not available. Please let me know if you got this to work (and how).
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\alpaca.go
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\error.go
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\format_blueprint.go
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\langs_node.go
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\langs_php.go
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\langs_python.go
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\langs_ruby.go
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\library.go
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\template.go
2014/03/31 20:33:14     found box '../templates'
2014/03/31 20:33:14 scanning file D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca\utils.go
2014/03/31 20:33:14
2014/03/31 20:33:14 Will create tmp zipfile: C:\Users\Dobek\AppData\Local\Temp\ricebox-1396290794-fj3tra70ls.zip
2014/03/31 20:33:14 Will append to file: D:\Golibs\forks\src\github.com\pksunkara\alpaca\alpaca-full.exe
Error setting zip offset: exit status 3

D:\Golibs\forks\src\github.com\pksunkara\alpaca>zip -A alpaca-full.exe
        zip warning: central dir not where expected - could not adjust offsets
        zip warning: (try -FF)

zip error: Zip file structure invalid (alpaca-full.exe)

zip -FF also is not helping so I will stay with rice embed as "Good enough".

Thank you for your time.

@GeertJohan
Copy link
Owner

Thanks, no problem :)
Don't forget, you can run rice clean to remove the generated source code and get back to 'live' files.

@matrixik
Copy link
Author

matrixik commented Apr 1, 2014

Maybe you could also add warning to README that append don't work on Windows and embed should be used.

@GeertJohan
Copy link
Owner

Done :)

@matrixik
Copy link
Author

matrixik commented Apr 1, 2014

Thank you.

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

2 participants