Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ruby gems and brew formulas?

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.

like image 543
Helen-G Avatar asked Aug 16 '15 04:08

Helen-G


People also ask

What is RubyGems Mac?

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 .

Do you need Ruby for homebrew?

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.

Where does homebrew Ruby install gems?

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 .

Where is brew installed on Mac?

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).


2 Answers

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.

like image 143
MarsAtomic Avatar answered Oct 16 '22 09:10

MarsAtomic


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.

like image 24
Mircea Avatar answered Oct 16 '22 11:10

Mircea