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

CLI command fails when config.json file is referenced relative to HOME environmental variable #907

Open
nurse-the-code opened this issue Nov 22, 2024 · 0 comments

Comments

@nurse-the-code
Copy link
Collaborator

nurse-the-code commented Nov 22, 2024

Problem Observed

The CLI tabulation fails when using a config.json file referenced by its relation to the home directory. By contrast, the CLI tabulation successfully completes when the same config.json is referenced by absolute path or path relative to the working directory.

Example of Problem

For example, when this command in the zsh shell on MacOS (Apple Silicon):

./gradlew run --args="--cli ~/config.json

This error occurs:

2024-11-22 14:31:53 EST SEVERE: Error opening file: ~/config.json
java.io.FileNotFoundException: ~/config.json (No such file or directory)
Check file path and permissions and make sure they are correct!
2024-11-22 14:31:53 EST SEVERE: Failed to load contest config: ~/config.json
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:116)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
        at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1081)
Caused by: java.lang.NullPointerException: Cannot invoke "network.brightspots.rcv.ContestConfig.getRawConfig()" because "config" is null
        at [email protected]/network.brightspots.rcv.TabulatorSession.checkConfigVersionMatchesApp(TabulatorSession.java:61)
        at [email protected]/network.brightspots.rcv.TabulatorSession.tabulate(TabulatorSession.java:171)
        at [email protected]/network.brightspots.rcv.TabulatorSession.tabulate(TabulatorSession.java:277)
        at [email protected]/network.brightspots.rcv.Main.main(Main.java:86)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        ... 6 more
Exception running application network.brightspots.rcv.Main

> Task :run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Users/malachi-at-rcvrc/Library/Java/JVMs/temurin-jdk-20.0.1+9/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s
5 actionable tasks: 2 executed, 3 up-to-date

By contrast, both of the following commands referencing the same config.json file both result in successful tabulation:

Referencing the config.json file by absolute path:

./gradlew run --args="--cli /Users/malachi-at-rcvrc/config.json"

Referencing the config.json file by relative path to working directory (when working directory is /Users/malachi-at-rcvrc/rctab/pre-2.0-develop/rcv):

./gradlew run --args="--cli ../../../config.json"

Reference Files Used In Example of Problem

  1. config.json (located at /Users/malachi-at-rcvrc/config.json)
  2. cvr.xlsx (located at /Users/malachi-at-rcvrc/cvr.xlsx)

Suggested Solution

  1. Update the README to advise user to use the absolute path when referring to the config.json file in the command to run the CLI.
  2. Update the CLI to support relative file paths that refer to the config.json file in relation to the $HOME directory.
@yezr yezr added this to RCTab v2.0 Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant