Package.json (javascript npm) or requirements.txt (python pip) ruby ​​equivalent

Nodejs npm has a package.json for storing dependencies (created with npm init

, modified with, npm install aPackage anotherPackage --save

and installed with npm install

).

Python pip has a requirements .txt file (created with pip freeze > requirements.txt

after packages have been installed with pip install apackage anotherpackage

and installed along with `pip install -r requirements.txt).

What file does Ruby use to store dependencies? If I install with gem install sass jekyll etc...

, how can I include these deps in a file and install them all together on a new machine?

python equivalent for npm or rubygems and gem equivalent for `pip install -r requirements.txt` point to the gem the Gemfile uses - is this the actual Ruby standard?

+3


source to share


2 answers


Well, which programming language has the best package manager? | Continuous update , as well as the two SO questions linked in my question point to Bundler: The best way to manage Ruby gems .



I think the workflow is gem install bundler

, add gems in Gemfile

, then bundle install

.

+1


source


Bundler is a great package manager and is definitely a ruby ​​standard. This is comparable to pip

and npm

.

You can set it up like this:

Install Bundler:

$ gem install bundler

List your dependencies in the Gemfile at the project root:



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

      

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

$ bundle install
$ git add Gemfile Gemfile.lock

      

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

+1


source







All Articles