Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gavignon opened this issue Apr 26, 2024 · 11 comments
Closed

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

gavignon opened this issue Apr 26, 2024 · 11 comments
Labels
duplicate This issue or pull request already exists

Comments

@gavignon
Copy link

gavignon commented Apr 26, 2024

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
Copy link
Collaborator

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
Copy link
Collaborator

This looks like a duplicate of #1453 and so I'm going to close this issue as we will be fixing this bug at some point this month.

@jfeingold35 jfeingold35 closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
@jfeingold35 jfeingold35 added the duplicate This issue or pull request already exists label May 7, 2024
@gavignon
Copy link
Author

gavignon commented May 13, 2024

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
Copy link
Collaborator

@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
Copy link
Author

@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
Copy link
Collaborator

@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
Copy link
Author

@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
Copy link
Author

@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: #1439, so we are blocked for now

@jfeingold35
Copy link
Collaborator

@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
Copy link
Collaborator

@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:

  • Remove the environment variable JAVA_TOOL_OPTIONS
  • Then call sf scanner rules list (so that the java version is captured in the internal config file)
  • Then add in the JAVA_TOOL_OPTIONS environment variable back in if you want
  • Then call sf scanner run as you normally would.

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants