Gemfile versus composer.json
As I mentioned before, bundler helps us handle all our program’s dependencies – that is, everything we need to install in order for our program to run correctly. To accomplish this, bundler uses a text file, which we will call a Gemfile
. Composer works in a very similar way by having us create a file called composer.json
, but while Composer downloads the required libraries into a folder, bundler installs them on our system. If bundler determines that a dependency is missing, it will automatically try to install it. Ruby’s way is a bit more magical (or automatic). Let’s take bundler for a test drive to understand the process a little further. We will start by uninstalling our previously installed oj
gem with the following command in the shell:
gem uninstall oj
The preceding command will confirm when the gem is removed from our system:
Successfully uninstalled oj-3.14.2
Now, if we try to run our reading_json.rb
again...