Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8087 (closed enhancement: wontfix)

Opened 2 years ago

Last modified 1 year ago

[PATCH] Vendor Everything

Reported by: josh Assigned to: core
Priority: normal Milestone: 1.x
Component: Railties Version: edge
Severity: normal Keywords:
Cc: chris@ozmm.org, masterkain, nicwilliams, thewoolleyman, norbauer

Description

Its been a while since we talked about freezing gems.

What I added.

* Rails generator makes 'vendor/gems' folder
* Loads tasks from 'vendor/gems/*/**/tasks/**/*.rake'
* Added gems:freeze and gem:unfreeze tasks
* Added 'vendor/gems' to load path

Who I ripped off.

* Ricks Gem task
* Nicks gem task loader
* Code from Ryans freeze task
* But all inspired by errs Vendor Everything

Attachments

vendor_everything.diff (2.9 kB) - added by josh on 04/17/07 02:09:40.
vendor_gems.diff (29.8 kB) - added by josh on 04/20/07 22:10:01.
Marcel's patch from Rails Core mailing list

Change History

04/17/07 02:09:40 changed by josh

  • attachment vendor_everything.diff added.

04/17/07 06:50:22 changed by Chris Wanstrath

  • cc set to chris@ozmm.org.

+1! Surely this is becoming a standard idiom -- might as well make it easier with this patch.

04/17/07 07:44:23 changed by masterkain

  • cc changed from chris@ozmm.org to chris@ozmm.org, masterkain.

agreed

04/20/07 22:10:01 changed by josh

  • attachment vendor_gems.diff added.

Marcel's patch from Rails Core mailing list

04/21/07 18:40:35 changed by nicwilliams

  • cc changed from chris@ozmm.org, masterkain to chris@ozmm.org, masterkain, nicwilliams.

+1 tally-ho

(follow-up: ↓ 7 ) 04/23/07 16:33:52 changed by thewoolleyman

One problem - how does this handle multiple platforms? In other words, if my app is developed and used on different platforms? The same version of a gem can have multiple platforms, which are packaged with different binaries. If you freeze a gem version for one platform into vendor, the app would not run on another platform that is incompatible.

04/23/07 16:35:45 changed by thewoolleyman

  • cc changed from chris@ozmm.org, masterkain, nicwilliams to chris@ozmm.org, masterkain, nicwilliams, thewoolleyman@gmail.com.

04/23/07 16:37:04 changed by thewoolleyman

  • cc changed from chris@ozmm.org, masterkain, nicwilliams, thewoolleyman@gmail.com to chris@ozmm.org, masterkain, nicwilliams, thewoolleyman.

(in reply to: ↑ 4 ; follow-up: ↓ 8 ) 04/23/07 19:33:18 changed by josh

Replying to thewoolleyman:

One problem - how does this handle multiple platforms? In other words, if my app is developed and used on different platforms? The same version of a gem can have multiple platforms, which are packaged with different binaries. If you freeze a gem version for one platform into vendor, the app would not run on another platform that is incompatible.

Most gems don't need to be compiled and are cross platform. And if it does, don't freeze it. 80/20 rule.

(in reply to: ↑ 7 ) 04/23/07 23:27:49 changed by thewoolleyman

Replying to josh:

Most gems don't need to be compiled and are cross platform. And if it does, don't freeze it. 80/20 rule.

So should the name of this ticket be changed to "Vendor Everything that is Pure Ruby"? ;)

04/23/07 23:48:37 changed by josh

  • summary changed from [PATCH] Vendor Everything to [PATCH] Vendor Everything (expect Java).

Better?

04/23/07 23:51:05 changed by josh

  • summary changed from [PATCH] Vendor Everything (expect Java) to [PATCH] Vendor Everything.

j/k

What gems are you exactly talking about?

Like hpricot? If the gem requires C compiling, some who argue that the gem would have better performance if compiled on the server.

04/24/07 00:41:11 changed by thewoolleyman

There's lots of gems that have ms-windows platforms. Platform-related discussions are frequent on the rubygems mailing list (and there's one regarding jruby in progress right now).

You could find out yourself by grepping the local gem specs on a windows machine to see what the platform is. As an unrelated experiment, I just installed all the gems off my mac onto a clean Windows XP rubygems installation. I'll try to see how many have a /mswin/ platform and report the results.

Also, I agree that it would probably be a good idea to compile any gem that needs compiling on the actual machine which will be running the gem. If you agree with this, then "Vendor Everything that is Pure Ruby" is actually pretty appropriate.

-- Chad

04/24/07 00:47:00 changed by josh

Sure, I agree, it only applies to ruby code. But I don't find it a huge problem.

The title was just named after Chris Wanstrath's popular post, "Vendor Everything".

04/24/07 01:45:27 changed by thewoolleyman

Here's some empirical data. These are gem specs which were on my mac, and I then installed on Windows XP, grepped for a platform matching "win":

