I copied the app from Github. Installed a proper version of Ruby using rbenv. I installed bundler by gem install bundler
and ran bundle install --path vendor/bundle
. All gems were installed in vendor/bundle
directory in the app. Now I wonder, why rails s
command doesn't work but bundle exec rails s
works? The same with rspec
command. Is this because I installed gems in vendor/bundle
directory? I'm confused.
Also, when I run gem list
I get only a few gems, but there are a lot of them in vendor/bundle
directory.
Please tell me why gem list
command doesn't see gems from vendor/bundle
directory and why I need to run commands with bundle exec
. Thank you!
The purpose of having the bundle exec command is to look/search for the command which you want to run inside the current bundle or installed gems inside your vendor directory.
If you are running newer rails (v5) then have a look at the binstubs which copies over the command executeable in the bin directory. So that you can simply call
bin/rails server
This is the same approach which is followed by the deployment solutions which we currently have. They create a .bundle directory which eliminates the need to do bundle install everytime.