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

[BUG]: cannot use generic type ristretto.Cache[K z.Key, V any] without instantiation #394

Open
poornachandratejasvi opened this issue Sep 18, 2024 · 7 comments
Assignees
Labels
kind/bug Something is broken.

Comments

@poornachandratejasvi
Copy link

What version of Ristretto are you using?

github.com/ory/viper

/root/go/pkg/mod/github.com/ory/viper@v1.7.5/viper.go:224:16: cannot use generic type ristretto.Cache[K z.Key, V any] without instantiation
getting below error post ristretto go package is updated to v1.0.0 from github.com/dgraph-io/ristretto v0.1.1

/root/go/pkg/mod/github.com/ory/viper@v1.7.5/viper.go:253:17: implicit function instantiation requires go1.18 or later (-lang was set to go1.12; check go.mod)
/root/go/pkg/mod/github.com/ory/viper@v1.7.5/viper.go:253:37: cannot use generic type ristretto.Config[K z.Key, V any] without instantiation
/root/go/pkg/mod/github.com/ory/viper@v1.7.5/viper.go:307:15: cannot use generic type ristretto.Cache[K z.Key, V any] without instantiation
/root/go/pkg/mod/github.com/ory/viper@v1.7.5/viper.go:307:36: cannot use generic type ristretto.Config[K z.Key, V any] without instantiation

What version of Go are you using?

1.22.6

Have you tried reproducing the issue with the latest release?

None

What is the hardware spec (RAM, CPU, OS)?

docker arm64

What steps will reproduce the bug?

any package who is using this package will get the issue

github.com/ory/go-acc

Expected behavior and actual result.

No response

Additional information

No response

@poornachandratejasvi poornachandratejasvi added the kind/bug Something is broken. label Sep 18, 2024
@jney
Copy link

jney commented Sep 18, 2024

Same issue using badger and upgrading:

- github.com/dgraph-io/ristretto v0.1.1 // indirect
+ github.com/dgraph-io/ristretto v1.0.0 // indirect

@OK93-01-18
Copy link

i have same issue on go v1.23.1

@asyslinux
Copy link

  • same issue

@Hamper
Copy link

Hamper commented Sep 19, 2024

The repository at github.com/ory/viper was archived 4 years ago. The current version of github.com/spf13/viper does not use ristretto.

Ristretto v1 uses generics and may not be compatible with packages that require ristretto without generics. You can try using ristretto v0 (the latest version is v0.2.0).

@jney
Copy link

jney commented Sep 19, 2024

@Hamper I don't use viper, but I use badger

MalinAhlberg added a commit to neicnordic/sensitive-data-archive that referenced this issue Sep 19, 2024
@Hamper
Copy link

Hamper commented Sep 19, 2024

Badger supports ristretto with generics starting from v4.3.0. Versions v4.2.0 and below do not support generics in the call to newCache and require ristretto v0

MalinAhlberg added a commit to neicnordic/sensitive-data-archive that referenced this issue Sep 20, 2024
MalinAhlberg added a commit to neicnordic/sensitive-data-archive that referenced this issue Sep 20, 2024
MalinAhlberg added a commit to neicnordic/sensitive-data-archive that referenced this issue Sep 20, 2024
@jchappelow
Copy link

The related issue in the badger repo: dgraph-io/badger#2005

This is tricky to resolve if you have an app with direct or transitive dependencies such that you include both badger/v3 and badger/v4. It feels like the only way to resolve this is if ristretto were to have gone from v0.x to v2 so that the module import path for each version of ristretto would be different (two different requires for the incompatible ristrettos), allowing badger/v3 to keep using v0.1 or v0.2 while badger/v3 could use ristretto/v2. Right now using badger/v4 hoist the ristretto requirement and breaks badger/v3.

I'm in a situation where our dependencies are forcing the ristretto version up, thus breaking our badger/v3 import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something is broken.
Development

No branches or pull requests

7 participants