Comments (4)
Hi, I had a look at this issue, and found out that it only happens if you run go mod init
before dagger mod init
, and if you have go > 1.21.3 locally. because go mod init
will create a go.mod
file with your local version of go (say 1.21.5), but when running dagger mod init
, it will run in a container with go 1.21.3 in local
mode, so it won't be able to do anything
the "quick" fix is to avoid running go mod init
, because dagger mod init
will take care of creating the go.mod
file anyway if it doesn't exists, and it will have the "right" go version (the one used by the dagger container)
the real fix is to ensure that the container is properly configured, with GOTOOLCHAIN=auto
. by default, the official go images have GOTOOLCHAIN=local
, which is ok because you want a controlled env. but in the dagger context, I believe it makes sense to be able to run the code if even it requires a newer version of go. just adding the GOTOOLCHAIN=auto
env to the container will do it:
$ echo $(docker run --rm -it golang:1.21.3 go env GOTOOLCHAIN)
local
$ echo $(docker run --rm -it -e GOTOOLCHAIN=auto golang:1.21.3 go env GOTOOLCHAIN)
auto
from dagger.
@samalba To clarify, you are allowed to have an existing go.mod and that's handled in general (there's integ test coverage for this). The problem here is that Go in 1.21 started creating go.mod
by default with directives like go 1.21.5
which result in these errors if there's a mismatch between the version of go being used by the engine the and the version of go you used to run go mod init
on your host.
So you don't get this error if your host is using go 1.21.3 (what the engine is currently on).
You can easily fix this right now by just editing the go.mod
created by go mod init
to just say go 1.21
rather than go 1.21.5
.
I'm sure there's got to be some better way of handling this in general since there's no way we actually care about the patch version of Go.
from dagger.
Thanks for the context. Maybe a good way to solve this is to detect if there is a minor version in go.mod and hint the user to remove it. If I learned this from the output, I would have done this manually to fix it.
from dagger.
As a note, Nipuna mentioned that he also needed to make the same adjustment to his go.work
file to remove the minor version in order for this to work fully
from dagger.
Related Issues (20)
- ✨ Support --mount=type=ssh with dockerBuild()
- 🐞 grpc: received message larger than max
- Support `Socket` args from the CLI HOT 1
- Zenith: Confusion over what "optional" means HOT 2
- 🐞 Using a repository as both a module ref and a `git://` arg leads to a timeout HOT 1
- `TestModuleCodegenOnDepChange` is flaky HOT 1
- 🐞 "Escapes Context" error confusing for end users HOT 1
- ✨ functions: support enum argument types
- 🖐️ Call modules in private repositories HOT 1
- Restore auto-creation of `.gitignore` file when calling `dagger mod init` HOT 2
- CLI: support passing sensitive `Directories` HOT 1
- 🐞 Trying to init a module named `service` fails
- 🐞 Dagger Functions: Progress output not formatted correctly on Windows
- Codegen error when installing certain dependencies in a Go module HOT 1
- Panic in `terminal` if no args set HOT 1
- Support list of lists arguments in dagger call HOT 1
- 🐞 `no space left on device` HOT 3
- ✨ Option to ignore hosts `.docker/config` HOT 2
- 🖐️ Need help to build Dockerfile with Dagger Functions v0.10
- 🐞 v0.10.1 Client panic when with Pipeline HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dagger.