Reputation: 1531
I am a new bee with sinatra and i am not an expert with ruby management tools like rvm and rbenv and i have the following issue: When i run a bundle install in my app, gems are installed and i have the following response "Bundled gems are installed into ./vendor/bundle." But when i try to run my sinatra app, it is displayed that i dont have sinatra installed and when i try this command line "gem list", i dont it found too.
I am using rbenv, and i dont have a clue how to resolve that. When i install gem by gem like "gem install sinatra" it works fine, but it's really painful, so my question is how to resolve that ?
PS: i tried to manage my ruby manager with rvm but i had issues so i moved to rbenv, maybe this is all about the path where gems are installed
This is a print of my gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /Users/laadhari/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/laadhari/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /Users/laadhari/.rbenv/versions/2.3.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/laadhari/.rbenv/versions/2.3.1/bin
- SPEC CACHE DIRECTORY: /Users/laadhari/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/laadhari/.rbenv/versions/2.3.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/laadhari/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- /Users/laadhari/.gem/ruby/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/laadhari/.rbenv/versions/2.3.1/bin
- /usr/local/Cellar/rbenv/1.0.0/libexec
- /Users/laadhari/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
A print of my Gemfile
source 'https://rubygems.org'
gem 'sinatra', '~> 1.4.7'
gem "sinatra-activerecord"
gem 'mysql2'
gem 'rest-client'
gem 'thin'
gem 'rake'
when i run :
gem list
*** LOCAL GEMS ***
...
After successfully running bundle install, I dont find gems from Gemfile in the local gems...
Upvotes: 0
Views: 999
Reputation: 2916
One of the objectives of Bundler
is to not pollute the global Gem list. This is achieved by NOT installing the bundled gems to the default location.
So to make sure your app finds the bundled gems, you have a few options:
bundle exec
When starting your application (ie. using rackup
or ruby ./app.rb
), prefix the command with bundle exec
bundle exec rackup
#=> Thin web server (v1.7.0 codename Dunder Mifflin)
#=> Maximum connections set to 1024
#=> Listening on localhost:9292, CTRL+C to stop
#=> ...
More Info: https://bundler.io/v1.12/man/bundle-exec.1.html
Bundler.setup
Before loading your dependencies (with require
), load Bunder:
require 'rubygems'
require 'bundler/setup'
# require your gems as usual
require 'sinatra'
More info: https://bundler.io/v1.12/bundler_setup.html
I strongly suggest to read the excellent documentation at https://bundler.io/v1.12/#getting-started .
One more thing, to find out WHERE your bundled gems actually are installed, run the following command:
bundle config path
#=> Settings for `path` in order of priority. The top value will be used
#=> Set for your local app (/path/to/project/.bundle/config): ".bundle"
Upvotes: 2