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

Setting shortenCommandLine "argfile" should not nest a user-passed argfile inside an argfile #1403

Open
justin39 opened this issue Oct 31, 2023 · 2 comments

Comments

@justin39
Copy link

justin39 commented Oct 31, 2023

When setting shortenCommandLine to argfile (or setting to auto and then triggering the argfile behavior with a long command), VS Code will always put any vmArgs inside an argfile, even if the only VM arg is another argfile. This breaks run configurations that pass a user-generated argfile that still trigger the automatic CLI shortening behavior such as a very long classpath, since argfiles cannot be nested.

Environment
  • Operating System: Linux
  • JDK version: 17
  • Visual Studio Code version: 1.84.0-insider (60182c7e1a666961ded4d0319c154f52d85daf30)
  • Java extension version: v0.25.15
  • Java Debugger extension version: v0.54.0
Steps To Reproduce
  1. Create a trivial Java project ex. a Hello World main method
  2. Create an argfile myargs
  3. Create launch.json with a corresponding run configuration for the main method. Set shortenCommandLine to argfile to force the argfile behavior (should be equivalent to setting auto and then loading a very long classpath).
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Hello",
            "request": "launch",
            "mainClass": "Hello",
            "vmArgs": "@myargs",
            "shortenCommandLine": "argfile"
        }
    ]
}
  1. Attempt to run the main method - this should fail.

Sample project: test-argfile.tar.gz

Current Result
$  /usr/bin/env /path/to/jdk @/tmp/cp_7ifzraqswz8cni6w2z8m6nw3w.argfile Hello 
Error: Could not find or load main class @myargs
Caused by: java.lang.ClassNotFoundException: @myargs

/tmp/cp_7ifzraqswz8cni6w2z8m6nw3w.argfile contents:

@myargs -XX:+ShowCodeDetailsInExceptionMessages -cp "/home/justinw/.vscode-server-insiders/data/User/workspaceStorage/-2d922411/redhat.java/jdt_ws/test-argfile_31bc6c61/bin"
Expected Result

Program should execute and argfiles should not be nested

Additional Informations
@testforstephen
Copy link
Contributor

Pls set "shortenCommandLine": "none" as a workaround.

@justin39
Copy link
Author

Pls set "shortenCommandLine": "none" as a workaround.

Yes, this works pretty well 😄

However, the reason the shortenCommandLine is getting triggered is because the CLI is getting long, and some projects with sufficiently long vmArgs + classpaths will end up triggering "Argument list too long" errors. This can typically be solved by putting the vmArgs directly into launch.json instead of an argfile, but this isn't always an option for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants