SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler offline
Tricking Bundler
              aka developing app & gem w/o roundtrips
             aka no more
             gem.git (at master) is not checked out. Please run `bundle install`




                                                              Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
Bundler + Git

                           Gem dependencies manager (that gets
                           caching right ;-)
                           Allows to install gems from Git
                           repositories
                           This trick is for Git gems only



                                                   Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
How does it work

                           Parses Gemfile & Gemfile.lock
                           git fetch && git checkout in
                           `gem environment gemdir`/bundler/
                           gems/$NAME-$REF12
                           Add the checked out directory to
                           Ruby’s $LOAD_PATH



                                                   Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
Problem

                           Your project is in ~/code/app
                           Your gem is in ~/code/gem
                           You run the app and need to change
                           the gem code
                           cd ~/code/gem; <code>; git commit;
                           git push; cd ~/code/app; bundle up
                           gem # DOESN’T fit the job


                                                   Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
Symlinks to the
                                  rescue!
                           Bundler directory contains all git-
                           fetched gems with this format:

                           $GEM_NAME-$REF12 (first 12 chars of
                           the HEAD SHA1 commit id)
                           Bash script gets ~/code/gems HEAD
                           ref && ln -s ~/code/gem to the
                           directory bundler expects the gem in
                           Profit!

                                                   Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
Solution

                           You edit the gem code directly in
                           your ~/code/gem - app picks it up
                           Once done, git commit && git show to
                           get HEAD SHA1 id
                           Update SHA1 in Gemfile.lock directly
                           symlink-gem ../gem


                                                   Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
Switching branches?

                           master branch needs commit c4feb4be
                           develop branch needs commit de4db3ef
                           (develop) git co master; for gem in
                           a b c d; do symlink-gem ../$gem;
                           done
                           # DOESN’T cut the job either ;-)



                                                   Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
Bundle::LockFileParser
                 is your friend
                           Ruby script gets all dependencies in
                           a nicely wrapped Array of Sources
                           For each Git-fetched $gem, check out
                           the commit required by Gemfile.lock
                           in your ~/code/$gem
                           %x{ symlink-gem #{gem} }
                           Why not git post-checkout-hook? :)


                                                      Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
