Can I request files outside of the gemfile?

For example, I am developing a gem, and while I am developing, I use pry instead of IRB and debugger for debugging. However, I do not want potential participants to install them (because they may not need them). My first idea was to put them in the Bundler group:

 source :rubygems gemspec group :extras do gem "pry" gem "debugger" end 

And then people could use:

 $ bundle install --without extras 

But I want them to not be installed by default. It’s completely that they are not in my Gemfile , but I can still require them (if they exist on the computer). This solution would be ok because I don't care which version they are locked in. It can be done?

+4
source share
2 answers

bundle install is a β€œfailure” - without specifying --without some_group , it installs everything.

If you absolutely do not want to have this gem in your Gemfile, you can simply gem install destroy the gem outside of your package. Then it will be visible to you under irb and direct ruby (but, obviously, you will get errors if you try require in the code running under bundle exec ).

0
source

In Gemfile, you can add a conditional expression based on environment variables. Example:

 source :rubygems gemspec if ENV['WITH_EXTRAS'] == '1' gem "pry" gem "debugger" end 

Then the stones are set / loaded only when setting the environment variable '1' , for example. WITH_EXTRAS=1 bundle install .

0
source

Source: https://habr.com/ru/post/1441328/


All Articles