What are the key differences between ruby gems and brew formulas?
It is not very clear which is used when. Sometimes I see how gems are installed with brew, and this is a bit confusing.
RubyGems are the ready-made software libraries that make development easy and fun in Ruby. Most Ruby projects use at least a few gems. If you use the Mac system Ruby, running gem install will try to save gems to the system Ruby directory /Library/Ruby/Gems/2.6. 0 .
Homebrew and its installation script are written in Ruby, and we'll use the default Ruby interpreter that comes with macOS to install it. The command uses curl to download the Homebrew installation script from Homebrew's Git repository on GitHub.
When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 .
On Mac Intel, Homebrew installs itself into the /usr/local/bin directory, which is already configured for access by the shell with the macOS default $PATH environment variable (the default is set by the /usr/libexec/path_helper command).
RubyGems and Homebrew are both package managers. RubyGems was created for the express purpose of installing gems whereas Homebrew is a more general tool which can build, install and manage different software packages including gems.
Homebrew is tied to Mac OS X, whereas RubyGems works on multiple platforms.
Best advice? Do whatever the book/tutorial you're following tells you to do and let your preferences develop over time until you have enough experience to know what you want. All this having been said, it seems as though you're going to be working in Rails, so you're going to be using bundler, rather than RubyGems or Homebrew.
We need to step back and understand how ruby handles gems in general.
It can either pick them up from system directory or local per user directory or local per project directory.
You are going to be working with ruby gems regardless of what you are doing.
homebrew has the ability to instal the gems in system level dirs based on formula.
gem can also install the gems and it can do it in any of these locations.
bundler can install bundles and gems and dependencies needed for them.
run gem environment if you want to see where ruby is going to pick up the gems from (probably you have multiple locations)
follow @MarsAtomic's advice and do whatever the tutorial tells you to do. After that go into bundler which will under the cover manage the gems for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With