Switch branches
              w/post-checkout-hook
            18:04:02 [vjt@debian ~/code/app] (develop) $ git co master
           Switched to branch 'master'

           [git://github.com/vjt/rtf.git] Already on 'master'

           [git://github.com/vjt/dep1.git] HEAD is now at df61eac...
           Fixed stuff

           [git://github.com/vjt/dep2.git] Previous HEAD position was
           45509fa... Experimental stuff
           Switched to branch 'master'

           [git://github.com/ifad/activerecord-sybase-adapter.git]
           Already on 'master'


                                                    Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012
Thanks!

                                   @vjt
                              vjt@openssl.it
                            http://sindro.me/
                           http://github.com/vjt


                                          Rome Ruby Social Club - March 23, 2012


Saturday, March 24, 2012

Mais conteúdo relacionado

Semelhante a Tricking Bundler

Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesHiroshi SHIBATA
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?Hiroshi SHIBATA
 
RubyConfBD 2013 decouple, bundle and share with ruby gems
RubyConfBD 2013   decouple, bundle and share with ruby gems RubyConfBD 2013   decouple, bundle and share with ruby gems
RubyConfBD 2013 decouple, bundle and share with ruby gems nhm taveer hossain khan
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Hiroshi SHIBATA
 
Presentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugPresentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugSébastien Deleuze
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyHiroshi SHIBATA
 
Simple Ruby DSL Techniques: Big Project Impact!
Simple Ruby DSL Techniques: Big Project Impact!Simple Ruby DSL Techniques: Big Project Impact!
Simple Ruby DSL Techniques: Big Project Impact!Aman King
 
Debugging Rails 3 Applications
Debugging Rails 3 ApplicationsDebugging Rails 3 Applications
Debugging Rails 3 ApplicationsNathan Broadbent
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in UnityRifauddin Tsalitsy
 

Semelhante a Tricking Bundler (14)

Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard Libraries
 
Aegir
AegirAegir
Aegir
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?
 
RubyConfBD 2013 decouple, bundle and share with ruby gems
RubyConfBD 2013   decouple, bundle and share with ruby gems RubyConfBD 2013   decouple, bundle and share with ruby gems
RubyConfBD 2013 decouple, bundle and share with ruby gems
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Presentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugPresentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJug
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
 
Introduzione a GIT - Webinar Zend
Introduzione a GIT - Webinar ZendIntroduzione a GIT - Webinar Zend
Introduzione a GIT - Webinar Zend
 
Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Ruby on Rails 3 Day BC
 
Simple Ruby DSL Techniques: Big Project Impact!
Simple Ruby DSL Techniques: Big Project Impact!Simple Ruby DSL Techniques: Big Project Impact!
Simple Ruby DSL Techniques: Big Project Impact!
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 
Debugging Rails 3 Applications
Debugging Rails 3 ApplicationsDebugging Rails 3 Applications
Debugging Rails 3 Applications
 
PDF Ruby on Rails 3 Day BC
 PDF Ruby on Rails 3 Day BC PDF Ruby on Rails 3 Day BC
PDF Ruby on Rails 3 Day BC
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 

Último

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Último (20)

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Tricking Bundler

  • 1. Tricking Bundler aka developing app & gem w/o roundtrips aka no more gem.git (at master) is not checked out. Please run `bundle install` Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 2. Bundler + Git Gem dependencies manager (that gets caching right ;-) Allows to install gems from Git repositories This trick is for Git gems only Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 3. How does it work Parses Gemfile & Gemfile.lock git fetch && git checkout in `gem environment gemdir`/bundler/ gems/$NAME-$REF12 Add the checked out directory to Ruby’s $LOAD_PATH Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 4. Problem Your project is in ~/code/app Your gem is in ~/code/gem You run the app and need to change the gem code cd ~/code/gem; <code>; git commit; git push; cd ~/code/app; bundle up gem # DOESN’T fit the job Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 5. Symlinks to the rescue! Bundler directory contains all git- fetched gems with this format: $GEM_NAME-$REF12 (first 12 chars of the HEAD SHA1 commit id) Bash script gets ~/code/gems HEAD ref && ln -s ~/code/gem to the directory bundler expects the gem in Profit! Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 6. Solution You edit the gem code directly in your ~/code/gem - app picks it up Once done, git commit && git show to get HEAD SHA1 id Update SHA1 in Gemfile.lock directly symlink-gem ../gem Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 7. Switching branches? master branch needs commit c4feb4be develop branch needs commit de4db3ef (develop) git co master; for gem in a b c d; do symlink-gem ../$gem; done # DOESN’T cut the job either ;-) Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 8. Bundle::LockFileParser is your friend Ruby script gets all dependencies in a nicely wrapped Array of Sources For each Git-fetched $gem, check out the commit required by Gemfile.lock in your ~/code/$gem %x{ symlink-gem #{gem} } Why not git post-checkout-hook? :) Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 9. Switch branches w/post-checkout-hook 18:04:02 [vjt@debian ~/code/app] (develop) $ git co master Switched to branch 'master' [git://github.com/vjt/rtf.git] Already on 'master' [git://github.com/vjt/dep1.git] HEAD is now at df61eac... Fixed stuff [git://github.com/vjt/dep2.git] Previous HEAD position was 45509fa... Experimental stuff Switched to branch 'master' [git://github.com/ifad/activerecord-sybase-adapter.git] Already on 'master' Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012
  • 10. Thanks! @vjt vjt@openssl.it http://sindro.me/ http://github.com/vjt Rome Ruby Social Club - March 23, 2012 Saturday, March 24, 2012