Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » Ruby build path
Ruby build path [message #22924] Sun, 04 May 2008 20:15 Go to next message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com.br

Out of Eclipse, if you run your script, then Ruby assumes that the
directory where your script is located contains your libraries, so that if
you require 'aaa/bbb', Ruby will search 'aaa' directory on the same
directory of your script.

BUT NOT ECLIPSE. ECLIPSE ONLY SEARCHES THE ROOT PROJECT FOLDER! The ugly
solution is to add EACH OF YOUR SUBFOLDERS TO THE BUILDPATH of the
Project. Anotehr ugly solution is changing the working directory on Run
Dialog for EACH FILE you want to run.

Has anyone noticed that? Is there any plans to make this better? I think
DLTK could make working directory being the same as of the script, not the
project's root folder.
Re: Ruby build path [message #23286 is a reply to message #22924] Tue, 06 May 2008 06:16 Go to previous messageGo to next message
Andrei Sobolev is currently offline Andrei SobolevFriend
Messages: 72
Registered: July 2009
Member
Hi Renato,

Lets understand current situation:
I've have following project:

/workspace/asd/
src/
A.rb
src2/
E/
F.rb
B.rb
src3/
E/
F.rb
C.rb

src, src2, src3 are source folders.
With following content:

A.rb:
print "This is A\n"

src/E/F.rb:
print "This is F1\n"

src2/B.rb:
print "This is B\n"
require "A"

src3/E/F.rb:
print "This is F2\n"

src3/C.rb:
print "This is C\n"
require "B"
require "E/F"

Then I execute C by default output will be following:
>>>
This is C
This is B
This is A
This is F1
>>>

By default working dir are set to project location.
Then DLTK run Ruby script all source folders will be passed as arguments for -I parameter.
So we will have following call:
ruby -I/workspace/asd/src -I/workspace/asd/src2 -I/workspace/asd/src3 /workspace/asd/src3/C.rb

As I understand you need what /src3/E/F.rb should be included instead of /src/E/F.rb ?
Is this correct?

But As I understand if you specify working directory to /workspace/src3/ you will receive absolutely same output,
because Ruby will look into src firstly, and then to working directory.

What behavior we should have? Also please provide some example.



> Out of Eclipse, if you run your script, then Ruby assumes that the
> directory where your script is located contains your libraries, so that
> if you require 'aaa/bbb', Ruby will search 'aaa' directory on the same
> directory of your script.
>
> BUT NOT ECLIPSE. ECLIPSE ONLY SEARCHES THE ROOT PROJECT FOLDER! The ugly
> solution is to add EACH OF YOUR SUBFOLDERS TO THE BUILDPATH of the
> Project. Anotehr ugly solution is changing the working directory on Run
> Dialog for EACH FILE you want to run.
>
> Has anyone noticed that? Is there any plans to make this better? I think
> DLTK could make working directory being the same as of the script, not
> the project's root folder.
>
Re: Ruby build path [message #23366 is a reply to message #23286] Tue, 06 May 2008 19:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com.br

Hi Andrei, I'm sorry but it is hard to understand what you're saying. I'll
give you an example to be more clear:

(1) A folder on the filesystem:

/ruby_scripts
/lessons
/common
utils.rb
file_handling.rb --> requires 'arrays'
arrays.rb --> requires 'common/utils'
not_lesson_script.rb --> requires 'lessons/common/utils'



(2) If you run file_handling.rb and arrays.rb in console, Ruby searches
the required resources
from the same directory of the scripts:

(a) file_handling.rb requires 'arrays': arrays.rb will be looked up
from /lessons

(b) arrays.rb requires 'common/utils': utils.rb will be looked up from
/lessons/common

(c) not_lesson_script.rb requires 'lessons/common/utils': the same as
above




(3) Then you create a Ruby project using /ruby_script as a root folder,
and want to run those scripts inside the IDE.
BUT YOU'LL GET AN ERROR, because:

(a) file_handling.rb requires 'arrays': Eclipse will seek for
/ruby_scripts/arrays.rb AND THEREFORE WILL FAIL!!!

(b) arrays.rb requires 'common/utils': Eclipse will seek for
/ruby_scripts/common/utils.rb AND THEREFORE WILL FAIL!!!

(c) not_lesson_script.rb requires 'lessons/common/utils': Eclipse will
seek for ruby_scripts/lessons/common/utils.rb
and this is the only case where we would not get any errors.


(4) Possible solutions currently (standing we'd never want to make a
require from the top /ruby_scripts directory)

(a) Add lessons and common into the project's build path: this way
everything would work just like in 2nd item (like outside the IDE)
But this becomes IMHO as weird as the number of sub-folders
increases. Besides this makes the appearance of the sub-folder
to change, from a pretty package-like to a folder-like structure
with a complete path for each sub-folder
(just add your sub-folders to build path and you will see how it
changes).

(b) For each script you want to run, go to Run Dialog and change the
script's run configuration to set the working directory to the
same directory where the script is, instead of the project's root
folder. But this is is weird.


I hope you can understand now. My suggestion would be making Eclipse to
consider the script folder as a place to look up required
required resources, instead of (or not limited by) project's root folder.
Re: Ruby build path [message #23409 is a reply to message #23366] Tue, 06 May 2008 19:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com.br

I'm sorry but it seems the message was a little unformatted after
posting...
Re: Ruby build path [message #23452 is a reply to message #23366] Tue, 06 May 2008 19:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com.br

I tried to well-format the message again:

Hi Andrei, I'm sorry but it is hard to understand what you're saying. I'll
give you an example to be more clear:

(1) A folder on the filesystem:

/ruby_scripts
/lessons
/common
utils.rb
file_handling.rb --> requires 'arrays'
arrays.rb --> requires 'common/utils'
not_lesson_script.rb --> requires 'lessons/common/utils'



(2) If you run file_handling.rb and arrays.rb in console, Ruby searches
the required resources from the same directory of the scripts:

(a) file_handling.rb requires 'arrays': arrays.rb will be looked up
from
/lessons

(b) arrays.rb requires 'common/utils': utils.rb will be looked up from
/lessons/common

(c) not_lesson_script.rb requires 'lessons/common/utils': the same as
above



(3) Then you create a Ruby project using /ruby_script as a root folder,
and want to run those scripts inside the IDE. BUT YOU'LL GET AN ERROR,
because:

(a) file_handling.rb requires 'arrays': Eclipse will seek for
/ruby_scripts/arrays.rb AND THEREFORE WILL FAIL!!!

(b) arrays.rb requires 'common/utils': Eclipse will seek for
/ruby_scripts/common/utils.rb AND THEREFORE WILL FAIL!!!

(c) not_lesson_script.rb requires 'lessons/common/utils': Eclipse will
seek
for ruby_scripts/lessons/common/utils.rb and this is the only case
where we would not get any errors.


(4) Possible solutions currently (standing we'd never want to make a
require from the top /ruby_scripts directory)

(a) Add lessons and common into the project's build path: this way
everything would work just like in 2nd item (like outside the IDE).
But this becomes IMHO as weird as the number of sub-folders
increases.
Besides this makes the appearance of the sub-folder to change,
from a
pretty package-like to a folder-like structure with a complete
path for
each sub-folder (just add your sub-folders to build path and you
will
see how it changes).

(b) For each script you want to run, go to Run Dialog and change the
script's run configuration to set the working directory to the
same directory where the script is, instead of the project's root
folder. But this is is weird.


I hope you can understand now. My suggestion would be making Eclipse to
consider the script folder as a place to look up required required
resources, instead of (or not limited by) project's root folder.
Re: Ruby build path [message #23624 is a reply to message #23366] Thu, 08 May 2008 22:32 Go to previous messageGo to next message
Andrey Platov is currently offline Andrey PlatovFriend
Messages: 28
Registered: July 2009
Junior Member
Hi Renato,

> [SKIPPED]
>
> I hope you can understand now. My suggestion would be making Eclipse to
> consider the script folder as a place to look up required
> required resources, instead of (or not limited by) project's root folder.
>
>

That's exactly like DLTK work from the beginning - look up use Source
Folders as roots. If this is not working for you - it's just a bug. Let
us verify that.

Thank you for reporting this.
Kind Regards,
Andrey
Re: Ruby build path [message #23667 is a reply to message #23624] Fri, 09 May 2008 05:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com.br

Hi Andrey.

Actually Eclipse works like item 4.a: when you create the project form
existing source, it adds each sub-folder to the build path, but besides
that folder-like appearance I've noted, if you take a look on how this
configuration is done (project's properties) then you'll see a lot of
inclusion and exclusion filters that look weird.

I don't know if this is the behavior you're talking about. If true, then I
think that just the *directory of the script* could be added silently and
dynamically as a "working directory" when running the script. This way we
wouldn't need to create and update all that rules I mentioned above for
build path except if we want a special behavior.

It's like outside the IDE: you don't need to give -I"./" to ruby
interpreter because it's already aware about considering the script's
directory as a place to look up required stuff.

If my suggestion would be implemented, then when you run a script, Eclipse
would try to look up stuff from the same directory of the script
**regardless** of build path including that directory or not. Just like
you are setting working directory on Run dialog every time you run the
script, but now Eclipse would be doing it by itself, silently and
automatically.

I'm not that good in English but hope you can understand what I'm saying.
Re: Ruby build path [message #23752 is a reply to message #23667] Mon, 12 May 2008 08:20 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
Hi Renato,

I have read through this thread and I can see the following issues:

1) Create project from existing sources

The following directory structure

src/
src/lib/
src/main.rb
src/lib/lang/
src/lib/lang/system.rb
src/lib/utils.rb

is imported as

<buildpathentry kind="src" path="src" excluding="lib/|lib/lang/"/>
<buildpathentry kind="src" path="src/lib" excluding="lang/"/>
<buildpathentry kind="src" path="src/lib/lang"/>

i.e.
a) all directories are added as source folders
b) child directories are excluded from the parent directory.

Renato, please confirm that is "a lot of inclusion and exclusion
filters" you mentioned.

2) Run as Ruby Script

We can solve the issue with include paths in different ways:

2.1) Set working directory to the directory the script is located in.

2.2) The list of include directories should be configurable similar to
java classpath when running standalone java application.

2.3) 'directory of the script' could be added automatically.

Since there are different ways to organize projects, all of these should
be completely configurable.

Again, please confirm that some of the above could solve your issues.

We will file these issues as feature requests.

regards,
Alex
Re: Ruby build path [message #23795 is a reply to message #23752] Mon, 12 May 2008 12:00 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
Create project from existing sources filed at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=231522
Re: Ruby build path [message #23836 is a reply to message #23795] Mon, 12 May 2008 12:54 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
> Create project from existing sources filed at
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=231522

Andrei have just fixed this issue.
Re: Ruby build path [message #24030 is a reply to message #23752] Tue, 13 May 2008 18:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com.br

Hi Alex,

Yes, what you said is that "a lot of inclusion and exclusion filters" I
mentioned.

About running ruby scripts, I'd suggest the 2.3 option: add directory of
the script automatucally to the build path or as a working directory.

I think the 2 issues you mentioned are related: the whole thing I'd like
DLTK to do is that when I run a script, then it quietly and automatically
consider the script's directory as a place to search required resources,
*exactly the same way the ruby interpreter does outside the IDE**.

<<< Ruby interpreter always search required stuff from the current
directory: you don't need a -I"./", but not Eclipse DLTK: there you need
make a kind of -I"./" which is build path configuration. This is my
problem. >>>

However, I don't understand why Eclipse doesn't consider current directory
automatically as ruby interpreter does, since what Eclipse does is to pass
the script to the interpreter itself running it. Looks like it works in a
different way inside Eclipse.
Re: Ruby build path [message #24061 is a reply to message #24030] Tue, 13 May 2008 20:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com.br

Actually, the solution for the bug you had open makes things more
difficult, because istead of Eclipse not adding all the subfolders to the
classpath, we have to add all of them manually or change all the require
commmands inside the IDE to start from the project floder instead of the
script folder.


<<< That is, I think the solution for the bug is only valid if, as I'm
saying, DLTK considers current folder (script folder) automatically when
running scripts. I've downloaded the new M7a, but I'm still not able to,
for example, run a script that requires another script under the same
folder just because that folder (which isn't a src folder itself but a
subfolder of such one) is not on the build path :( >>>
Re: Ruby build path [message #24163 is a reply to message #24061] Tue, 20 May 2008 14:41 Go to previous messageGo to next message
Andrei Sobolev is currently offline Andrei SobolevFriend
Messages: 72
Registered: July 2009
Member
Hi Renato,

We corrected launching in DLTK, for now by default script folder will be specified as working directory, and case you
specified will work.

This fix will be available in 1.0RC1 version of DLTK.

Best regards,
Andrei Sobolev.

> Actually, the solution for the bug you had open makes things more
> difficult, because istead of Eclipse not adding all the subfolders to
> the classpath, we have to add all of them manually or change all the
> require commmands inside the IDE to start from the project floder
> instead of the script folder.
>
>
> <<< That is, I think the solution for the bug is only valid if, as I'm
> saying, DLTK considers current folder (script folder) automatically when
> running scripts. I've downloaded the new M7a, but I'm still not able to,
> for example, run a script that requires another script under the same
> folder just because that folder (which isn't a src folder itself but a
> subfolder of such one) is not on the build path :( >>>
>
>
>
>
Re: Ruby build path [message #24198 is a reply to message #24163] Wed, 21 May 2008 14:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com

Hi Andrei,

Thnak you very much, I'll be waiting this release to try it out!
Re: Ruby build path [message #24233 is a reply to message #24198] Wed, 21 May 2008 16:52 Go to previous messageGo to next message
Andrey Platov is currently offline Andrey PlatovFriend
Messages: 28
Registered: July 2009
Junior Member
RC1 just released
http://download.eclipse.org/technology/dltk/downloads/drops/ R1.0/S-1.0RC1-200805211222/

We're very interested in your feedback to check if problem understood
well and adequate fix has been provided.

Thank you very much for your help,
Andrey

> Hi Andrei,
>
> Thnak you very much, I'll be waiting this release to try it out!
>
Re: Ruby build path [message #24274 is a reply to message #24233] Thu, 22 May 2008 19:10 Go to previous message
Eclipse UserFriend
Originally posted by: renato3110.yahoo.com.br

Hi Andrey,

Yes, the problem was understood and solved well! Very nice job! I was not
really expecting my suggestion to be heard.

Thank you very much for implementing this!!!
Previous Topic:unable to find method declarations
Next Topic:Reconiling strategy problem in dltk1.0RC1
Goto Forum:
  


Current Time: Tue Apr 23 11:14:50 GMT 2024

Powered by FUDForum. Page generated in 0.04150 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top