processing / processing/processing4
sketchPath is different on OSX then Windows
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 494
- 派生
- 183
- 平均合并
- 4 小时 39 分钟
- 30 天内合并 PR
- 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)
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 core/src/processing/core/PApplet.java 中链接行附近的 sketchPath 逻辑开始,比较 jarPath 在 Windows 10 和 OSX 上的处理方式。复现将库放在 lib 文件夹中的设置,并验证 sketchPath 指向的是项目根目录而不是 lib 文件夹,同时 dataPath 是从该根目录派生的。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- operating-systems
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100