Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/java/dev/jbang/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ public static Path getConfigDir(boolean init) {
if (jd != null) {
dir = Paths.get(jd);
} else {
dir = Paths.get(System.getProperty("user.home")).resolve(".jbang");
// On Windows, USERPROFILE is more reliable than user.home for non-ASCII
// usernames
String home = Util.isWindows()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this overlaps with #2450

? System.getenv().getOrDefault("USERPROFILE", System.getProperty("user.home"))
: System.getProperty("user.home");
dir = Paths.get(home).resolve(".jbang");
}

if (init)
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/dev/jbang/cli/Edit.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,17 @@ private static void setupEditor(Path editorBinPath, Path dataPath) throws IOExce
}

private static List<String> findEditorsOnPath() {
return Arrays.stream(knownEditors).filter(e -> Util.searchPath(e) != null).collect(Collectors.toList());
return Arrays.stream(knownEditors)
.filter(e -> Util.searchPath(e) != null)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to 2x the calls to searchPath() that does not seem right.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we simply return the right name ? idea.bat ? or exec it shell?

.map(e -> {
Path found = Util.searchPath(e);
// On Windows, use the full path with extension so Git Bash can execute it
if (Util.isWindows() && found != null) {
return found.toString();
}
return e;
})
.collect(Collectors.toList());
}

private static void showStartingMsg(String ed, boolean showConfig) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/dev/jbang/dependencies/DependencyCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ public static List<ArtifactInfo> findDependenciesByHash(String depsHash) {

public static void clear() {
depCache = null;
// Also clear the dependency cache JSON file from disk
try {
Path cacheFile = Settings.getCacheDependencyFile();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not seem related to this issue?

if (Files.exists(cacheFile)) {
Util.verboseMsg("Deleting dependency cache file: " + cacheFile);
Files.deleteIfExists(cacheFile);
}
// Also clear the depcache directory containing actual JARs
Path depCacheDir = Settings.getCacheDir(dev.jbang.Cache.CacheClass.deps);
if (Files.exists(depCacheDir)) {
Util.verboseMsg("Deleting dependency cache dir: " + depCacheDir);
Util.deletePath(depCacheDir, true);
}
} catch (IOException e) {
Util.errorMsg("Could not clear dependency cache files", e);
}
}

}