A
A
Anton2021-11-16 19:10:00
ruby
Anton, 2021-11-16 19:10:00

How to create an isolated environment with dependencies for a Ruby/Rails project?

I would like to have a set of gems for a specific project without using solutions like Docker.
Found out that there are gemsets in RVM. Bundler also offers to set the path for storing dependencies.

But what if Rails is also used?
If you install Rails globally and then create a project with rails new, then bundle installRails will be installed again, but now locally. I don't like this double installation and confusion about calling - bundle exec railsor rails.

Tried starting project initialization with bundle init, bundle add railsand rails new. So a conflict over the presence of a Gemfile arises because the last command also creates it.

Please tell me which way is correct?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AVKor, 2021-11-16
@AVKor

In the terminal: create a gemset, make it active. Write a Gemfile with the required gems. Execute the bundle command.

R
Roman Mirilaczvili, 2021-11-24
@2ord

Optional gemsets in RVM.
blockquote>Install your dependencies, even gems that are already installed to your system gems, to a location other than your system's gem repository. In this case, install them to vendor/bundle.
$ bundle install --path vendor/bundle
https://bundler.io/bundle_install.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question