Closed fredrikaverpil closed 4 months ago
Hey @fredrikaverpil! 😄 Great to cross paths with you again here in the digital wilderness! 🌐👾 I'm diving into your issue now and will be back with you in a jiffy with some insights. Stay tuned! 🚀
To add to this confusion;
❯ /Users/fredrik/.pkgx/go.dev/v1.21.5/bin/go version
go version go1.22.1 darwin/arm64
❯ cd ..
env -go.dev@1.21.5 -git-scm.org
❯ /Users/fredrik/.pkgx/go.dev/v1.21.5/bin/go version
go version go1.21.5 darwin/arm64
I'm just super confused at this point.
Based on the information you've provided, it seems like there might be an issue with how pkgx is handling the version constraints for Go. The parse_deps
function in pkgx processes the dependencies specified in the pkgx.yaml
file and has a specific behavior for handling version constraints. If the version constraint ends with @latest
, it is replaced with *
, which means any version (the latest available version). However, this might not be the direct cause if you're specifying a version other than @latest
.
The real issue could be related to how the parse_deps
function or the validatePackageRequirement
function from pkgx/hooks/usePantry.ts
validates and processes the specified version constraints. If the version constraint specified in the pkgx.yaml
file doesn't match the expected format or if there's an issue in how these functions interpret the version constraint, pkgx might end up fetching an incorrect version.
To resolve this issue, ensure that the version constraint specified in the pkgx.yaml
file strictly follows the expected format. If you're specifying a version directly and still facing issues, it might be worth investigating the validatePackageRequirement
function or how the parse_deps
function processes the version constraints.
If the problem persists, it might be a bug in the version handling logic of pkgx. In that case, providing a detailed description of the issue, including the specific version constraint that's causing problems, to the pkgx maintainers could help in identifying and resolving the issue.
You can find more information about this in the src/utils/devenv.ts file in the pkgx repository.
Hey @fredrikaverpil , I'm unable to reproduce this error. Please try removing the entire .pkgx/
directory and try again
Hey @michaelessiet, I just did this;
brew uninstall pkgx
rm -rf ~/.pkgx
rm -rf "${XDG_CACHE_HOME:-$HOME/Library/Caches}/pkgx"
rm -rf "${XDG_DATA_HOME:-$HOME/Library/Application Support}"/pkgx
The problem still persists and it's driving me nuts at this point;
❯ brew install pkgx
...
❯ pkgx go@1.21 version
✓ ~/.pkgx/curl.se/ca-certs/v2023.12.12
✓ ~/.pkgx/openssl.org/v1.1.1w
✓ ~/.pkgx/go.dev/v1.21.8
go version go1.21.8 darwin/arm64 <--- 👍
❯ ll ~/.pkgx/go.dev
Permissions Size User Group Date Modified Name
lrwxr-xr-x@ - fredrik staff 7 Mar 17:35 v* -> v1.21.8
lrwxr-xr-x@ - fredrik staff 7 Mar 17:35 v1 -> v1.21.8
lrwxr-xr-x@ - fredrik staff 7 Mar 17:35 v1.21 -> v1.21.8
drwxr-xr-x@ - fredrik staff 7 Mar 17:35 v1.21.8
❯ cd myproj
❯ pkgx go@1.21 version
go version go1.22.1 darwin/arm64 <--- 🤯
I just added this go file:
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println("Go version:", runtime.Version())
}
Then I run it a few different ways:
❯ ~/.pkgx/go.dev/v1.21.8/bin/go run book-service/main.go
Go version: go1.21.8 <--- 👍
❯ cd myproj
❯ ~/.pkgx/go.dev/v1.21.8/bin/go run main.go
Go version: go1.22.1 <--- 🤯
And here, I did not have dev
enabled!!! What the heck?!!!
Problem solved, in the project's go.mod
I apparently had toolchain go1.22.1
which causes go itself to download a new version (which I already had cached) and use that.
If setting the toolchain to a non-existing version, like toolchain go1.26.1
, I get this:
❯ /Users/fredrik/.pkgx/go.dev/v1.21.8/bin/go version
go: downloading go1.26.1 (darwin/arm64)
go: download go1.26.1 for darwin/arm64: toolchain not available
This was such a mindfuck. Sorry for the noise.
in general, i like how good modern languages (specifically go
and rust
) are at managing themselves. but, once in a while, there's a very subtle foot-gun in the mix. this was a good find.
I get why they do this, but really they should leave such stuff to tools like us. They are the wrong layer to do this sort of thing and by doing it they are adding complexity for everyone as well as burden for themselves to maintain.
I've defined a project to use go 1.21 via
pkgx.yaml
, but pkgx still uses go 1.22.I ran
rm -rf /Users/fredrik/.pkgx/go.dev
and re-downloaded it all, but it ended up doing the same thing. I also tried adding a patch version inpkgx.yaml
:My starship prompt also shows the 1.22 version no matter what:
Furthermore;
What could be wrong?