alchitry / Alchitry-Labs

https://alchitry.com/
GNU General Public License v3.0
28 stars 12 forks source link

Build does not start, exception encountered #32

Open jmatta1 opened 3 years ago

jmatta1 commented 3 years ago

I am trying to run alchitry-lab on Ubuntu 20.04.2 LTS.

When I click the build button nothing happens in the console. If I go to the terminal (where I ran alchitry-labs from) I see the following exception stack trace:

Exception in thread "DefaultDispatcher-worker-1" java.lang.NoSuchMethodError: 'void org.apache.commons.io.FileUtils.write(java.io.File, java.lang.CharSequence)'
    at com.alchitry.labs.project.builders.ProjectBuilder.convertConstraintFile(ProjectBuilder.java:248)
    at com.alchitry.labs.project.builders.ProjectBuilder.getConstraintFiles(ProjectBuilder.java:298)
    at com.alchitry.labs.project.builders.VivadoBuilder.generateProjectFile(VivadoBuilder.java:121)
    at com.alchitry.labs.project.builders.VivadoBuilder.projectBuilder(VivadoBuilder.java:33)
    at com.alchitry.labs.project.builders.ProjectBuilder.build(ProjectBuilder.java:152)
    at com.alchitry.labs.project.Project$build$1.invokeSuspend(Project.kt:1260)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

Steps to reproduce:

  1. Open a project.
  2. Click build button.
  3. Observe lack of console output and terminal output.

Fix attempts:

At this point I am at a bit of a loss because neither Java nor Kotlin are among the computer programming languages I have any real familiarity with. Any assistance or suggestions would be welcome!

harvv commented 3 years ago

I've encountered this NoSuchMethodError when trying to create a new project, from a fresh unzip of labs 1.2.6.

It looks like there is a duplicate FileUtils being pulled in as a part of another dependency: harvey@harvey:~/alchitry-labs-1.2.6$ java -verbose -cp "lib/*" com.alchitry.labs.MainKt lin64 | grep FileUtils [9.135s][info][class,load] org.apache.commons.io.FileUtils source: file:/home/harvey/alchitry-labs-1.2.6/lib/fop-transcoder-allinone-2.2.jar

I didn't go any further to see if this is in fact the problem...but it seems to be... because in my case, the method "missing" is reported as java.lang.NoSuchMethodError: 'void org.apache.commons.io.FileUtils.writeStringToFile(java.io.File, java.lang.String, boolean)'

if you note the method signature, it's File, String, boolean

However, if you dump (via javap) the JAR "fop-transcoder-allinone-2.2.jar" where the classloader told us the "other FileUtils" lives, you see these overloads of the method (NOTE THE SIGNATURES) public static void writeStringToFile(java.io.File, java.lang.String, java.lang.String) throws java.io.IOException; public static void writeStringToFile(java.io.File, java.lang.String) throws java.io.IOException;

So, this suggests that there might be an issue there.

harvv commented 3 years ago

editing the fop-transcoder-allinone-2.2.jar file and deleting the entire commons/io subdir tree allows my slightly different scenario of creating a project to continue without error

Please do not close this bug. This is a hack; it's not even a workaround.

liamhays commented 3 years ago

Hi,

I'm trying to run Alchitry Labs on Arch (with OpenJDK 15), and got the same error in the exact same way as harvv, when trying to create a new project. Seeing this thread, I did some experimenting, and found that by deleting entirely fop-transcoder-allinone-2.2.jar from the lib/ directory, Labs would start and run just fine.

