{"id":21824435,"url":"https://github.com/shopify/bootboot","last_synced_at":"2025-05-14T01:11:16.264Z","repository":{"id":33864732,"uuid":"157651245","full_name":"Shopify/bootboot","owner":"Shopify","description":"Dualboot your Ruby app made easy","archived":false,"fork":false,"pushed_at":"2024-11-18T12:15:59.000Z","size":99,"stargazers_count":439,"open_issues_count":12,"forks_count":32,"subscribers_count":371,"default_branch":"main","last_synced_at":"2025-05-10T12:37:32.659Z","etag":null,"topics":["boot","dependencies","tooling"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shopify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-15T04:17:29.000Z","updated_at":"2025-05-08T03:47:03.000Z","dependencies_parsed_at":"2024-06-21T07:12:03.719Z","dependency_job_id":"0e648d3c-c1bd-4e91-8d7a-8667e57f7e8a","html_url":"https://github.com/Shopify/bootboot","commit_stats":{"total_commits":72,"total_committers":21,"mean_commits":"3.4285714285714284","dds":0.6388888888888888,"last_synced_commit":"2ee386b19ca76d40cd31bcb534d9ed24637872e8"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Fbootboot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Fbootboot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Fbootboot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Fbootboot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shopify","download_url":"https://codeload.github.com/Shopify/bootboot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253568691,"owners_count":21928909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boot","dependencies","tooling"],"created_at":"2024-11-27T17:58:06.352Z","updated_at":"2025-05-14T01:11:16.222Z","avatar_url":"https://github.com/Shopify.png","language":"Ruby","readme":"## 👢👢 Bootboot   - [![Build Status](https://github.com/Shopify/bootboot/actions/workflows/ci.yml/badge.svg)](https://github.com/Shopify/bootboot/actions/workflows/ci.yml)\n\nIntroduction\n------------\nBootboot is a [Bundler plugin](https://bundler.io/v1.17/guides/bundler_plugins.html#what-is-a-plugin) meant to help dual boot your ruby application.\n\n#### What is \"Dual booting\"?\nIn this context, dual boot is the process of booting your application with a different set of dependencies. This technique has become very popular in the Ruby community to help applications safely upgrade dependencies. If you want to learn more about it, have a look at this [conference talk](https://www.youtube.com/watch?v=I-2Xy3RS1ns\u0026t=368s) by @rafaelfranca.\n\nThere are two schools on how to dual boot your app, each having advantages and disadvantages.\n1) Use three Gemfiles. One with current production dependencies, a second with an alternate \"next\" set of dependencies, and a third containing the dependencies that both Gemfiles have in common.\n```ruby\n# Gemfile.common\ngem \"some_gem\"\n\n# Gemfile\ngem \"rails\", \"~\u003e 6.1.7.3\"\neval_gemfile \"Gemfile.common\"\n\n# Gemfile.next\ngem \"rails\", \"~\u003e 7.0.4.3\"\neval_gemfile \"Gemfile.common\"\n```\n\n2) Have a single Gemfile containing dependencies separated by environment sensitive `if` statements.\n```ruby\n# Gemfile\n\nif ENV['DEPENDENCIES_NEXT']\n  gem \"rails\", \"~\u003e 7.0.4.3\"\nelse\n  gem \"rails\", \"~\u003e 6.1.7.3\"\nend\n```\n-----------------------------\nThe former doesn't require any Bundler workaround but you need to deal with three Gemfiles and the [confusion](https://github.com/bundler/bundler/issues/6777#issuecomment-436771340) that comes with it.\nThe latter is the approach we decided to take at Shopify and it worked very well for us for multiple years.\n\nNo matter what approach you decide to take, you'll need to create tooling to ensure that all the lockfiles are in sync whenever a developer updates a dependency.\n\nBootboot is only useful if you decide to follow the second approach. It creates the required tooling as well as the Bundler workaround needed to enable dual booting.\n\nInstallation\n------------\n1) In your Gemfile, add this\n```ruby\nplugin 'bootboot', '~\u003e 0.2.2'\n```\n2) Run `bundle install \u0026\u0026 bundle bootboot`\n3) You're done. Commit the Gemfile and the Gemfile_next.lock\n\nNote: You should only run `bundle bootboot` once to install the plugin, otherwise your Gemfile will get updated each time you run it.\n\nDual boot it!\n------------\nIf you want to boot using the dependencies from the `Gemfile_next.lock`, run any bundler command prefixed with the `DEPENDENCIES_NEXT=1` ENV variable. I.e. `DEPENDENCIES_NEXT=1 bundle exec irb`.\n\n**Note:** `bootboot` will use the gems and Ruby version specified per environment in your `Gemfile` to resolve dependencies and keep `Gemfile.lock` and `Gemfile_next.lock` in sync, but it does not do any magic to actually change the running Ruby version or install the gems in the environment you are not currently running, it simply tells Bundler which Ruby and gem versions to use in its resolution algorithm and keeps the lock files in sync. If you are a developer who is not involved in updating the dependency set, this should not affect you, simply use bundler normally. _However_, if you are involved in the dependency changes directly, you will often have to run `DEPENDENCIES_NEXT=1 bundle install` after making changes to the dependencies.\n\n```sh\n# This will update Gemfile.lock and Gemfile_next.lock and install the gems\n# specified in Gemfile.lock:\n$ bundle update some_gem\n# This will actually install the gems specified in Gemfile_next.lock\n$ DEPENDENCIES_NEXT=1 bundle install\n```\n\nDual boot different Ruby versions\n---------------------------------\n\nWhile dual booting is often used for framework upgrades, it is also possible to use `bootboot` to dual boot two Ruby versions, each with its own set of gems.\n\n```ruby\n# Gemfile\n\nif ENV['DEPENDENCIES_NEXT']\n  ruby '3.2.2'\nelse\n  ruby '3.1.4'\nend\n```\n\nDual booting Ruby versions does incur some additional complications however, see the examples following for more detail.\n\nExample: updating a gem while dual booting Ruby versions\n--------------------------------------------------------\n\nTo dual boot an app while upgrading from Ruby 3.1.4 to Ruby 3.2.2, your Gemfile would look like this:\n\n```ruby\n# Gemfile\n\nif ENV['DEPENDENCIES_NEXT']\n  ruby '3.2.2'\nelse\n  ruby '3.1.4'\nend\n```\n\nAfter running `bundle install`, `Gemfile.lock` will have:\n\n```\nRUBY VERSION\n   ruby 3.1.4p206\n```\n\nand `Gemfile_next.lock` will have:\n\n```\nRUBY VERSION\n   ruby 3.2.2p114\n```\nAssuming there's a gem `some_gem` with the following constraints in its gemspecs:\n\n```ruby\n# some_gem-1.0.gemspec\nspec.version = \"1.0\"\nspec.required_ruby_version = '\u003e= 3.1.4'\n```\n\n```ruby\n# some_gem-2.0.gemspec\nspec.version = \"2.0\"\nspec.required_ruby_version = '\u003e= 3.2.2'\n```\n\nRunning `bundle update some_gem` will use Ruby 3.1.4 to resolve `some_gem` for `Gemfile.lock` and Ruby 3.2.2 to resolve `some_gem` for `Gemfile_next.lock` with the following results:\n\nGemfile.lock:\n```\nspecs:\n  some_gem (1.0)\n```\n\nGemfile_next.lock:\n```\nspecs:\n  some_gem (2.0)\n```\n\n**Note:** It is important to note that at this point, `some_gem 2.0` **will not** be installed on your system, it will simply be specified in `Gemfile_next.lock`, since installing it on the system would require changing the running Ruby version. This is sufficient to keep `Gemfile_next.lock` in sync, but is a potential source of confusion. To install gems under both versions of Ruby, see the next section.\n\nVendoring both sets of gems\n---------------------------\nTo vendor both sets of gems, make sure caching is enabled by checking `bundle config` or bundle gems using `bundle pack`.\n\n```bash\nbundle pack\nDEPENDENCIES_NEXT=1 bundle pack\n```\n\n### Example: running Ruby scripts while dual booting Ruby versions\n\nWhen running Ruby scripts while dual booting two different Ruby versions, you have to remember to do two things simultaneously for every command:\n- Run the command with the correct version of Ruby\n- Add the DEPENDENCIES_NEXT environment variable to tell bundler to use `Gemfile_next.lock`\n\nSo to run a spec in both versions, the workflow would look like this (assuming chruby for version management):\n\n```sh\n$ chruby 3.1.4\n$ bundle exec rspec spec/some_spec.rb\n$ chruby 3.2.2\n$ DEPENDENCIES_NEXT=1 bundle exec rspec spec/some_spec.rb\n```\n\nPerhaps more importantly, to update or install a gem, the workflow would look like this:\n\n```sh\n# This will update Gemfile.lock and Gemfile_next.lock and install the gems\n# specified in Gemfile.lock:\n$ chruby 3.1.4\n$ bundle update some_gem\n# This will actually install the gems specified in Gemfile_next.lock under the\n# correct Ruby installation:\n$ chruby 3.2.2\n$ DEPENDENCIES_NEXT=1 bundle install\n```\n\nConfiguration (Optional)\n------------------------\nBy default Bootboot will use the `DEPENDENCIES_NEXT` environment variable to update your Gemfile_next.lock. You can however configure it. For example, if you want the dualboot to happen when the `SHOPIFY_NEXT` env variable is present, you simply have to add this in your Gemfile:\n\n```ruby\n# Gemfile\nBundler.settings.set_local('bootboot_env_prefix', 'SHOPIFY')\n```\n\nKeep the `Gemfile_next.lock` in sync\n------------\nWhen a developer bumps or adds a dependency, Bootboot will ensure that the `Gemfile_next.lock` snapshot gets updated.\n\n**However, this feature is only available if you are on Bundler `\u003e= 1.17`**\nOther versions will trigger a warning message telling them that Bootboot can't automatically keep the `Gemfile_next.lock` in sync.\n\nIf you use the deployment flag (`bundle --deployment`) this plugin won't work on Bundler `\u003c= 2.0.1`. Consider using this workaround in your Gemfile for these versions of Bundler:\n\n```ruby\nplugin 'bootboot', '~\u003e 0.1.2' unless Bundler.settings[:frozen]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshopify%2Fbootboot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshopify%2Fbootboot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshopify%2Fbootboot/lists"}