When running a selected code in a Scala Editor, the current local dir is set to 'C:\perforce\scala_ide_4_0_0_eclipse_luna' instead of using a project dir, in my case 'C:\perforce\git\bayes-scala-gp'
it causes problems if you try running some code, which refers to a local project dir, e.g. val data = csvread(new File("src/test/resources/cogp/cogp_no_missing_points.csv"))
link to mailing list item:
https://groups.google.com/forum/#!topic/scala-ide-user/uYQl7FX62ac
it causes problems if you try running some code, which refers to a local project dir, e.g. val data = csvread(new File("src/test/resources/cogp/cogp_no_missing_points.csv"))
link to mailing list item:
https://groups.google.com/forum/#!topic/scala-ide-user/uYQl7FX62ac
Leave a comment
on 2015-10-02 12:45 *
By Simon Schäfer
I tried to fix this, but failed.
It doesn't seem to be possible to change the user directory in a way that the entire implementation of File appreciates the change. Sometimes, it still seems to rely on the working directory of the OS.
[antoras@wookypooky → ~]
% mkdir xxx
[antoras@wookypooky → ~]
% cd xxx
[antoras@wookypooky → ~/xxx]
% echo "hello world" > test.txt
[antoras@wookypooky → ~/xxx]
% cd ..
[antoras@wookypooky → ~]
% s
Welcome to Scala version 2.11.7 (OpenJDK 64-Bit Server VM, Java 1.8.0_60).
Type in expressions to have them evaluated.
Type :help for more information.
scala> System.setProperty("user.dir", System.getProperty("user.dir") + "/xxx")
res0: String = /home/antoras
scala> val f = new java.io.File("test.txt")
f: java.io.File = test.txt
scala> f.getAbsolutePath
res1: String = /home/antoras/xxx/test.txt
scala> f.exists
res2: Boolean = false
scala> :quit
[antoras@wookypooky → ~]
% cd xxx
[antoras@wookypooky → ~/xxx]
% s
Welcome to Scala version 2.11.7 (OpenJDK 64-Bit Server VM, Java 1.8.0_60).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val f = new java.io.File("test.txt")
f: java.io.File = test.txt
scala> f.getAbsolutePath
res0: String = /home/antoras/xxx/test.txt
scala> f.exists
res1: Boolean = true
It doesn't seem to be possible to change the user directory in a way that the entire implementation of File appreciates the change. Sometimes, it still seems to rely on the working directory of the OS.
on 2015-10-02 12:59 *
By Simon Schäfer
This question says that it is not possible to change the working directory reliable. I guess we would have to spawn a new process in a different working directory instead of running the REPL inside of the Eclipse process.
Workaround for now: Either always use absolute paths in your application (which you should do anyway, since relying on relative paths for such scenarios in not safe) or use the expression evaluator. The latter actually is only available in a debug VM and therefore not as useful as the REPL for simple code evaluation.
Good to know about the limitation of a in process REPL, maybe I have the time someday to change the code insofar that it also spawns in its own process.
Workaround for now: Either always use absolute paths in your application (which you should do anyway, since relying on relative paths for such scenarios in not safe) or use the expression evaluator. The latter actually is only available in a debug VM and therefore not as useful as the REPL for simple code evaluation.
Good to know about the limitation of a in process REPL, maybe I have the time someday to change the code insofar that it also spawns in its own process.
Move ticket to next milestone.
No file chosen
You have an empty file field. Please select or remove it.
Name | Size |
---|