r/ruby • u/Ayano-Keiko • Apr 26 '26
venv in ruby
Finnally, I get used of ruby bundle. The step is following
- set the vendor path
bundle init
bundle config set --local path 'vendor/bundle'
-
add gem to
Gemfilefile -
install gem package
bundle install
- run the ruby script
bundle exec ruby ./script.rb
Is these any way I can install ruby packages in current project folder like Python venv. I only know about gem install <custom-gem> --user-install which install in $HOME/.gem/ruby/2.6.0/gems/. AI said I should use bundler and Gemfile. But it seems very comfused and do not work well with gem file ( it only work with package uploaded on https://rubygems.org/
4
Upvotes
View all comments
Show parent comment
5
u/mourad_dc Apr 26 '26
I actually do:
bundle config set --global path 'vendor/bundle'
… so it uses vendor/bundle as the path for every project where there's a Gemfile, and never the system or user installed gems, even if I forget to set the bundle config for a project.
Another useful command is:
bundle exec gem env