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

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

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