processing / processing/processing4

sketchPath is different on OSX then Windows

オープン
#808 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug core has attachment
主要言語
Java
スター
497
フォーク
183
平均マージ
4時間 39分
マージ済み PR(30日)
3

説明

Created by: clankill3r

Processing 4.3 (and prior)
Windows 10

When working outside the IDE it's common to put the libraries in a lib folder like: (even when not using processing this is common)

sketchPath

The above works fine on OSX, but on windows it does not work.
The reason it breaks on windows: https://github.com/benfry/processing4/blob/main/core/src/processing/core/PApplet.java#L7186

        if (jarPath.contains("/lib/")) {
          // Windows or Linux, back up a directory to get the executable
          folder = new File(jarPath, "../..").getCanonicalPath();
        }

It is assumed that core.jar is directly in the lib folder, in the above case sketchPath becomes rootOfProject/lib and dataPath becomes rootOfProject/lib/data.

For now I use this in my sketch:

    public void fixSketchPath() {
        try {
            Field sketchPathField = PApplet.class.getDeclaredField("sketchPath");
            sketchPathField.setAccessible(true);

            String sketchPath = (String) sketchPathField.get(this);

            if (sketchPath.contains("\\lib")) {
                int libIndex = sketchPath.indexOf("\\lib");
                sketchPath = sketchPath.substring(0, libIndex);
            }

            sketchPathField.set(this, sketchPath);

        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }

But this is of course more a work around then a fix.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

core/src/processing/core/PApplet.java の、リンクされた行付近にある sketchPath のロジックから始め、Windows 10 と OSX で jarPath がどのように扱われるかを比較してください。ライブラリを lib フォルダーに置く構成を再現し、sketchPath が lib フォルダーではなくプロジェクトルートを指し、dataPath がそのルートから導出されることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
operating-systems
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。