forcedotcom / sfdx-scanner

MIT License
208 stars 49 forks source link

[BUG] JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 not working #1446

Closed gavignon closed 2 months ago

gavignon commented 2 months ago

Description: When having the environment variable JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8, the scanner run command is not working, resulting in this error:

Error (1): Java version 8 isn't supported. Install Java 1.8 or later.

Steps To Reproduce: export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 sf scanner:run --engine pmd --target force-app/main/default/classes --pmdconfig ~/dev/ruleset.xml -s 3

Expected Behavior: Command executed succesfully with the results of the scan

Workaround: Remove the environment variable JAVA_TOOL_OPTIONS

Urgency: Very High

stephen-carter-at-sf commented 2 months ago

Hello @gavignon. Can you do 3 things... 1) Tell me what you you get with: echo $JAVA_HOME and java --version 2) Tell me what you get with: sf --version sf plugins 3) delete your ~/.sfdx-scanner folder and try again and let me know if you still get the issue.

stephen-carter-at-sf commented 2 months ago

This looks like a duplicate of https://github.com/forcedotcom/sfdx-scanner/issues/1453 and so I'm going to close this issue as we will be fixing this bug at some point this month.

gavignon commented 1 month ago

Hello @stephen-carter-at-sf, I saw that #1453 was fixed so I tested again but I still have the error.

Here are what you requested:

  1. echo $JAVA_HOME => empty, java --version: openjdk 21.0.2 2024-01-16 OpenJDK Runtime Environment Homebrew (build 21.0.2) OpenJDK 64-Bit Server VM Homebrew (build 21.0.2, mixed mode, sharing)
  2. sf --version: @salesforce/cli/2.40.7 darwin-x64 node-v20.12.2 sf plugins: @salesforce/sfdx-scanner 3.23.0 dev 2.1.8 (2.1.8) sfdmu 4.33.7 sfdx-git-delta 5.34.0 (stable) sfdx-notify 0.0.16 signups 2.0.21 (2.0.21) Uninstalled JIT Plugins: community 3.2.6 custom-metadata 3.3.4 devops-center 1.2.9 env 3.0.29 functions 1.23.0 @salesforce/sfdx-plugin-lwc-test 1.2.0
  3. Same error

Could you please help me ?

jfeingold35 commented 1 month ago

@gavignon , the bug has been resolved in our dev branch, but the fix has not yet been published. That will happen on our next release, currently scheduled for May 28.

gavignon commented 1 month ago

@jfeingold35 Thanks! Do you know if it has been published ? I tried yesterday on the latest version (3.25.0) and had the same issue.

jfeingold35 commented 1 month ago

@gavignon , yeah, it should be working now. Question: Have you tried deleting the javaHome property from your ~/.sfdx-=scanner/config.json file and re-running? That might fix it.

gavignon commented 1 month ago

@jfeingold35 It still doesn't work with 3.25.0, but on @latest-beta it's working (4.2.0), will it be fixed in the @latest ?

gavignon commented 3 weeks ago

@jfeingold35 Would it be fixed in a 3.25.X release ? We tried to use the 4.2.0 version but we have other blocking issues like this one: https://github.com/forcedotcom/sfdx-scanner/issues/1439, so we are blocked for now

jfeingold35 commented 3 weeks ago

@gavignon , we didn't push the fix to 3.x, so that's unlikely. We'll try to get this sorted out as soon as we can. In the meantime, we appreciate your patience.

stephen-carter-at-sf commented 3 weeks ago

@gavignon soon v4 will be the standard. But if you need to remain on v3 for a while.. can you first try the following workaround:

Meanwhile, I'll check with our project manager to see if we want to backport this fix to our last v3 version (3.26.0) that is going out at the end of the month so that you might be able to just use that for now while waiting for PMD folks to fix your issue.

stephen-carter-at-sf commented 3 weeks ago

OK, yeah just got approval. We'll make sure this fix also goes out with 3.26.0