Then, out of curiosity (because it doesn't seem like it should run at all, missing a library), I cloned Labs' source and looked for where fop was imported. grepping for fop in the repo root found nothing at all, so I looked for apache. That got me this:

[~/Downloads/Alchitry-Labs] $ grep -r apache *
src/com/alchitry/labs/hardware/usb/ftdi/enums/LineStopbit.java: *      http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/hardware/usb/ftdi/enums/ChipType.java: *      http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/hardware/usb/ftdi/enums/LineDatabit.java: *      http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/hardware/usb/ftdi/enums/PortInterfaceType.java: *      http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/hardware/usb/ftdi/enums/BitMode.java: *      http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/hardware/usb/ftdi/enums/BitMode.java:import org.apache.batik.apps.svgbrowser.Application;
src/com/alchitry/labs/hardware/usb/ftdi/enums/FlowControl.java: *      http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/hardware/usb/ftdi/enums/LineParity.java: *      http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/hardware/usb/ftdi/enums/LineBreak.java: *      http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/widgets/CustomConsole.java:import org.apache.commons.lang3.StringUtils;
src/com/alchitry/labs/gui/NewProjectDialog.kt:import org.apache.commons.io.FileUtils
src/com/alchitry/labs/gui/NewProjectDialog.kt:import org.apache.commons.lang3.RegExUtils
src/com/alchitry/labs/project/CoreGen.java:import org.apache.commons.lang3.exception.ExceptionUtils;
src/com/alchitry/labs/project/VivadoIP.kt:import org.apache.commons.io.FileUtils
src/com/alchitry/labs/project/Project.kt:import org.apache.commons.io.FileUtils
src/com/alchitry/labs/project/Project.kt:import org.apache.commons.lang3.exception.ExceptionUtils
src/com/alchitry/labs/project/builders/ISEBuilder.java:import org.apache.commons.io.FileUtils;
src/com/alchitry/labs/project/builders/IceCubeBuilder.java:import org.apache.commons.io.FileUtils;
src/com/alchitry/labs/project/builders/ProjectBuilder.java:import org.apache.commons.io.FileUtils;
src/com/alchitry/labs/project/builders/VivadoBuilder.java:import org.apache.commons.io.FileUtils;
src/com/alchitry/labs/ExtractUtility.java:import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
src/com/alchitry/labs/ExtractUtility.java:import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
src/com/alchitry/labs/ExtractUtility.java:import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
src/com/alchitry/labs/dictionaries/Dictionary.java:import org.apache.commons.lang3.StringUtils;
src/com/alchitry/labs/UpdateChecker.kt:import org.apache.commons.io.FileUtils
src/com/alchitry/labs/UpdateChecker.kt:import org.apache.commons.io.IOUtils
src/com/alchitry/labs/UpdateChecker.kt:import org.apache.commons.lang3.exception.ExceptionUtils
src/com/alchitry/labs/parsers/InstModule.java:import org.apache.commons.lang3.StringUtils;
src/com/alchitry/labs/parsers/tools/lucid/ConstExprParser.java:import org.apache.commons.text.StringEscapeUtils;
src/com/alchitry/labs/parsers/BigFunctions.java:  http://www.apache.org/licenses/LICENSE-2.0
src/com/alchitry/labs/parsers/lucidv2/ExprParser.kt:import org.apache.commons.text.StringEscapeUtils
src/com/alchitry/labs/Util.kt:import org.apache.batik.transcoder.SVGAbstractTranscoder
src/com/alchitry/labs/Util.kt:import org.apache.batik.transcoder.TranscoderException
src/com/alchitry/labs/Util.kt:import org.apache.batik.transcoder.TranscoderInput
src/com/alchitry/labs/Util.kt:import org.apache.batik.transcoder.TranscoderOutput
src/com/alchitry/labs/Util.kt:import org.apache.batik.transcoder.image.PNGTranscoder
src/com/alchitry/labs/Util.kt:import org.apache.commons.io.IOUtils
src/com/alchitry/labs/Util.kt:import org.apache.commons.io.filefilter.DirectoryFileFilter
src/com/alchitry/labs/Util.kt:import org.apache.commons.lang3.exception.ExceptionUtils

If I'm reading this correctly, Labs isn't importing fop at all, and the only transcoder it's importing is the Batik toolkit (an SVG toolkit, I guess). Even stranger, fop isn't referenced by any IDE project files, like one might expect from an old dependency. It looks to me like Alchitry mistakenly included an extra JAR in their release (but not their current Git source, which has no fop JAR), and it's conflicting with the Apache IO functions.

As a solution, this is only slightly better than the JAR-editing hack above. Hopefully by the next release Alchitry doesn't include this file.

alchitry commented 3 years ago

I'm not sure if this will fix the original issue, but I've remove all the Batik stuff in 1.2.7.

liamhays commented 3 years ago

It appears to be working now. Thanks for making that change---should save folks a lot of confusion!