-
Notifications
You must be signed in to change notification settings - Fork 186
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
Fails to locate box when cross-compiling in go 1.5 #66
Comments
Is the binary executed with having the pwd equal to the cmd import path location? |
Yes. I ran I do the identical same steps in a docker container with the Ubuntu 14.04 image and the build passes but the resultant binary panics. |
I'm seeing the same issue. It looks like the error only occurs when a relative path is specified. So, "./assets" fails on cross-compilation, but just "assets" does not. |
I didn't find how this can happen yet. I only tested subfolders being rice boxes (so no |
I'm getting the same issue on normal compilation on OS X and am also using a relative path. All works fine in live mode but I cannot append to an executable. |
Same issue here. Compiling with |
I'm not too familiar with cross-compiling.. I'l try to reproduce. Can someone paste the complete panic message? |
@GeertJohan It's not an issue about cross compiling I think, more an issue with Go 1.5. I get the same problem even though not cross-compiling. Compiled on a 64bit Linux, executed on 64bit Linux, here is the full panic :
There is also the panic from Goji though. Don't mind that part. |
I have created a sample app that demonstrates the issue I am seeing at https://github.com/robdimsdale/go-rice-test from OSX run the following command:
and copy the resultant binary to a linux machine and you will see the following error:
If you cross-compile on a linux machine to target This is using the I am no longer using this library in my applications, so I will be unable to assist much further. I cannot reproduce the issue @depado is reporting with regards to native compilation - when I run it natively it works fine. I did have to delete the entire
However, I think that is simply an issue with trying to install one version of golang over the top of an existing one, rather than installing to an empty directory. |
@robdimsdale Thanks for your report. I think the second error you're mentioning is not related here, looks like trouble with the Go install in generic. rice isn't using any C by default (only the embed-syso experiment does). |
I don't have a lot of free time at the moment, and didn't run into this issue myself yet. I hope to be able to fix soon. PR is also welcome and would be very much appreciated. |
@GeertJohan correct, the second part of my comment was intended to clarify that I could not reproduce the issue as described by @depado - that I can only observe this when cross-compiling and that native compilation seems to work fine. As I mentioned, I switched to a different library (https://github.com/mjibson/esc) so from my perspective I'm happy for you to close the issue. |
@robdimsdale I have no trouble working with rice on the same machine. Compilation works fine, I can execute and such. But when I move the binary to another machine, then the issue shows up. Although appending via |
Ah yes, I must have missed this in @robdimsdale's post, sorry. You must append the the binary with the rice boxes before moving the binary to a different machine. Without appended files, rice will try to look for the files on the filesystem. If it cannot find them the @kwo and @cortesi how did you reproduce? Did you append before moving the binary? |
Isn't generating the go source files with |
@depado yes. If you're using that you should be fine. |
@depado In your panic I see you're trying to load the box during init. The embedded go files need an init too. Your init might be too soon (the box was not registered yet to the internal box register used by embedding). |
package main
import (
"flag"
"html/template"
"log"
"math/rand"
"net/http"
"net/http/pprof"
"strconv"
"time"
"github.com/GeertJohan/go.rice"
"github.com/zenazn/goji"
"github.com/zenazn/goji/web"
)
var templateBox = rice.MustFindBox("templates")
var staticBox = rice.MustFindBox("assets") I "Find" the boxes right at the start of my program. Is that what you mean ? Where should I place the |
You can have the |
Alright ! It fixed the issue for me, although it was just a programming error. Thanks a lot for your reactivity. |
@GeertJohan I don't have time to track this down at the moment, but I'm seeing the issue using embedded boxes, using a super-simple test program like this: func main() {
fmt.Printf("%v", rice.MustFindBox("./static"))
} To trigger the issue, I start on OSX, run "rice embed-go", and then cross-compile the binary for linux:
Running the binary on Linux, I see:
The exact same code works compiled locally for OSX. If I change the relative path "./static" to just "static", and re-run "rice embed-go", the code works on both platforms even with cross-compilation. I haven't confirmed that this works when compiled on Linux for Linux, so it may be a platform issue. Geert, if you can't track this down, I might be able to make time a bit later in the week to look at this in more detail. |
I think this particular issue now spans a number of different problems, and should be split up. I've just reported #67 with an associated pull request that fixes my issue, and might also fix some of what other people are seeing here. @robdimsdale: I'm unable to reproduce the cross compilation issue using your test code. Using the current master, "rice go-embed", cross compilation, and the running the binary in Linux with docker works. If you'd like to pursue this, please let me know, and I'll submit a Dockerfile and test script to your repo so we can make sure we're on the same page. |
@cortesi thanks for the offer. I am not working on this - no need to pursue. I'm glad it appears to be working though. @GeertJohan I agree with @cortesi that this issue is overloaded. My original issue appears solved, so from my perspective I am happy for you to close the issue. |
Closing this issue. If anyone feels their problem hasn't been resolved yet please open a new issue. |
When cross compiling using go 1.5 the resultant binary fails with:
This is true for multiple target architectures. I've verified that it works fine when compiling natively on multiple targets.
I'm using commit
ada95a01c963696fb73320ee662195af68be81ae
of this repository; this is the tip of master branch.I'm cross compiling with e.g.
GOOS=linux GOARCH=arm GOARM=7 go build main.go
Do you know what would be different about cross compiling vs compiling natively?
The text was updated successfully, but these errors were encountered: