asdfjkl / jfxchess

JFXChess - Chess Program
https://asdfjkl.github.io/jfxchess
GNU General Public License v2.0
100 stars 22 forks source link

Bug: Cannot find stockfish_x64 engine #98

Closed 3N4N closed 3 years ago

3N4N commented 3 years ago

In Linux, I have Stockfish installed, but Jerry cannot find the binary. I think you're shipping your own version of stockfish anyway, but the code doesn't align with the directory structure. image

For now I'm doing a normal bugfix for myself:

diff --git a/src/main/java/org/asdfjkl/jerryfx/gui/GameModel.java b/src/main/java/org/asdfjkl/jerryfx/gui/GameModel.java
index 76de284d420a..f840a07f9679 100644
--- a/src/main/java/org/asdfjkl/jerryfx/gui/GameModel.java
+++ b/src/main/java/org/asdfjkl/jerryfx/gui/GameModel.java
@@ -147,7 +147,8 @@ public class GameModel {
                 if(tmp.getParentFile().exists()) {
                     //System.out.println(tmp.getParentFile().getAbsolutePath());
                     if(tmp.getParentFile().getParentFile().exists()) {
-                    File subEngine = new File(tmp.getParentFile().getParentFile(), "engine");
+                    File subEngine = new File(tmp.getParentFile().getParentFile(),
+                            "/snap/local/engine");
                     //System.out.println(subEngine.getPath());
                     stockfishPath = new File(subEngine, "stockfish_x64").getPath();
                     return stockfishPath;

 

On a different note, I'm a newbie chess player and need help with using Jerry. (Haven't used SCID. Looks too complicated.) Where do I get help or talk about that?

asdfjkl commented 3 years ago

thx, I will look into this.

For general questions about chess probably other places are better suited, but for any question about using Jerry, just raise an issue. I'll try to be as responsive as possible :-) ... and maybe other users join the discussion as well

asdfjkl commented 3 years ago

I am having some trouble figuring out what happens there on your system. Which OS/distribution are you using? I'll then try to use a VM to see what's going on. Here on Ubuntu 20.04 there should be this directory structure:

/snap/jerry/current/ /snap/jerry/current/engine/stockfish_x64 /snap/jerry/current/jar

if you installed the snap.

The error message looks as if you installed this locally into some project folder in your home directory?

3N4N commented 3 years ago

I didn't install it. I cloned the repo and ran the program. The snap installation works fine.

But ideally the program should search for the stockfish binary, not assume it was installed through snap. Hard coding is problematic for mass usage. I think having the snap directory structure checked first is fine, but on file-not-found (binary file of stockfish) error, you could use which stockfish in Linux to get the path of the binary. Or something like that.

asdfjkl commented 3 years ago

The path is not hard-coded. Instead the program looks relative to the execution path (the jar) for all relevant files. End-Users are not expected to clone the repo and build from source manually, but use either the snap or .tar.xz package from the release page. There, there everything (book, engine, graphics, splash screen) are packaged accordingly, and a starth.sh is provided.

Note that we cannot expect to have file permissions to search arbitrarily on the file system for certain binaries.

Of course, you can always add engines manually.

3N4N commented 3 years ago

@asdfjkl Ah! It's coded to work only for the end products. Makes sense.

By the way, by hard-coding, I meant using the relative path. (I read the code, you see. How else would I fix the bug?) It assumes that the directory structure will be the same as devs intended. Anyway, it doesn't matter since the user can add engines manually. That removes the barrier of being stuck with the devs' engine. I didn't see that option before.

And thanks! for the program.