facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.96k stars 2.02k forks source link

[Error] Infer needs a working compilation command to run (javac fails) #864

Closed cldrn closed 6 years ago

cldrn commented 6 years ago

Hey,

I'm having trouble running infer on a project and I think this might be a bug. The project builds correctly without infer but it complains about javac not getting a valid flag from a file generated by infer.

Is this bug or how can I fix this to run infer on this project?

Thanks.

Infer version v0.13.1

infer-out/toplevel.log

[INFO] output of locale.getdefaultlocale(): ('en_US', 'UTF-8')
[INFO] encoding we chose in the end: UTF-8
[INFO] Running command /usr/local/Cellar/infer/0.13.1/lib/infer/infer/bin/../lib/python/infer.py --analyzer checkers -j 8 --project-root /Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a --out /Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/infer-out -- ./gradlew build
[INFO] Path to infer script /usr/local/Cellar/infer/0.13.1/lib/infer/infer/bin/../lib/python/infer.py (/usr/local/Cellar/infer/0.13.1/lib/infer/infer/lib/python/infer.py)
[INFO] Platform: Darwin-17.4.0-x86_64-i386-64bit
[INFO] PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/MacGPG2/bin:/tools:/platform-tools:/Users/cldrn/Library/Android/sdk/tools:/Users/cldrn/Library/Android/sdk/platform-tools
[INFO] SHELL=/bin/bash
[INFO] PWD=/Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a
[INFO] Running with:

------------------------------------------------------------
Gradle 3.5
------------------------------------------------------------

Build time:   2017-04-10 13:37:25 UTC
Revision:     b762622a185d59ce0cfc9cbc6ab5dd22469e18a6

Groovy:       2.4.10
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_152 (Oracle Corporation 25.152-b16)
OS:           Mac OS X 10.13.3 x86_64

$ ./gradlew clean && OCAMLRUNPARAM=b infer -- ./gradlew build

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/cldrn/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/cldrn/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/cldrn/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

:clean
:ResideMenu:clean
:app:clean
:volley:clean

BUILD SUCCESSFUL

Total time: 2.376 secs
Capturing in gradle mode...
Running and capturing gradle compilation...
13:51:25.125 [ERROR] [system.err] Note: Some input files use or override a deprecated API.
13:51:25.125 [ERROR] [system.err] Note: Recompile with -Xlint:deprecation for details.
13:51:25.353 [ERROR] [system.err] Note: Some input files use or override a deprecated API.
13:51:25.353 [ERROR] [system.err] Note: Recompile with -Xlint:deprecation for details.
13:51:26.312 [ERROR] [system.err] Note: Some input files use or override a deprecated API.
13:51:26.312 [ERROR] [system.err] Note: Recompile with -Xlint:deprecation for details.
13:51:26.312 [ERROR] [system.err] Note: /Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/volley/src/main/java/com/android/volley/RequestQueue.java uses unchecked or unsafe operations.
13:51:26.313 [ERROR] [system.err] Note: Recompile with -Xlint:unchecked for details.
13:51:37.853 [ERROR] [system.err] Note: Some input files use or override a deprecated API.
13:51:37.853 [ERROR] [system.err] Note: Recompile with -Xlint:deprecation for details.
13:51:37.854 [ERROR] [system.err] Note: Some input files use unchecked or unsafe operations.
13:51:37.854 [ERROR] [system.err] Note: Recompile with -Xlint:unchecked for details.
13:52:14.807 [ERROR] [system.err] Note: Some input files use or override a deprecated API.
13:52:14.807 [ERROR] [system.err] Note: Recompile with -Xlint:deprecation for details.
13:52:14.807 [ERROR] [system.err] Note: Some input files use unchecked or unsafe operations.
13:52:14.807 [ERROR] [system.err] Note: Recompile with -Xlint:unchecked for details.
13:53:01.971 [ERROR] [system.err] Note: Some input files use or override a deprecated API.
13:53:01.971 [ERROR] [system.err] Note: Recompile with -Xlint:deprecation for details.
13:53:01.971 [ERROR] [system.err] Note: /Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/volley/src/main/java/com/android/volley/RequestQueue.java uses unchecked or unsafe operations.
13:53:01.971 [ERROR] [system.err] Note: Recompile with -Xlint:unchecked for details.
Usage Error: 
*** Failed to execute compilation command: exited with code 2
*** Command: 'javac' '@/Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/infer-out/filelists/gradle_9aS6Un.txt' '@/var/folders/lq/flnbxflx72d5lspr_gl_0knc0000gn/T/args_.tmp.b1b2bb'
*** Output:
javac: invalid flag: /Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/volley/build/generated/source/apt/release
Usage: javac <options> <source files>
use -help for a list of possible options

