Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

package.json (javascript npm) or requirements.txt (python pip) equivalent for ruby

Nodejs's npm has package.json to store dependencies (created with npm init, modified with npm install aPackage anotherPackage --save, and installed all-together with npm install).

Python's pip has requirements.txt (created with pip freeze > requirements.txt after packages have been installed with pip install apackage anotherpackage and installed all-together with `pip install -r requirements.txt).

What file does Ruby use for storing dependencies? If I install with gem install sass jekyll etc..., how can I include those dep's in a file and install them all-together on a new machine?

Python equivalent of npm or rubygems and gem equivalent of `pip install -r requirements.txt` point to the bundler gem which uses a Gemfile - is this the de facto Ruby standard?

like image 575
Pat Avatar asked Oct 31 '22 13:10

Pat


2 Answers

Well, Which programming language has the best package manager? | Continuous Updating as well as the two SO questions linked in my question all point to Bundler: The best way to manage a Ruby application's gems.

I guess the workflow is gem install bundler, add gems to Gemfile, then bundle install.

like image 160
Pat Avatar answered Nov 15 '22 07:11

Pat


Bundler is a great package manager and is definitely the ruby standard. It is comparable to pip and npm.

You can set it up like so:

Install Bundler:

$ gem install bundler

Specify your dependencies in a Gemfile in your project's root:

source 'https://rubygems.org'
gem 'nokogiri'
gem 'rack', '~>1.1'
gem 'rspec', :require => 'spec'

Then, on any machine you can install all of the project's gems:

$ bundle install
$ git add Gemfile Gemfile.lock

The second command adds the Gemfile and Gemfile.lock to your repository. This ensures that other developers on your app, as well as your deployment environment, will all use the same third-party code that you are using now.

like image 38
JMac Avatar answered Nov 15 '22 07:11

JMac