|
Does anyone know if compiling rb files to class files using jrubyc works with Rails?
Rich |
|
Rich Manalang wrote:
> Does anyone know if compiling rb files to class files using jrubyc works > with Rails? I believe Peter Chan was doing something with this, and possible Ricardo Trinidade...you guys out there? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
I compiled a subset of Rails, activerecord and activesupport, into java byte code and found it working very well in my app.
Peter -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Charles Oliver Nutter Sent: Friday, October 10, 2008 1:10 AM To: [hidden email] Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files Rich Manalang wrote: > Does anyone know if compiling rb files to class files using jrubyc works > with Rails? I believe Peter Chan was doing something with this, and possible Ricardo Trinidade...you guys out there? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Thanks! I'll create a rake task to compile everything in my app dir and see if it works.
Rich On Thu, Oct 9, 2008 at 11:33 PM, Peter K Chan <[hidden email]> wrote: I compiled a subset of Rails, activerecord and activesupport, into java byte code and found it working very well in my app. |
|
Did my own test on an existing JRoR app (jrubyc app/) and it didn't work. Complained about an application_support dependency. Looking into it further.
Peter, did you compile your app source or just the vendor/rails dir? Rich On Fri, Oct 10, 2008 at 12:00 PM, Rich Manalang <[hidden email]> wrote:
|
|
Can you post the exact error message?
I havent noticed any problem with loading compiled code, compared to ruby source. Mixed loading of compiled and plain source also worked. You may want to double check to make sure that you have at least something called application_support.rb or application_support.class (with the appropriate java package prefix, if applicable) and that it is inside the loadpath or classpath. I just compiled activerecord and activesupport, ensure that the resulting files are in classpath, and was able to load them from my application code. Peter From: Rich Manalang [mailto:[hidden email]] Sent: Friday, October 10, 2008 3:01 PM To: [hidden email] Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files Did my own test on an existing JRoR app (jrubyc app/) and it didn't work. Complained about an application_support dependency. Looking into it further. Peter, did you compile your app source or just the vendor/rails dir? Rich On Fri, Oct 10, 2008 at 12:00 PM, Rich Manalang <[hidden email]> wrote: Thanks! I'll create a rake task to compile everything in my app dir and see if it works. Rich On Thu, Oct 9, 2008 at 11:33 PM, Peter K Chan <[hidden email]> wrote: I compiled a subset of Rails, activerecord and activesupport, into java byte code and found it working very well in my app. Peter -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Charles Oliver Nutter Sent: Friday, October 10, 2008 1:10 AM To: [hidden email] Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files Rich Manalang wrote: > Does anyone know if compiling rb files to class files using jrubyc works > with Rails? I believe Peter Chan was doing something with this, and possible Ricardo Trinidade...you guys out there? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Here's what I did:
> jrubyc app/ > jruby script/server <- rb/class files together... works fine. > rm `find app/ -name "*.rb"` > jruby script/server <- class files only... fails with the following error: => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails 2.1.0 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Exiting /Users/richmanalang/dev/connect.git/vendor/rails/activesupport/lib/active_support/dependencies.rb:512:in `require': uninitialized constant ApplicationHelper (NameError) from /Users/richmanalang/dev/connect.git/vendor/rails/railties/lib/commands/server.rb:39 from /Users/richmanalang/dev/connect.git/vendor/rails/railties/lib/commands/server.rb:27:in `require' from /Users/richmanalang/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from script/server:3 Thoughts? Rich On Fri, Oct 10, 2008 at 1:30 PM, Peter K Chan <[hidden email]> wrote: Can you post the exact error message? |
|
I dont use the full Rails framework myself, so I have to defer other experts
on this subject. The only thing that I can think of is for you to trace where the error originates. Figure out what file defines ApplicationHelper and what line is loading it, and from that point determine what is not working in loading the compiled file. You may also find it helpful to leave the source file and see if the app can pick that up, instead of the compiled version. Peter From: Rich Manalang [mailto:[hidden email]] Sent: Friday, October 10, 2008 3:42 PM To: [hidden email] Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files Here's what I did: > jrubyc app/ > jruby script/server <- rb/class files together... works fine. > rm `find app/ -name "*.rb"` > jruby script/server <- class files only... fails with the following error: => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails 2.1.0 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Exiting /Users/richmanalang/dev/connect.git/vendor/rails/activesupport/lib/active_supp ort/dependencies.rb:512:in `require': uninitialized constant ApplicationHelper (NameError) from /Users/richmanalang/dev/connect.git/vendor/rails/railties/lib/commands/server. rb:39 from /Users/richmanalang/dev/connect.git/vendor/rails/railties/lib/commands/server. rb:27:in `require' from /Users/richmanalang/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.r b:27:in `require' from script/server:3 Thoughts? Rich On Fri, Oct 10, 2008 at 1:30 PM, Peter K Chan <[hidden email]> wrote: Can you post the exact error message? I haven't noticed any problem with loading compiled code, compared to ruby source. Mixed loading of compiled and plain source also worked. You may want to double check to make sure that you have at least something called application_support.rb or application_support.class (with the appropriate java package prefix, if applicable) and that it is inside the loadpath or classpath. I just compiled activerecord and activesupport, ensure that the resulting files are in classpath, and was able to load them from my application code. Peter From: Rich Manalang [mailto:[hidden email]] Sent: Friday, October 10, 2008 3:01 PM To: [hidden email] Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files Did my own test on an existing JRoR app (jrubyc app/) and it didn't work. Complained about an application_support dependency. Looking into it further. Peter, did you compile your app source or just the vendor/rails dir? Rich On Fri, Oct 10, 2008 at 12:00 PM, Rich Manalang <[hidden email]> wrote: Thanks! I'll create a rake task to compile everything in my app dir and see if it works. Rich On Thu, Oct 9, 2008 at 11:33 PM, Peter K Chan <[hidden email]> wrote: I compiled a subset of Rails, activerecord and activesupport, into java byte code and found it working very well in my app. Peter -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Charles Oliver Nutter Sent: Friday, October 10, 2008 1:10 AM To: [hidden email] Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files Rich Manalang wrote: > Does anyone know if compiling rb files to class files using jrubyc works > with Rails? I believe Peter Chan was doing something with this, and possible Ricardo Trinidade...you guys out there? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Looks like the dependencies module in active support tries to load dependencies by appending the .rb to the constant names which is why it's failing. I'm patching these now to see if I can get it to work.
More to come... Rich On Fri, Oct 10, 2008 at 2:48 PM, Peter K Chan <[hidden email]> wrote: I don't use the full Rails framework myself, so I have to defer other experts |
|
I seem to remember that JRuby automatically handles loading file
ending in .rb to using the compiled version. But it has been a while (and a few
versions), so maybe you need to discard the .rb suffix. Peter From: Rich Manalang
[mailto:[hidden email]] Looks like the dependencies
module in active support tries to load dependencies by appending the .rb to the
constant names which is why it's failing. I'm patching these now to see
if I can get it to work. On Fri, Oct 10, 2008 at 2:48 PM, Peter K Chan <[hidden email]> wrote: I don't use the full Rails framework myself, so I have to
defer other experts
Sent: Friday, October 10, 2008 3:42 PM To: [hidden email] Here's what I did: |
|
I'll wait to see from Rich, but you're right, it should try to find both
foo.class and foo.rb (in that order) if you require 'foo.rb', but I'm not sure whether we made it do that for load or not. I'd have to check the code, and I'm working on something else at the moment. Peter K Chan wrote: > I seem to remember that JRuby automatically handles loading file ending > in .rb to using the compiled version. But it has been a while (and a few > versions), so maybe you need to discard the .rb suffix. > > > > Peter > > > > *From:* Rich Manalang [mailto:[hidden email]] > *Sent:* Friday, October 10, 2008 5:02 PM > *To:* [hidden email] > *Subject:* Re: [jruby-user] Compiling Rails app/**/* to .class files > > > > Looks like the dependencies module in active support tries to load > dependencies by appending the .rb to the constant names which is why > it's failing. I'm patching these now to see if I can get it to work. > > More to come... > > Rich > > On Fri, Oct 10, 2008 at 2:48 PM, Peter K Chan <[hidden email] > <mailto:[hidden email]>> wrote: > > I don't use the full Rails framework myself, so I have to defer other > experts > on this subject. > > The only thing that I can think of is for you to trace where the error > originates. Figure out what file defines ApplicationHelper and what line is > loading it, and from that point determine what is not working in loading the > compiled file. > > You may also find it helpful to leave the source file and see if the app can > pick that up, instead of the compiled version. > > > Peter > > From: Rich Manalang [mailto:[hidden email] > <mailto:[hidden email]>] > > Sent: Friday, October 10, 2008 3:42 PM > > To: [hidden email] <mailto:[hidden email]> > Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files > > Here's what I did: > > > jrubyc app/ > > jruby script/server <- rb/class files together... works fine. > > rm `find app/ -name "*.rb"` > > jruby script/server <- class files only... fails with the following > error: > > => Booting Mongrel (use 'script/server webrick' to force WEBrick) > => Rails 2.1.0 application starting on http://0.0.0.0:3000 > => Call with -d to detach > => Ctrl-C to shutdown server > ** Starting Mongrel listening at 0.0.0.0:3000 <http://0.0.0.0:3000> > ** Starting Rails with development environment... > JRuby limited openssl loaded. gem install jruby-openssl for full support. > http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL > Exiting > /Users/richmanalang/dev/connect.git/vendor/rails/activesupport/lib/active_supp > ort/dependencies.rb:512:in `require': uninitialized constant > ApplicationHelper > (NameError) > from > /Users/richmanalang/dev/connect.git/vendor/rails/railties/lib/commands/server. > rb:39 > from > /Users/richmanalang/dev/connect.git/vendor/rails/railties/lib/commands/server. > rb:27:in `require' > from > /Users/richmanalang/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.r > b:27:in `require' > from script/server:3 > > Thoughts? > > Rich > On Fri, Oct 10, 2008 at 1:30 PM, Peter K Chan <[hidden email] > <mailto:[hidden email]>> wrote: > Can you post the exact error message? > > I haven't noticed any problem with loading compiled code, compared to ruby > source. Mixed loading of compiled and plain source also worked. You may want > to double check to make sure that you have at least something called > application_support.rb or application_support.class (with the > appropriate java > package prefix, if applicable) and that it is inside the loadpath or > classpath. > > I just compiled activerecord and activesupport, ensure that the resulting > files are in classpath, and was able to load them from my application code. > > Peter > > From: Rich Manalang [mailto:[hidden email] > <mailto:[hidden email]>] > Sent: Friday, October 10, 2008 3:01 PM > To: [hidden email] <mailto:[hidden email]> > Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files > > Did my own test on an existing JRoR app (jrubyc app/) and it didn't work. > Complained about an application_support dependency. Looking into it > further. > > Peter, did you compile your app source or just the vendor/rails dir? > > Rich > On Fri, Oct 10, 2008 at 12:00 PM, Rich Manalang <[hidden email] > <mailto:[hidden email]>> > wrote: > Thanks! I'll create a rake task to compile everything in my app dir and see > if it works. > > Rich > > On Thu, Oct 9, 2008 at 11:33 PM, Peter K Chan <[hidden email] > <mailto:[hidden email]>> wrote: > I compiled a subset of Rails, activerecord and activesupport, into java byte > code and found it working very well in my app. > > Peter > > -----Original Message----- > From: [hidden email] <mailto:[hidden email]> > [mailto:[hidden email] <mailto:[hidden email]>] On > Behalf Of > Charles Oliver Nutter > Sent: Friday, October 10, 2008 1:10 AM > To: [hidden email] <mailto:[hidden email]> > Subject: Re: [jruby-user] Compiling Rails app/**/* to .class files > > Rich Manalang wrote: > > Does anyone know if compiling rb files to class files using jrubyc works > > with Rails? > > I believe Peter Chan was doing something with this, and possible Ricardo > Trinidade...you guys out there? > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Ok... I got it to work (compiled app/ and lib/), but I had to modify rails/activesupport/lib/active_support/dependencies.rb. This file loads all deps during rails initialization and looks specifically for *.rb files. I had to add *.class to the searches.
I've attached the diff. I'd love for rails to be able to do this automatically, how would you guys suggest getting this stuff to rails core? Rich On Fri, Oct 10, 2008 at 3:12 PM, Charles Oliver Nutter <[hidden email]> wrote: I'll wait to see from Rich, but you're right, it should try to find both foo.class and foo.rb (in that order) if you require 'foo.rb', but I'm not sure whether we made it do that for load or not. I'd have to check the code, and I'm working on something else at the moment. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
FYI -- I've forked rails and added my changes here:
http://github.com/manalang/rails/commit/29de7f2746e4809e8f1e010bda558ab32c522f43 Rich On Mon, Oct 13, 2008 at 3:11 PM, Rich Manalang <[hidden email]> wrote:
|
|
In reply to this post by manalang
Rich Manalang wrote:
> Ok... I got it to work (compiled app/ and lib/), but I had to modify > rails/activesupport/lib/active_support/dependencies.rb. This file loads > all deps during rails initialization and looks specifically for *.rb > files. I had to add *.class to the searches. > > I've attached the diff. I'd love for rails to be able to do this > automatically, how would you guys suggest getting this stuff to rails core? I think we should actually modify JRuby so that "load 'foo.rb'" will also look for .class, since basically this is like .py/.pyc in Python and .rb/.rbc in Rubinius; the .class version should be treated as an equivalent compiled version of the .rb file. Agreed? I think we may have had a bug on this previous and either not fixed it or punted on it, since it's obviously not doing that. - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
I agree this should be in JRuby, but it looks like ActiveSupport overrides load and require... which is why it doesn't work out of the box.
Rich On Tue, Oct 14, 2008 at 5:22 PM, Charles Oliver Nutter <[hidden email]> wrote:
|
|
Rich Manalang wrote:
> I agree this should be in JRuby, but it looks like ActiveSupport > overrides load and require... which is why it doesn't work out of the box. Eventually it needs to fall back on require/load logic though, which is where JRuby is falling down: ~/projects/jruby ➔ vi foo.rb ~/projects/jruby ➔ jrubyc foo.rb Compiling foo.rb to class foo ~/projects/jruby ➔ rm foo.rb ~/projects/jruby ➔ jruby -e "load './foo.rb'" -e:1:in `load': No such file to load -- ./foo.rb (LoadError) from -e:1 ~/projects/jruby ➔ jruby -e "load './foo.class'" here I will file a bug for 1.1.5. I see the light now, and believe load should search for both .class and .rb when requested to load xxx.rb. - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