*** Infer needs a working compilation command to run.

Failed to execute: /usr/local/Cellar/infer/0.13.1/lib/infer/infer/lib/python/inferlib/../../../bin/infer capture --continue -- javac -source 1.7 -target 1.7 -d /Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/volley/build/intermediates/classes/release -encoding UTF-8 -bootclasspath /Users/cldrn/Library/Android/sdk/platforms/android-22/android.jar -g -sourcepath -proc:none -XDuseUnsharedTable=true -classpath -s /Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/volley/build/generated/source/apt/release @/Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/infer-out/filelists/gradle_9aS6Un.txt
Traceback (most recent call last):
  File "/usr/local/Cellar/infer/0.13.1/lib/infer/infer/bin/../lib/python/infer.py", line 186, in <module>
    main()
  File "/usr/local/Cellar/infer/0.13.1/lib/infer/infer/bin/../lib/python/infer.py", line 168, in main
    capture_exitcode = imported_module.gen_instance(args, cmd).capture()
  File "/usr/local/Cellar/infer/0.13.1/lib/infer/infer/lib/python/inferlib/capture/gradle.py", line 217, in capture
    return util.run_compilation_commands(cmds, clean_cmd)
  File "/usr/local/Cellar/infer/0.13.1/lib/infer/infer/lib/python/inferlib/capture/util.py", line 46, in run_compilation_commands
    if cmd.start() != os.EX_OK:
  File "/usr/local/Cellar/infer/0.13.1/lib/infer/infer/lib/python/inferlib/jwlib.py", line 37, in start
    raise e
subprocess.CalledProcessError: Command '[u'/usr/local/Cellar/infer/0.13.1/lib/infer/infer/lib/python/inferlib/../../../bin/infer', u'capture', u'--continue', u'--', u'javac', u'-source', u'1.7', u'-target', u'1.7', u'-d', u'/Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/volley/build/intermediates/classes/release', u'-encoding', u'UTF-8', u'-bootclasspath', u'/Users/cldrn/Library/Android/sdk/platforms/android-22/android.jar', u'-g', u'-sourcepath', u'-proc:none', u'-XDuseUnsharedTable=true', u'-classpath', u'-s', u'/Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/volley/build/generated/source/apt/release', u'@/Users/cldrn/Documents/workbench/client/clientAndroid-services-appointment-fix-gps-1cdc3e717f8514cae8e9ebe0e2d7593ac589191a/infer-out/filelists/gradle_9aS6Un.txt']' returned non-zero exit status 1

Error backtrace:
Raised at file "integration/Driver.ml", line 310, characters 16-78
Called from file "integration/Driver.ml", line 184, characters 2-16
Called from file "backend/infer.ml", line 23, characters 2-36
Called from file "backend/infer.ml", line 112, characters 6-52
Uncaught error: ("InferModules__Driver.Infer_error(\"exited with code 1\")")

Run the command again with `--keep-going` to try and ignore this error.
AnyMarvel commented 6 years ago

I have also the same issure .how can I fix it??? Uncaught error: ("InferModules__Driver.Infer_error(\"exited with code 1\")")

jvillard commented 6 years ago

Looks like another victim of the simplistic gradle integration (#855). Sorry for the late reply. Seeing the contents of the files generated by infer to pass to javac would help diagnose further.

jvillard commented 6 years ago

Closing as duplicate.