name: ParseTree name: RubyInline name: SwedishTV name: ZenTest name: actionmailer name: actionpack name: actionwebservice name: activerecord name: activesupport name: acts_as_searchable name: aws-s3 name: builder name: capistrano name: cgi_multipart_eof_fix name: cheat name: coderay name: daemons name: fastthread platform: mswin32 name: firebrigade_api name: fjson name: flexmock name: fxri name: fxruby platform: mswin32 name: gem_plugin name: heckle name: hpricot platform: mswin32 name: log4r name: meta_project name: mime-types name: mkrf name: money name: mongrel platform: mswin32 name: needle name: net-sftp name: net-ssh name: piston name: rails name: rc-rest name: rjb platform: mswin32 name: rspec name: ruby-doom name: ruby2ruby name: rutils name: s3-ruby name: s33r name: sources name: sqlite3-ruby platform: mswin32 name: syntax name: tinderbox name: win32-clipboard name: win32-dir platform: mswin32 name: win32-eventlog name: win32-file-stat platform: mswin32 name: win32-file-stat platform: mswin32 name: win32-process name: win32-sapi platform: mswin32 name: win32-sound name: windows-pr name: windows-pr name: windows-pr name: x10-cm17a platform: i386-mswin32 name: xml-simple

In addition, these were installed on mac but don't have a windows build available (and thus won't even work on Windows):

name: fastthread name: ferret name: rmagick name: termios name: x10-cm17a

So, there's not too many, but some popular ones, like hpricot, mongrel/fastthread, and sqlite. You could probably perform this operation on the entire rubygems repository, but it would be difficult, since the "gem specification" command can't be run against a remote repository.

04/24/07 01:47:58 changed by thewoolleyman

Hmm. That didn't work too well, but you get the idea. Put in the newlines if you want...

04/24/07 01:58:33 changed by josh

Many of those gems listed are pure ruby but have some little modifications for windows. Most of contain a bat script to replace the shell script bundle. Take rails for example. The rails command uses the bat file on windows and the shell script on unix.

However all this doesn't make a difference. You aren't freezing utilities, you are freezing libraries. You can still load the actual library portion.

Its useless to freeze system utilities like piston or capistrano. Maybe not useless, but not the point.

This patch a simple solution to freeze ruby code in vendor/gems and it works in most cases.

04/24/07 06:28:01 changed by nicwilliams

I do think its worth investigating a solution that supports platform-specific gems when a rails app is first run.

E.g. if you link in 'hpricot 0.5' vs freezing it, then when you launch your app, and if hpricot 0.5 isn't available you are asked to install it, or the app quits with an error.

Auto-install will be available when its supported by RubyGems in the future.

Whatever our solution, we should consider the gems that have platform specific versions.

Similarly, if you develop your app on a Mac, and want to deploy to Tomcat on jruby... well, that's a funny coloured kettle of fish to consider oneday.

Perhaps this ticket is best developed in one of the existing gem solutions (http://errtheblog.com/post/2120), and then we integrate the gem code into core later, or link in as a dependency of rails gem.

04/24/07 06:31:57 changed by nicwilliams

I'll have a look into the missing code from the gemsonrails gem (http://drnicwilliams.com/2007/02/09/railsrally-2007-and-gemsonrails/#railsrally-gemsonrails) towards "complaining on missing gem versions that are linked by not frozen".

Anyone else who wants to look at the code via SVN its at http://rubyforge.org/scm/?group_id=2391

Easy peasy.

Nic

04/24/07 12:17:00 changed by thewoolleyman

Coincidentally (or maybe not) the RubyGems developers seem to be ready to tackle the platform issue:

http://rubyforge.org/pipermail/rubygems-developers/2007-April/002733.html

04/25/07 02:50:13 changed by thewoolleyman

04/25/07 03:05:32 changed by josh

We should probably move this debate over to the mailing list so we don't clog the internet tubes to the trac server.

http://groups.google.com/group/rubyonrails-core/browse_thread/thread/e48c42e133ee2bf9/#

Still, this whole platform thing doesn't concern me, and I leave it up to you to PDI.

06/07/07 17:57:10 changed by norbauer

  • cc changed from chris@ozmm.org, masterkain, nicwilliams, thewoolleyman to chris@ozmm.org, masterkain, nicwilliams, thewoolleyman, norbauer.

06/18/07 14:39:14 changed by josh

  • status changed from new to closed.
  • resolution set to wontfix.

Idea still needs more work. Closing this ticket. If you are still back the idea, start up your own ticket (Please don't reopen this one).

06/18/07 20:35:05 changed by thewoolleyman

Just for future reference and closure, can we have a summary of the technical issues that caused this ticket to be killed? Links to other external references/articles/blogs would be fine.

I'm just interested in the underlying validity of the whole "vendor everything" approach, and whether it's fundamentally impossible, or just not possible in the immediate timeframe.

If you don't want to bloat this ticket with more comments, feel free to email me at thewoolleyman@gmail.com.

Thanks! -- Chad

06/18/07 20:36:52 changed by josh

No problem Chad. The main article you're looking for is "err.the_blog.find_by_title('Vendor Everything')" (http://errtheblog.com/post/2120).