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

consul/api 版本冲突无法使用 #101

Closed
baipangbai opened this issue Jun 9, 2022 · 16 comments
Closed

consul/api 版本冲突无法使用 #101

baipangbai opened this issue Jun 9, 2022 · 16 comments
Assignees

Comments

@baipangbai
Copy link

自己项目中有用到consul版本为v1.4.3,holmes中的consul/api的版本为v1.3.0

去看holmes代码中其实并没用用到consul,去追依赖发现依赖层级如下

mosn.io/pkg-> github.com/dubbogo/gost -> github.com/prometheus/client_golang  -> github.com/prometheus/common ->  github.com/go-kit/kit -> consul/api v1.3.0

本身holmes中并没有任何consul的依赖,即使是使用的日志库holmes.io/pkg/log的功能中,也没有用到consul/api的功能。

不知是否可以把moson.io/pkg/log中有关consul的依赖去除,要不可惜了这么优秀的开源不能使用。

@nejisama
Copy link
Contributor

nejisama commented Jun 9, 2022

mosn.io/pkg/log中也没有依赖consul 这个库啊?用这个库的看了下是dubbogo的间接依赖,只要引用这部分,直接用你项目里需要的版本就可以了吧?我理解应该没有冲突的?

@nejisama
Copy link
Contributor

nejisama commented Jun 9, 2022

只要你的项目里不依赖 github.com/dubbogo/gost 应该就可以用你需要的版本了吧?

@baipangbai
Copy link
Author

会报这个错,是mod,会报错,不知道找哪个版本,即使我指定自己用的consul 包是1.4.3。另一个consul/api@v1.3.0,是mosn.io/pkg/log中的库,在go.sum中能找到 https://github.com/mosn/holmes/blob/master/go.sum#L199

consul_registry.go:7:2: ambiguous import: found package github.com/hashicorp/consul/api in multiple modules:
	github.com/hashicorp/consul v1.4.3 (/root/go/pkg/mod/github.com/hashicorp/consul@v1.4.3/api)
	github.com/hashicorp/consul/api v1.3.0 (/root/go/pkg/mod/github.com/hashicorp/consul/api@v1.3.0)

@baipangbai
Copy link
Author

baipangbai commented Jun 9, 2022

只要你的项目里不依赖 github.com/dubbogo/gost 应该就可以用你需要的版本了吧?

项目里面没有依赖gost,我理解是mosn.io/pkg里面附带的包,有用到gost的包(https://github.com/mosn/holmes/blob/master/go.sum#L85)

consul/api的间接引用sum位置:
https://github.com/mosn/holmes/blob/master/go.sum#L199

@baipangbai
Copy link
Author

baipangbai commented Jun 9, 2022

log是没有依赖,但是log所在的pkg包中包含了.

这个里面包含了 mosn.io/pkg v0.0.0-20211217101631-d914102d1baf

@baipangbai
Copy link
Author

我的理解是 :

mosn.io/holmes 中用到了 log,其中的log来源是mosn.io/pkg v0.0.0-20211217101631-d914102d1baf。

这个pkg中有其他的包,并没有被holmes所用(holmes只用到了其中的log),比如dubbogo,但是在pkg里面,依然会被加载,从而间接加载进holmes。

所以导致了consul/api的版本冲突。

@nejisama
Copy link
Contributor

nejisama commented Jun 9, 2022

module mosn.io/test

go 1.14

require (
	github.com/hashicorp/consul/api v1.12.0
	mosn.io/pkg v1.0.0
)

我自己简单写了一个demo 指定的是更新的版本,因为我只用了pkg/log 并没有用pkg下的dubbo 所以没有报冲突

@nejisama
Copy link
Contributor

nejisama commented Jun 9, 2022

go.sum里的内容可能有很多,但是并不会影响实际的使用才对

@nejisama
Copy link
Contributor

nejisama commented Jun 9, 2022

我指定了一下低版本(v1.4.3) 是有问题,我看了下 是因为他这个低版本还没有按照规范接入go.mod导致的

@baipangbai
Copy link
Author

https://github.com/baipangbai/selfmotion

image

确实1.4.3会有问题,所以建议是升级还是可以把pkg中的相关依赖给去掉呢

@nejisama
Copy link
Contributor

nejisama commented Jun 9, 2022

在低版本 github.com/hashicorp/consul 是一个库,对应的github.com/hashicorp/consul/api 是包含在里面的
但是 新版本下 github.com/hashicorp/consul/api 是一个独立的版本,所以这里识别上会有冲突

@nejisama
Copy link
Contributor

nejisama commented Jun 9, 2022

https://github.com/baipangbai/selfmotion

image

确实1.4.3会有问题,所以建议是升级还是可以把pkg中的相关依赖给去掉呢

pkg里的registry/dubbo是有使用的,不可能去掉

@baipangbai
Copy link
Author

github.com/hashicorp/consul 是一个库,对应的github.com/hashicorp/consul/api 是包含在里面的
但是 新版本下 github.com/hashicorp/consul/api 是一个独立的版本,所以这里识别上会有冲突

明白了,感谢回答~♥️

@baipangbai baipangbai closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2022
@nejisama
Copy link
Contributor

nejisama commented Jun 9, 2022

github.com/hashicorp/consul 是一个库,对应的github.com/hashicorp/consul/api 是包含在里面的
但是 新版本下 github.com/hashicorp/consul/api 是一个独立的版本,所以这里识别上会有冲突

明白了,感谢回答~♥️

我看了下 https://github.com/hashicorp/consul/tree/api/v1.3.0/api 这个库专门为1.3.0 的api加了一个go.mod 但是1.4.3 这个没有。。所以导致这里识别冲突了

@baipangbai
Copy link
Author

如果有底层依赖consul 导致冲突,且底层涉及较多,不方便都升级解决方案~

replace github.com/hashicorp/consul => github.com/hashicorp/consul v1.5.0 (hashicorp/consul#6019
)

@nejisama
Copy link
Contributor

如果有底层依赖consul 导致冲突,且底层涉及较多,不方便都升级解决方案~

replace github.com/hashicorp/consul => github.com/hashicorp/consul v1.5.0 (hashicorp/consul#6019 )

这里我想了一下,可以考虑把pkg里的部分内容 单独组织一个go.mod 可能可以一定程度避免这种问题,但是不能彻底的解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants