On Sunday, September 16, 2012 5:42:50 AM UTC+1, Ruby-Forum.com User wrote:
>
> This standalone program in using mysql and dbi gems 
>   I call this program as such from a model 
>
>      system("ruby standalonepgm.ruby -args ") 
>
> In  rails 2.0 this  worked without any issue. 
> In 3.0 the program exits without any way to capture the error. 
>
>
> Running under console I see that the program dies because it can't find 
> dbi gem! 
>
> If I put dbi gem in the Gemfile and do bundle date  but then there is 
> real trouble. 
> Rails refuse to start  -  "rails server" dies with all kind of issues .. 
> I can put in the screendump .. 
> but that's unimportant  I think. 
>
> There seem to be 2 issues 
> 1. DBI is surely incompatible with the  gods of rails 
> 2. Rails creates a sandbox .. and all programs called must live in that 
> sandbox (that's why just a require statement doesn't suffice). 
>
>
> I don't know what the issue between rails and DBI might be, but the second 
bit is down to bundler. Bundler doesn't allow you to require stuff outside 
the Gemfile because that's how it's sure that you always have a consistent 
set of gems around. Furthermore, when bundler is enabled it sets some 
environment variables (RUBYOPT, BUNDLE_GEMFILE etc...) which will be picked 
up by the ruby running inside your call to system and cause it to also use 
bundler and your Gemfile.

You could either try killing those enviroment variables e.g.
    
    system("RUBYOPT='' ruby standalonepgm.rb ")

Or, probably less jacky, try changing the gemfile entry for dbi to

    gem "dbi", :require => false

which means that gem won't be used unless someone requires it, which should 
hopefully avoid whatever conflict it has with rails while still allowing 
your script to run.

Fred

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/z2IHt7A9IeYJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to