flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.3k stars 27.52k forks source link

flutter_plugin_tools can't find java from PATH #86675

Closed gaaclarke closed 3 years ago

gaaclarke commented 3 years ago

example failure: https://github.com/flutter/packages/pull/398/checks?check_run_id=3107661154

Running command: "flutter format ../third_party/packages/bsdiff/example/main.dart ../third_party/packages/bsdiff/lib/bsdiff.dart ../third_party/packages/bsdiff/test/bsdiff_test.dart ../third_party/packages/cupertino_icons/lib/cupertino_icons.dart animations/example/lib/container_transition.dart animations/example/lib/fade_scale_transition.dart animations/example/lib/fade_through_transition.dart animations/example/lib/main.dart animations/example/lib/shared_axis_transition.dart animations/lib/animations.dart animations/lib/src/fade_scale_transition.dart animations/lib/src/fade_through_transition.dart animations/lib/src/modal.dart animations/lib/src/open_container.dart animations/lib/src/page_transition_switcher.dart animations/lib/src/shared_axis_transition.dart animations/test/dual_transition_builder_test.dart animations/test/fade_scale_transition_test.dart animations/test/fade_through_transition_test.dart animations/test/modal_test.dart animations/test/open_container_test.dart animations/test/page_transition_switcher_test.dart animations/test/shared_axis_transition_test.dart cross_file/lib/cross_file.dart cross_file/lib/src/types/base.dart cross_file/lib/src/types/html.dart cross_file/lib/src/types/interface.dart cross_file/lib/src/types/io.dart cross_file/lib/src/web_helpers/web_helpers.dart cross_file/lib/src/x_file.dart cross_file/test/x_file_html_test.dart cross_file/test/x_file_io_test.dart css_colors/lib/css_colors.dart extension_google_sign_in_as_googleapis_auth/example/lib/main.dart extension_google_sign_in_as_googleapis_auth/lib/extension_google_sign_in_as_googleapis_auth.dart extension_google_sign_in_as_googleapis_auth/test/extension_google_sign_in_as_googleapis_auth_test.dart flutter_image/lib/flutter_image.dart flutter_image/lib/network.dart flutter_image/test/network_test.dart flutter_image/test/network_test_server.dart flutter_lints/example/lib/main.dart flutter_markdown/example/lib/demos/basic_markdown_demo.dart flutter_markdown/example/lib/demos/centered_header_demo.dart flutter_markdown/example/lib/demos/extended_emoji_demo.dart flutter_markdown/example/lib/demos/minimal_markdown_demo.dart flutter_markdown/example/lib/demos/original_demo.dart flutter_markdown/example/lib/demos/subscript_syntax_demo.dart flutter_markdown/example/lib/demos/wrap_alignment_demo.dart flutter_markdown/example/lib/main.dart flutter_markdown/example/lib/screens/demo_card.dart flutter_markdown/example/lib/screens/demo_screen.dart flutter_markdown/example/lib/screens/home_screen.dart flutter_markdown/example/lib/shared/dropdown_menu.dart flutter_markdown/example/lib/shared/markdown_demo_widget.dart flutter_markdown/example/lib/shared/markdown_extensions.dart flutter_markdown/lib/flutter_markdown.dart flutter_markdown/lib/src/_functions_io.dart flutter_markdown/lib/src/_functions_web.dart flutter_markdown/lib/src/builder.dart flutter_markdown/lib/src/style_sheet.dart flutter_markdown/lib/src/widget.dart flutter_markdown/test/all.dart flutter_markdown/test/blockquote_test.dart flutter_markdown/test/custom_syntax_test.dart flutter_markdown/test/emphasis_test.dart flutter_markdown/test/header_test.dart flutter_markdown/test/horizontal_rule_test.dart flutter_markdown/test/html_test.dart flutter_markdown/test/image_test.dart flutter_markdown/test/image_test_mocks.dart flutter_markdown/test/line_break_test.dart flutter_markdown/test/link_test.dart flutter_markdown/test/list_test.dart flutter_markdown/test/scrollable_test.dart flutter_markdown/test/style_sheet_test.dart flutter_markdown/test/table_test.dart flutter_markdown/test/text_alignment_test.dart flutter_markdown/test/text_scale_factor_test.dart flutter_markdown/test/text_test.dart flutter_markdown/test/uri_test.dart flutter_markdown/test/utils.dart flutter_template_images/lib/flutter_template_images.dart fuchsia_ctl/bin/main.dart fuchsia_ctl/lib/fuchsia_ctl.dart fuchsia_ctl/lib/src/amber_ctl.dart fuchsia_ctl/lib/src/command_line.dart fuchsia_ctl/lib/src/dev_finder.dart fuchsia_ctl/lib/src/emulator.dart fuchsia_ctl/lib/src/image_paver.dart fuchsia_ctl/lib/src/logger.dart fuchsia_ctl/lib/src/operation_result.dart fuchsia_ctl/lib/src/package_server.dart fuchsia_ctl/lib/src/ssh_client.dart fuchsia_ctl/lib/src/ssh_key_manager.dart fuchsia_ctl/lib/src/tar.dart fuchsia_ctl/test/command_line_test.dart fuchsia_ctl/test/dev_finder_test.dart fuchsia_ctl/test/emulator_test.dart fuchsia_ctl/test/fakes.dart fuchsia_ctl/test/image_paver_test.dart fuchsia_ctl/test/logger_test.dart fuchsia_ctl/test/package_server_test.dart fuchsia_ctl/test/ssh_client_test.dart fuchsia_ctl/test/ssh_key_manager_test.dart fuchsia_ctl/test/tar_test.dart imitation_game/bin/imitation_game.dart imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart imitation_game/lib/imitation_game.dart imitation_game/lib/readme_template.dart metrics_center/lib/metrics_center.dart metrics_center/lib/src/common.dart metrics_center/lib/src/constants.dart metrics_center/lib/src/flutter.dart metrics_center/lib/src/gcs_lock.dart metrics_center/lib/src/google_benchmark.dart metrics_center/lib/src/skiaperf.dart metrics_center/test/common.dart metrics_center/test/flutter_test.dart metrics_center/test/gcs_lock_test.dart metrics_center/test/google_benchmark_test.dart metrics_center/test/skiaperf_test.dart metrics_center/test/utility.dart multicast_dns/example/main.dart multicast_dns/example/mdns_resolve.dart multicast_dns/example/mdns_sd.dart multicast_dns/lib/multicast_dns.dart multicast_dns/lib/src/constants.dart multicast_dns/lib/src/lookup_resolver.dart multicast_dns/lib/src/native_protocol_client.dart multicast_dns/lib/src/packet.dart multicast_dns/lib/src/resource_record.dart multicast_dns/test/client_test.dart multicast_dns/test/decode_test.dart multicast_dns/test/lookup_resolver_test.dart multicast_dns/test/resource_record_cache_test.dart multicast_dns/tool/packet_gen.dart palette_generator/example/lib/main.dart palette_generator/lib/palette_generator.dart palette_generator/test/palette_generator_test.dart pigeon/bin/pigeon.dart pigeon/e2e_tests/test_objc/lib/dartle.dart pigeon/e2e_tests/test_objc/lib/main.dart pigeon/e2e_tests/test_objc/test_driver/e2e_test.dart pigeon/e2e_tests/test_objc/test_driver/widget_test.dart pigeon/lib/ast.dart pigeon/lib/dart_generator.dart pigeon/lib/generator_tools.dart pigeon/lib/java_generator.dart pigeon/lib/objc_generator.dart pigeon/lib/pigeon.dart pigeon/lib/pigeon_cl.dart pigeon/lib/pigeon_lib.dart pigeon/mock_handler_tester/lib/main.dart pigeon/mock_handler_tester/test/message.dart pigeon/mock_handler_tester/test/test.dart pigeon/mock_handler_tester/test/widget_test.dart pigeon/pigeons/all_datatypes.dart pigeon/pigeons/android_unittests.dart pigeon/pigeons/async_handlers.dart pigeon/pigeons/enum.dart pigeon/pigeons/flutter_unittests.dart pigeon/pigeons/host2flutter.dart pigeon/pigeons/java_double_host_api.dart pigeon/pigeons/list.dart pigeon/pigeons/message.dart pigeon/pigeons/void_arg_flutter.dart pigeon/pigeons/void_arg_host.dart pigeon/pigeons/voidflutter.dart pigeon/pigeons/voidhost.dart pigeon/platform_tests/android_unit_tests/lib/main.dart pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart pigeon/platform_tests/flutter_null_safe_unit_tests/test/all_datatypes_test.dart pigeon/platform_tests/flutter_null_safe_unit_tests/test/all_datatypes_test.mocks.dart pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_safe_test.dart pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_safe_test.mocks.dart pigeon/platform_tests/ios_unit_tests/lib/main.dart pigeon/test/dart_generator_test.dart pigeon/test/generator_tools_test.dart pigeon/test/java_generator_test.dart pigeon/test/objc_generator_test.dart pigeon/test/pigeon_lib_test.dart pigeon/test/version_test.dart pointer_interceptor/example/integration_test/widget_test.dart pointer_interceptor/example/lib/main.dart pointer_interceptor/example/lib/src/shim/dart_ui.dart pointer_interceptor/example/lib/src/shim/dart_ui_fake.dart pointer_interceptor/example/lib/src/shim/dart_ui_real.dart pointer_interceptor/example/test_driver/integration_test.dart pointer_interceptor/lib/pointer_interceptor.dart pointer_interceptor/lib/src/mobile.dart pointer_interceptor/lib/src/shim/dart_ui.dart pointer_interceptor/lib/src/shim/dart_ui_fake.dart pointer_interceptor/lib/src/shim/dart_ui_real.dart pointer_interceptor/lib/src/web.dart pointer_interceptor/test/tests_exist_elsewhere_test.dart web_benchmarks/lib/client.dart web_benchmarks/lib/server.dart web_benchmarks/lib/src/benchmark_result.dart web_benchmarks/lib/src/browser.dart web_benchmarks/lib/src/common.dart web_benchmarks/lib/src/recorder.dart web_benchmarks/lib/src/runner.dart web_benchmarks/testing/test_app/lib/aboutpage.dart web_benchmarks/testing/test_app/lib/benchmarks/runner.dart web_benchmarks/testing/test_app/lib/homepage.dart web_benchmarks/testing/test_app/lib/main.dart web_benchmarks/testing/web_benchmarks_test.dart xdg_directories/lib/xdg_directories.dart xdg_directories/test/xdg_directories_test.dart" in /private/var/folders/sr/b58hwhtj0jbcf4r09zmg0wlc0000gn/T/cirrus-ci-build/packages Formatted pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart Formatted pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart Formatted web_benchmarks/lib/src/browser.dart Formatted 210 files (3 changed) in 2.02 seconds. �[31mUnable to run 'java'. Make sure that it is in your path, or provide a full path with --java.�[0m

cc @stuartmorgan

gaaclarke commented 3 years ago

The image being used is big-sur-xcode-12.4 https://github.com/flutter/packages/blob/8da24ab81e3354fc973ba6f319d9e2dfff27bc10/.cirrus.yml#L93

That hasn't changed recently and should have Android Studio (and by extension Java) installed.

gaaclarke commented 3 years ago

cc @fkorotkov

fkorotkov commented 3 years ago

It does have in on the PATH. Maybe your tests using a custom PATH?

https://cirrus-ci.com/task/4825465656442880?logs=main#L17

gaaclarke commented 3 years ago

It does have a custom PATH, but it references the existing PATH:

task:
  name: local_tests
  use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'
  osx_instance:
    image: big-sur-xcode-12.4
  env:
    PATH: $PATH:/usr/local/bin
    matrix:
      CHANNEL: "master"
      CHANNEL: "stable"
  << : *FLUTTER_UPGRADE_TEMPLATE
  clang_format_setup_script:
    - brew install clang-format
  build_script:
    - ./script/local_tests.sh

None of that has changed for us in the past 5 months. I was out for vacation 2 weeks and when I came back it was failing if that's any clue. I don't think anything else could have broken it other than some change to that yaml file.

gaaclarke commented 3 years ago

I guess any script between Cirrus and my script could be messing up the PATH, it seems like Cirrus should be good based on the test. Let me dig deeper.

gaaclarke commented 3 years ago

Java is being used successfully somewhere else from PATH, like here: https://github.com/gaaclarke/packages/blob/4d5e1d8f0766a62ccac1f8f6f609f3d0ef1ec2b4/packages/pigeon/run_tests.sh#L155:L155

This appears to be a bug with flutter format's ability to find java.

jmagman commented 3 years ago

As of 2.4.0-0.0.pre flutter format is pretty much directly just calling dart format https://github.com/flutter/flutter/pull/84273. The last master local_tests successful run was well past that on d3c3b891c9 https://cirrus-ci.com/task/5517917665099776?logs=upgrade_flutter#L535.

gaaclarke commented 3 years ago

Thanks @jmagman. That means the bug is probably in flutter_plugin_tools. The call to flutter format before the error is probably a red herring.

stuartmorgan commented 3 years ago

Thanks @jmagman. That means the bug is probably in flutter_plugin_tools. The call to flutter format before the error is probably a red herring.

That message is definitely from flutter_plugin_tools; I added it recently.

It's printed if java --version either fails to run at all, or exits with something other than 0. Perhaps that version of java doesn't handle --version, only -version? It works for me locally, but I have a totally different version of Java than what that bot is showing. I can do some debugging tomorrow morning.

stuartmorgan commented 3 years ago

Hm, something else is going on here as well though. I added that more recently than the last time I rolled the flutter/packages tool pin. Your run shows Activated flutter_plugin_tools 0.1.4., but that error message didn't exist until 0.4.0.

stuartmorgan commented 3 years ago

@gaaclarke The fact that this broke out of band is a bug in Pigeon:

https://github.com/flutter/packages/blob/66a6816b6eee1661470136da24650627460591c2/packages/pigeon/run_tests.sh#L295

This makes that test script behave unpredictably in the face of breaking changes in flutter_plugin_tools. All the other uses are pinned so this kind of thing doesn't happen, and would instead show up in a PR to update the tool pin.

stuartmorgan commented 3 years ago

Perhaps that version of java doesn't handle --version, only -version?

This is indeed the problem.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.