-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
Unable to clean modules installed by xcaddy build #102
Comments
The flag |
Why do you need write access to the modules? 🤔 What is the |
The command I am executing is
which works just fine for the first time. It fails in consequent runs because the build system must clean the files before it can be re-compiled but it fails because go installs modules as RO which causes rm to bail out since my user has no root privileges. |
There is also another related issue with xcaddy is that Yocto trims the produced binaries automatically but xcaddy enforces this by adding flags builder.go
so I will need to add the following exception to my recipe
This could be avoided if there would be an environment variable to pass the build flags to xcaddy which would allow the user to control the behavior of compilation in contrast to hardcoding 'em. |
Sorry, I don't understand. Go doesn't delete files to re-compile a second time. This sounds like more of a problem with whatever Yocto is, than xcaddy or Go. 🤔 |
Yocto is a distributed build-system to compile Linux kernels which are used by millions of Embedded Linux devices. Yes, you are correct: Go does not delete files during recompiling, but a build system might.
No, this is not an issue with Go or Yocto. Let me explain. Go installs modules with read-only access (by default) because Golang was developed by Google who uses monolithic repository structure which can benefit from using global module path. The global module install cannot be used for distributed build-systems because modules need to declare their own dependencies which would blow up in disk space. Fortunately, this has been addressed by Golang maintainers a while ago by introducing flag Here is background information and discussion related to why the flag is useful golang/go#27161. |
In Caddy-speak, what I need is something like this
which allows me to redefine build arguments from our build system. I have already patched this in our build but I decided to bring this up because the caddy community would benefit from it. |
Oh, I see what you mean now. Thanks for the explanation. Yeah, that env var seems like a good way to work around it, I guess. (I'm way less picky about xcaddy than I am about caddy anyway.) Want to submit a PR? |
Sure, the patch needs a bit of polishing but I should be able to submit it by next week. |
Add environment variable XCADDY_GOBUILDFLAGS to override default build arguments from environment (caddyserver#102). To support flags with variable arguments Unix-style quoting is supported.
I am not sure what is your process for contributing so I created a fork for the pull request. You can comment on the PR if any changes are needed. |
Perfect, thanks @akeskimo ! |
Add environment variable XCADDY_GO_BUILD_FLAGS to override default build arguments from environment (caddyserver#102). To support flags with variable arguments Unix-style quoting is supported.
Add environment variable XCADDY_GO_BUILD_FLAGS to override default build arguments from environment (#102). To support flags with variable arguments Unix-style quoting is supported.
Commit 47f9ded is not sufficient alone to ensure that all go modules are installed with write bit set because go mod and go get installs modules of other modules with read-only access. The environment variable sets -modcacherw to both go get and go mod commands to ensure that the build/pkg/mod directory does not have sub directories that are read-only for the current user.
Commit 47f9ded is not sufficient alone to ensure that all go modules are installed with write bit set because go mod and go get installs modules of other modules with read-only access. The environment variable sets -modcacherw to both go get and go mod commands to ensure that the build/pkg/mod directory does not have sub directories that are read-only for the current user.
Commit 47f9ded is not sufficient alone to ensure that all go modules are installed with write bit set because go mod and go get installs modules of other modules with read-only access. If set, the environment variable sets -modcacherw to ensure that also module sub directories have write-access to the current user.
Commit 47f9ded is not sufficient alone to ensure that all go modules are installed with write bit set because 'go mod' or 'go get' might install submodules of other modules as read-only. If set, the environment variable appends '-modcacherw' to go mod and go get to ensure that submodules of other modules have write access.
Hi @mholt, We still have the problem that go modules that are pulled in by go get or go mod might be read-only which we are unable to clean from our build environment. I have added another pull request which should fully resolve this issue. We currently have this patch applied in our build system (Yocto) but here it is if you would like to have this in upstream, as well. |
Commit 47f9ded is not sufficient alone to ensure that all go modules are installed with write bit set because 'go mod' or 'go get' might install modules as read-only, too. If set, the environment variable is appended for the other go commands that support build flags.
Commit 47f9ded is not sufficient alone to ensure that all go modules are installed with write bit set because 'go mod' or 'go get' might install modules as read-only, too. If set, the environment variable is appended for the other go commands that support build flags.
* Extend XCADDY_GO_BUILD_FLAGS usage (#102) Commit 47f9ded is not sufficient alone to ensure that all go modules are installed with write bit set because 'go mod' or 'go get' might install modules as read-only, too. If set, the environment variable is appended for the other go commands that support build flags. * Make running 'go' implicit for build environment The method newCommand runs only go commands so let's make command 'go' implicit and rename it to make it more verbose.
While building with xcaddy with Yocto I am getting the following error
ERROR: Command '['rm', '-rf', '/work/yocto/build/tmp/work/aarch64-poky-linux/caddy/2.4.6-r0/build/pkg']' returned non-zero exit status 1.
In our build machine, we need write access to modules directory in order to re-compile the project but go modules are installed with read access, only. This can be fixed by executing go build with flag '-modcacherw` but xcaddy does not support passing custom flags from environment.
The text was updated successfully, but these errors were encountered: