File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -85,10 +85,9 @@ At your option, under:
8585* Apache License, Version 2.0, (http://www.apache.org/licenses/LICENSE-2.0)
8686* MIT license (http://opensource.org/licenses/MIT)
8787
88- */
88+ */
8989
9090use std:: env;
91- use std:: error:: Error ;
9291use std:: path:: PathBuf ;
9392use std:: process:: Command ;
9493
@@ -190,10 +189,21 @@ fn do_locate_java_home() -> errors::Result<String> {
190189 }
191190
192191 let output = command. output ( ) . map_err ( |error| {
193- let message = format ! ( "Command '{}' is not found in the system PATH ({})" , command_str, error. description ( ) ) ;
192+ let message = format ! ( "Command '{}' is not found in the system PATH ({})" , command_str, error) ;
194193 errors:: JavaLocatorError :: new ( & message)
195194 } ) ?;
196- let java_exec_path = String :: from_utf8 ( output. stdout ) ?;
195+ let java_exec_path = String :: from_utf8 ( output. stdout )
196+ . map ( |jp| {
197+ let mut lines: Vec < & str > = jp. lines ( ) . collect ( ) ;
198+ if lines. len ( ) > 1 {
199+ println ! ( "WARNING: java_locator found {} possible java locations: {}. Using the last one." ,
200+ lines. len( ) ,
201+ lines. join( ", " ) ) ;
202+ lines. remove ( lines. len ( ) - 1 ) . to_string ( )
203+ } else {
204+ jp
205+ }
206+ } ) ?;
197207
198208 // Return early in case that the java executable is not found
199209 if java_exec_path. is_empty ( ) {
You can’t perform that action at this time.
0 commit comments