diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/debug/ReadaptDebugDelegate.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/debug/ReadaptDebugDelegate.java index ee27b22..93926e0 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/debug/ReadaptDebugDelegate.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/launch/debug/ReadaptDebugDelegate.java @@ -70,7 +70,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun } if (UPDATE_GEM.getValue() && !HAS_UPDATED_READAPT.getAndSet(true)) { - GemHelper.scheduleUpdate("Readapt", READAPT_UPDATE_DELAY); + GemHelper.scheduleUpdate("Readapt", READAPT_UPDATE_DELAY, READAPT_PATH); } } diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/server/SolargraphStreamConnectionProvider.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/server/SolargraphStreamConnectionProvider.java index 10eabbc..9a06a3b 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/server/SolargraphStreamConnectionProvider.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/server/SolargraphStreamConnectionProvider.java @@ -57,7 +57,7 @@ public void start() throws IOException { } super.start(); if (UPDATE_GEM.getValue() && !HAS_UPDATED_SOLARGRAPH.getAndSet(true)) { - GemHelper.scheduleUpdate("Solargraph", 30000L); + GemHelper.scheduleUpdate("Solargraph", 30000L, GEM_PATH); } } diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/GemHelper.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/GemHelper.java index 9aa9bcb..c84c7ea 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/GemHelper.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/utils/GemHelper.java @@ -31,16 +31,11 @@ public class GemHelper { - private static String buildGemCmd(String cmd, String lowerCaseGem) { - return String.format( - "gem %s -V -n \"%s\" %s", - cmd, getPluginStateLocation(), lowerCaseGem); - } - public static void install(String gem, StringPreferences pathPreference) { String lowerCaseGem = gem.toLowerCase(); - String[] command = CommandHelper.getPlatformCommand(buildGemCmd("install", lowerCaseGem)); - CommandJob installCommandJob = new CommandJob(gem, command, "Installation in progress"); + String command = String.format("gem install -V -n \"%s\" %s", getPluginStateLocation(), lowerCaseGem); + String[] platformCommand = CommandHelper.getPlatformCommand(command); + CommandJob installCommandJob = new CommandJob(gem, platformCommand, "Installation in progress"); installCommandJob.addJobChangeListener(new JobChangeAdapter() { @@ -58,9 +53,11 @@ public void done(IJobChangeEvent event) { installCommandJob.schedule(); } - public static void scheduleUpdate(String gem, long delay) { - String[] command = CommandHelper.getPlatformCommand(buildGemCmd("update", gem)); - new CommandJob(gem, command, "Update in progress").schedule(delay); + public static void scheduleUpdate(String gem, long delay, StringPreferences pathPreference) { + String path = pathPreference.getValue(); + String command = String.format("gem update -V -n \"%s\" %s", path.substring(0, path.lastIndexOf(File.separator)), gem); + String[] plarformCommand = CommandHelper.getPlatformCommand(command); + new CommandJob(gem, plarformCommand, "Update in progress").schedule(delay); } private static String getPluginStateLocation() {