# Gems != Magic

DevFeed: [Gems != Magic](<https://devfeed.tech/articles/gems-magic-21037.md>)

Original publisher: [Read original article](<https://jakeyesbeck.com/2015/08/16/gems-are-not-magic/>)

Published: 2015-08-16T12:00:00Z

Content type: opinion

Language: en

Sources: [Jake Yesbeck](<https://devfeed.tech/sources/jake-yesbeck.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [Rails](<https://devfeed.tech/topics/rails.md>), [Code](<https://devfeed.tech/topics/code.md>), [Parsing](<https://devfeed.tech/topics/parsing.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [rails](<https://devfeed.tech/tags/rails.md>), [ruby](<https://devfeed.tech/tags/ruby.md>)

## AI overview

The article argues that Ruby gems are ordinary libraries of code rather than magical solutions. It discusses the risks of unmanaged dependencies and recommends examining gem source code, documentation, design patterns, and idiomatic Ruby conventions to understand how gems work.

## Source excerpt

Ruby gems can seem magical. Usually, one (or more accurately: thirty) solution to a problem exists in the form of a gem. Using gems is easy and intuitive. Simply add a line in the project root's Gemfile and run bundle install. Then, either require the name of the gem or, if using Ruby on Rails, start using the gem's code immediately anywhere in the project. What could possibly go wrong? Gems on gems on gems Unchecked and unmanaged, a project's Gemfile might turn into something that looks like: source 'https://rubygems.org' gem 'linkbuilder' gem 'http_helper' gem 'the-color-red' gem 'devise' gem 'cancancancancan' gem 'nokogiri' gem 'crack' # ... # .... # ..... gem 'cucumber' gem 'avacado' gem 'you-get-the-idea' gem 'these-are-too-many-gems' gem 'really' It is very possible that all these gems do not have any adverse side effects. They might not even have any horrible monkey patches to String or Object. This post has more information on "Why do most Rails apps use so much memory per process?". Without being able to see inside of them, intrusive gems might be mixed into this mass and we would have no idea. At a glance, it is not immediately obvious how to differentiate between benign and malignant gems. It becomes infinitely easier to understand how gems interact if we remember that gems are not magic. Gems are just Libraries There it is! The rabbit is out of the hat. Somewhere, some amount of cats have been released from their respective bags. Gems are not magic silver bullets injected into a codebase. Instead they are nothing more than libraries of code. Gems are (hopefully) well encapsulated groups of files that amount to a (again hopefully) few pieces of helpful functionality. With this new understanding of what gems really are, it means that parsing, modifying, and creating gems is within reach. All that is left is to figure out how to pry them open. Opening gems Understanding gems is a great way to learn different design patterns and idiomatic Ruby conventions. G