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

Workarounds for "input too long" problem do not work as expected #1466

Open
bobismijnnaam opened this issue Oct 8, 2021 · 4 comments
Open
Labels
bug universal Zip, tar.gz, tgz and bash issues

Comments

@bobismijnnaam
Copy link

Expected behaviour

Using enablePlugins(LauncherJarPlugin) or enablePlugins(ClasspathJarPlugin) should result in a package that runs.

Actual behaviour

When either of enablePlugins(LauncherJarPlugin) or enablePlugins(ClasspathJarPlugin) is used, when running the generated package, an error is printed: "class vct.main.Main not found". (vct.main.Main is the main class of our package)

Information

  • What sbt-native-packager are you using: 1.9.4
  • What sbt version: 1.5.1
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian ): Manjaro Stable
  • What package are you building (e.g. docker, rpm, ...): packageZipTarball
  • What version has your build tool (find out with e.g. rpm --version): I used the file manager's built-in "extract here"
  • What is your target system (e.g. Ubuntu 16.04, CentOS 7): Manjaro stable (trying to run the built package locally)

What's strange is that if I run the package with a custom java command in the terminal, e.g.:

$ java -cp 'lib/*:res vct.main.Main --help

As expected, it prints the help message. So all classes needed for running our package are in the unzipped package. But somehow the run script/jar files that sbt-native-packager generates have trouble finding the class files.

Currently we are using the workaround of: scriptClasspath := Seq("*", "../res"), which does result in a package that runs as expected, but we'd rather use one of the aforementioned plugins for clarity and stability.

I am aware of https://sbt-native-packager.readthedocs.io/en/latest/recipes/longclasspath.html, #1327, and #1071, but I think I have tried all three options (of which the third worked, the Seq("*") approach). I did not apply any other changed to my build.sbt except adding the "enablePlugins" statements; please let me know if there is more intricate setup required to make these plugins function.

@muuki88 muuki88 added universal Zip, tar.gz, tgz and bash issues bug labels Oct 8, 2021
@muuki88
Copy link
Contributor

muuki88 commented Oct 8, 2021

Thanks a lot @bobismijnnaam for the detailed report.

This surely sounds like a bug. Do you have the time to create a minimal example reproducing this?

My initial guess would be that there are multiple main classes, but not sure if this explains this.

@bobismijnnaam
Copy link
Author

Here is our build.sbt: https://github.com/utwente-fmt/vercors/blob/dev/build.sbt

I think we have only one main class but of course maybe our settings are wrong. I have vacation this week but I'll try to make a repro when I get back (or maybe one of my team members can have a look, but I expect them to be busy as well).

@ArmborstL
Copy link

FWIW, I think that there are indeed multiple main classes, as we include other git repositories as dependencies, which have their own main method. The build.sbt even mentions multiple mains, and tries to handle them in some way: https://github.com/utwente-fmt/vercors/blob/97c49d6dc1097ded47a5ed53143695ace6904865/build.sbt#L153
I spent a little time trying to reduce the example. But as a newbie to sbt, I didn't get far, and I think I'll wait for Bob to get back 😄

@bobismijnnaam
Copy link
Author

bobismijnnaam commented Oct 20, 2021

I made a minimal version of our big project that exhibits the problem:

vercors_stripped_test.zip

Reproduction steps:

  • Unzip
  • Run sbt shell in the root project folder with the build.sbt
  • In sbt's shell, run clean; Univeral / packageZipTarball
  • In the folder target / universal, there should now be a .tgz file. Unzip that, cd into it, and run the command ./bin/vercors --help. This should print the error cannot find class vct.main.Main.

EDIT: Looks like the problem is that we have spaces in the organization in our build.sbt... So the short term fix for us is clear (i.e. remove spaces from our organization), not sure how you want to handle this on your side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug universal Zip, tar.gz, tgz and bash issues
Projects
None yet
Development

No branches or pull requests

3 participants