Where is the difference between >system "script/myscript"< and >script/myscript< (via shell)?

hallo everybody,

i’ve searched the web for quite some time now, but didn’t find an
answer to this question (and thus no solution to my problem).

explanation:
i wrote a script to start a DRb-server on a rails-app. what i want to
achieve is to run this script from another application (on the same
machine). everything is working perfectly when i start myscript from a
shell and enter “script/myscript” (without quotes). but when i call it
from my other application like this: system “#{path}/script/myscript”
my tests are failing…

of course there is the obvious difference in ENV[’_’], but even
changing this manually wouldn’t help. i’m looking for a way to get a
“clean” call. (just like from shell)

any ideas?

thanks in advance
dominik

On 20 Oct 2008, at 15:04, none wrote:

shell and enter “script/myscript” (without quotes). but when i call it
from my other application like this: system “#{path}/script/myscript”
my tests are failing…

current working directory is one obvious difference that does screw up
some things.

Fred

current working directory is one obvious difference that does screw up
some things.

Fred

thanks for your quick response!
still, it’s not working. everytime i call an instance-method of
‘some_class’ in my remote application, it crashes.

without copy/paste-ing a whole bunch of code, here is what happens (in
pseudocode):

>> myobject = MyObject.new
>> myobject.save
>> myobject.my_instance_method!
NameError: uninitialized constant MyObject::RemoteAppControlClass
        from (druby://localhost:9003) /home/n0ne/_files/work/_code/
my_remote_app/vendor/rails/activerecord/lib/../../activesupport/lib/
active_support/dependencies.rb:478:in `const_missing'
        from (druby://localhost:9003) ./app/models/my_object.rb:95:in
`my_instance_method!'
        from (druby://localhost:9003) /home/n0ne/_files/work/_code/
my_remote_app/lib/drb_server.rb:30:in `some_method'
        from /home/n0ne/_files/work/_code/my_local_app/app/models/
my_object.rb:97:in `my_instance_method!'
        from (irb):6

explanation:

  • there are two rails-apps ‘my_local_app’ and ‘my_remote_app’
  • both apps share a common database-connection for ‘MyObject’ (with
    the plugin use_db)
  • when ‘my_local_app’ calls ‘my_instance_method!’ it’s redirected (via
    drb_server) to ‘my_remote_app’ and ‘my_instance_method!’ gets
    evaluated there
  • when starting both apps individually this works great! which means
    there is no fundamental error in my code.
  • when starting ‘my_remote_app’ through the ‘remote_app_control_class’
    i get that weird error.
  • a manual start is done by calling ‘script/start_remote_app’
  • a remote startis done in ‘my_local_app’ by the
    ‘remote_app_control_class’ calling ‘system “#{path}/script/
    start_remote_app”’

i can only assume, that there is a problem with the environment ENV or
something similar. is there a way of getting a clean/fresh ENV for my
system call (so that it is just like i would have started it
manually)?

thanks again
dominik

On 21 Okt., 09:43, none [email protected] wrote:

current working directory is one obvious difference that does screw up
some things.

Fred

man, nevermind! i got it. and: you were right, of course! it was the
working directory.
i just had some other stuff failing, so my first tries with changing
the working directory failed as well.

just tried it again and succeeded.

thanks fred

ps: nice talk at the railsconf europe this year! building smaller apps
instead of one big one really got me thinking… thanks!