Dropsource / monarch

Monarch is a tool for building Flutter widgets in isolation. It makes it easy to build, test and debug complex UIs.
https://monarchapp.io
MIT License
433 stars 22 forks source link

bloc_test and monarch 3.0.0 cannot resolve dependencies #66

Closed PhilipHayes closed 1 year ago

PhilipHayes commented 1 year ago

I can't seem to get monarch 3.0.0 to work: I get dependency issues when I run monarch init.

Because test >=1.16.0-nullsafety.19 <1.16.6 depends on test_api 0.2.19 and test >=1.16.6 <1.17.10 depends on analyzer ^1.0.0, test >=1.16.0-nullsafety.19 <1.17.10 requires test_api 0.2.19 or analyzer ^1.0.0. And because test >=1.17.10 <1.20.0 depends on analyzer >=1.0.0 <3.0.0, test >=1.16.0-nullsafety.19 <1.20.0 requires test_api 0.2.19 or analyzer >=1.0.0 <3.0.0. And because test >=1.20.0 <1.21.2 depends on test_api 0.4.9 and test >=1.21.0 <1.21.6 depends on analyzer >=2.0.0 <5.0.0, test >=1.16.0-nullsafety.19 <1.21.6 requires test_api 0.2.19 or 0.4.9 or analyzer >=1.0.0 <5.0.0. And because test >=1.21.6 <1.21.7 depends on test_api 0.4.14 and test >=1.21.7 <1.22.0 depends on test_api 0.4.15, test >=1.16.0-nullsafety.19 <1.22.0 requires test_api 0.2.19 or 0.4.9 or 0.4.14 or 0.4.15 or analyzer >=1.0.0 <5.0.0. And because test >=1.22.0 <1.22.1 depends on test_api 0.4.16 and test >=1.22.1 <1.22.2 depends on test_api 0.4.17, test >=1.16.0-nullsafety.19 <1.22.2 requires test_api 0.2.19 or 0.4.9 or 0.4.14 or 0.4.15 or 0.4.16 or 0.4.17 or analyzer >=1.0.0 <5.0.0. And because test >=1.22.2 depends on test_api 0.4.18 and bloc_test >=8.0.0-nullsafety.5 depends on test ^1.16.0, bloc_test >=8.0.0-nullsafety.5 requires test_api 0.2.19 or 0.4.9 or 0.4.14 or 0.4.15 or 0.4.16 or 0.4.17 or 0.4.18 or analyzer >=1.0.0 <5.0.0. And because every version of flutter_test from sdk depends on test_api 0.4.12 and monarch 3.0.0 depends on analyzer ^5.2.0, one of bloc_test >=8.0.0-nullsafety.5 or flutter_test from sdk or monarch 3.0.0 must be false. And because monarch 3.0.0 depends on flutter_test from sdk and no versions of monarch match >3.0.0 <4.0.0, bloc_test >=8.0.0-nullsafety.5 is incompatible with monarch ^3.0.0. So, because your app depends on both bloc_test ^9.1.0 and monarch ^3.0.0, version solving failed. pub get failed (1; So, because your app depends on both bloc_test ^9.1.0 and monarch ^3.0.0, version solving failed.)

fertrig commented 1 year ago

I tried it and got the same error on the latest flutter stable version. There are many bloc_test dependency compatibility issues reported on the bloc repo:

You can find more if you run this query: https://github.com/felangel/bloc/issues?q=bloc_test+dependency

There is an incompatibility between the test_api version that bloc_test uses (via its test dependecy) and the test_api that the flutter sdk uses (via flutter_test). Currently, flutter_test uses test_api: 0.4.12 and bloc_test uses test: 1.16.0 which uses test_api: 0.2.19.

I added these dependency overrides and got flutter pub get to work. However, I don't know if you will run into any issues at runtime:

dependency_overrides:
  test: ^1.21.3
  test_api: 0.4.12

I think the overarching issue is that all flutter projects use flutter_test which uses a pinned version of test_api. If you add bloc_test to a flutter project then you add the dart test package, which may use a different pinned version of test_api that flutter_test uses.

Ideally, I think bloc should have a package to test blocs on flutter, something like bloc_flutter_test, this new package should use flutter_test instead of package test. I think that would take care of their dependency issues.

For now, you could move all your blocs to a dart project which doesn't depend on the flutter_sdk. Or try the dependency overrides above. Or wait for bloc_test to fix the issues I listed above. In any case, I think this is a bloc issue.

PhilipHayes commented 1 year ago

I think the dependency overrides would be the way to go for now since it's mainly for development. But I agree this looks like a bloc_test issue.

I compiled monarch myself after I changed anaylzer:^5.2.0 to analyzer: any

Not a fix, but something to get it to at least allow me to access my stories again. I went with the overrides and I'll submit an issue to bloc_test. Thank you for looking into this!