ringo / ringojs

RingoJS is a JavaScript platform built on the JVM and optimized for server-side applications.
https://ringojs.org
Apache License 2.0
838 stars 101 forks source link

Fail to execute scripts, throws FileNotFoundException #237

Closed alexshen closed 4 years ago

alexshen commented 11 years ago

ringo fails to run scripts which are in the sub directories of directories listed in RINGO_MODULE_PATH, FileNotFoundException will be thrown.

kmfdm1 commented 11 years ago

Could you please provide some code to clarify the problem. I never had any problem with scripts in subdirectories of RINGO_MODULE_PATH.

alexshen commented 11 years ago

My directory structure is like below

--ringojs
    |--- ringojs-0.9
    |--- test
    |      |--- b.js
    |      |--- test
    |             |--- a.js
    |--- run.bat

run.bat

@echo off

set RINGO_MODULE_PATH=%~dp0\test
ringojs-0.9\bin\ringo.cmd %~dp0\test\test\a.js

a.js

require('b');
print('hello');

Invoke run.bat in the ringojs directory, I get the following output

E:\Develop\ringojs>run.bat
java.io.FileNotFoundException: E:\Develop\ringojs\test\a.js

If I move a.js upward and change the path to a.js in run.bat accordingly, then ringo has no problem to locate the file.

oberhamsi commented 11 years ago

hi @alexshen, i just tried the same thing on linux and it seems to work. can you try with --verbose so we get a better error message. this is how it looks for me, it was able to require('b') as expected:

 $ export RINGO_MODULE_PATH=./test/ 
 $ ringo --verbose test/test/a.js 
 Loading module: ringo/engine
 Loading module: b
alexshen commented 11 years ago

This is the output with --verbose

E:\Develop\ringojs>run.bat
Loading module: ringo/engine
java.io.FileNotFoundException: E:\Develop\ringojs\test\a.js
Java Exception: java.io.FileNotFoundException: E:\Develop\ringojs\test\a.js
        at org.ringojs.engine.RhinoEngine.runScript(RhinoEngine.java:196)
        at org.ringojs.tools.RingoRunner.run(RingoRunner.java:152)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.ringojs.tools.launcher.Main.run(Main.java:66)
        at org.ringojs.tools.launcher.Main.main(Main.java:45)

I guess the problem may be relevant to the path handling on windows ?

oberhamsi commented 11 years ago

the path in FileNotFoundException and the path in your batch file don't match up (one "test" vs "test/test"). i don't think this is related to MODULE_PATH. if you call a.js, it should at least execute a.js and complain about "cannot find module: b":

 > ringojs-0.9\bin\ringo.cmd test\test\a.js
  Cannot find module 'b'
alexshen commented 11 years ago

I changed a.js so that it does not require b, then I ran two tests, one w/ MODULE_PATH, the other w/o. The results are listed below

w/ MODULE_PATH

E:\Develop\ringojs>run.bat
Loading module: ringo/engine
java.io.FileNotFoundException: E:\Develop\ringojs\test\a.js
Java Exception: java.io.FileNotFoundException: E:\Develop\ringojs\test\a.js
        at org.ringojs.engine.RhinoEngine.runScript(RhinoEngine.java:196)
        at org.ringojs.tools.RingoRunner.run(RingoRunner.java:152)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.ringojs.tools.launcher.Main.run(Main.java:66)
        at org.ringojs.tools.launcher.Main.main(Main.java:45)

w/o MODULE_PATH

E:\Develop\ringojs>run.bat
Loading module: ringo/engine
hello

I found an issue in run.bat which will have MODULE_PATH persist after running. I changed run.bat to ensure that MODULE_PATH won't affect next run.

botic commented 4 years ago

I’m closing this issue because it has been inactive for a long time. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on for so long, then it seems no one has the time to implement this / there is no interest in it.

Please reopen if you still encounter this issue with the current master version or there is a need to address this issue.