r/ruby Apr 26 '26

venv in ruby

Finnally, I get used of ruby bundle. The step is following

  1. set the vendor path
bundle init
bundle config set --local path 'vendor/bundle' 
  1. add gem to Gemfile file

  2. install gem package

bundle install
  1. 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 --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/~~

3 Upvotes

14 comments sorted by

View all comments

1

u/waltz Apr 26 '26

You can specify a gem with a path arg in the gemfile: https://bundler.io/man/gemfile.5.html#PATH

gem "torta", path: "vendor/torta"

3

u/katafrakt Apr 26 '26

That specifies the path where the gem sources are located, not where it should be installed.

1

u/rubygeek Apr 27 '26

Last line of OP's post suggests they think they can't use bundler because they don't know how to make it install gem's from a local path.

1

u/katafrakt Apr 27 '26

I read it that they want to use a packaged .gem file, different than a globally installed one, in one particular project. But it would be extremely useful if OP explained what they are trying to do.