|
From: <caw...@us...> - 2007-04-30 14:48:37
|
Revision: 2398
http://svn.sourceforge.net/rubyeclipse/?rev=2398&view=rev
Author: cawilliams
Date: 2007-04-30 07:48:33 -0700 (Mon, 30 Apr 2007)
Log Message:
-----------
try checking System path to find a ruby executable on windows
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java 2007-04-30 14:09:45 UTC (rev 2397)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java 2007-04-30 14:48:33 UTC (rev 2398)
@@ -255,34 +255,45 @@
* @see org.eclipse.jdt.launching.IVMInstallType#detectInstallLocation()
*/
public File detectInstallLocation() {
- // do not detect on Windows
+ File rubyExecutable = null;
if (Platform.getOS().equals(Constants.OS_WIN32)) {
- return null;
- }
-
- String[] cmdLine = new String[] { "which", "ruby" }; //$NON-NLS-1$ //$NON-NLS-2$
- Process p = null;
- File rubyExecutable = null;
- try {
- p = Runtime.getRuntime().exec(cmdLine);
- IProcess process = DebugPlugin.newProcess(new Launch(null, ILaunchManager.RUN_MODE, null), p, "Standard Ruby VM Install Detection"); //$NON-NLS-1$
- for (int i = 0; i < 200; i++) {
- // Wait no more than 10 seconds (200 * 50 mils)
- if (process.isTerminated()) {
+ String winPath = System.getenv("Path"); // iterate through system path and try to find ruby.exe
+ String[] paths = winPath.split(";");
+ for (int i = 0; i < paths.length; i++) {
+ String possibleExecutablePath = paths[i] + File.separator + "ruby.exe";
+ File possible = new File(possibleExecutablePath);
+ if (possible.exists()) {
+ rubyExecutable = possible;
break;
}
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {}
}
- rubyExecutable = parseRubyExecutableLocation(process);
- } catch (IOException ioe) {
- LaunchingPlugin.log(ioe);
- } finally {
- if (p != null) {
- p.destroy();
+ } else { // Mac, Linux - so let's just run 'which ruby' and parse out the result
+ String[] cmdLine = new String[] { "which", "ruby" }; //$NON-NLS-1$ //$NON-NLS-2$
+ Process p = null;
+ try {
+ p = Runtime.getRuntime().exec(cmdLine);
+ IProcess process = DebugPlugin.newProcess(new Launch(null,
+ ILaunchManager.RUN_MODE, null), p,
+ "Standard Ruby VM Install Detection"); //$NON-NLS-1$
+ for (int i = 0; i < 200; i++) {
+ // Wait no more than 10 seconds (200 * 50 mils)
+ if (process.isTerminated()) {
+ break;
+ }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+ }
+ rubyExecutable = parseRubyExecutableLocation(process);
+ } catch (IOException ioe) {
+ LaunchingPlugin.log(ioe);
+ } finally {
+ if (p != null) {
+ p.destroy();
+ }
}
- }
+ }
if (rubyExecutable == null) {
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|