diff --git a/README.md b/README.md index 44bc6da..2018516 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_1056 TILs and counting..._ +_1057 TILs and counting..._ --- @@ -816,6 +816,7 @@ _1056 TILs and counting..._ ### Ruby - [A Shorthand For Rerunning Failed Tests With RSpec](ruby/a-shorthand-for-rerunning-failed-tests-with-rspec.md) +- [Add Linux As A Bundler Platform](ruby/add-linux-as-a-bundler-platform.md) - [Are They All True?](ruby/are-they-all-true.md) - [Assert About An Object's Attributes With RSpec](ruby/assert-about-an-objects-attributes-with-rspec.md) - [Assoc For Hashes](ruby/assoc-for-hashes.md) diff --git a/ruby/add-linux-as-a-bundler-platform.md b/ruby/add-linux-as-a-bundler-platform.md new file mode 100644 index 0000000..7990a75 --- /dev/null +++ b/ruby/add-linux-as-a-bundler-platform.md @@ -0,0 +1,34 @@ +# Add Linux As A Bundler Platform + +With a locally developed Ruby project on Mac OSX, I have `darwin` specified as +the _platform_ in the `Gemfile.lock`. + +```ruby +PLATFORMS + x86_64-darwin-19 +``` + +When setting up CI for my project on a linux container, I'd get an error like +this: + +> Your bundle only supports platforms ["x86_64-darwin-19"] ... + +This platform incompatability can be solved with by adding linux as a platform +and re-resolving the lock file. This is done with [`bundle +lock`](https://bundler.io/v2.0/man/bundle-lock.1.html) and the `--add-platform` +flag. + +```bash +$ bundle lock --add-platform x86_64-linux +``` + +If all existing gems work with the new linux platform, the command will succeed +and the updated `Gemfile.lock` will have the following `PLATFORMS` section. + +```ruby +PLATFORMS + x86_64-darwin-19 + x86_64-linux +``` + +[source](https://github.com/rubygems/rubygems/issues/4269#issuecomment-759591430)