Bundler puts my gems in my project directory
You are probably running the following command: bundle install bandsintown
. That command tells bundler to install gems into the bandsintown
subdirectory of your application. In order to install gems, all you need to do is modify your Gemfile and run bundle install
.
Bundler will remember the location that you last specified in the .bundle/config file. So, in order to "reset" bundler's memory. In your application's directory, run rm -r .bundle/config.
Then, after updating your Gemfile, simply run bundle install
Why are gems installed in my project directory?
Bundler was remembering the location from the first time I ran bundle install. Had to 'reset' bundler's memory be running rm -r .bundle/config
Why Bundle Install is installing gems in vendor/bundle?
Use
bundle env
to view paths and bundle configurationAfter this set bundle path to
~/.rvm/gems/ruby-2.0.0-p247
like this:bundle install --path ~/.rvm/gems/ruby-2.0.0-p247
which is global and also you can use your own custom path.
Post this
bundle install
will never needpath
again and will always install all of your gems in thatdirectory(~/.rvm/gems/ruby-2.0.0-p247 in my case
) for that app not inapp_folder/vendor/bundle
How do I get Bundler to consider local gems as already installed ?
This trick is done using bundler.
Let's say that gem foo depends upon gem bar. Then in foo's Gemfile, use bundler's path option to point to gem bar:
gem "bar", path: "/home/wayne/lab/bar"
then bundle install
After that, commands such as bundle exec rspec
, bundle exec rake features
, etc., will use the gem "bar" out of your local folder.
When done, revert the gem "bar"
line in Gemfile to its normal form.
If you want to keep the Gemfile modification permanently, you have several options. One is to just check it in with the modification. According to the Gemfile source priority, Bundler will first try to load the gem from the local path, then fall back to installing it from the global source.
If the gem is public, your local modification might be confusing to someone who clones your gem. In that case, since a Gemfile is just ruby code, you can use, for example, an environment variable to turn on your location modification:
# When making concurrent modifications to gem "bar",
# use that gem by its local directory.
if ENV['BAR_GEM_PATH']
gem "bar", path: ENV['BAR_GEM_PATH']
end
Specify gem installation directory
You can add the following to your config.ru file:
ENV['GEM_HOME']="#{ENV['HOME']}/projects/shared/gems/ruby/1.8/gems"
ENV['GEM_PATH']="#{ENV['GEM_HOME']}:/var/lib/ruby/gems/1.8"
require 'rubygems'
Gem.clear_paths
This will tell your rack app where to look for gems.
Also configure your server .bashrc:
export GEM_HOME="$HOME/projects/shared/gems/ruby/1.8/gems"
export GEM_PATH="$GEM_HOME:/var/lib/ruby/gems/1.8"
Where does bundler store gems?
It depends. In the usual development setup they are installed where they would be when you install a gem "normally" (by running gem install foo
) and bundler won't reinstall gems that are already there. This location depends on how rubygems itself is configured.
If you run bundle install with the --deployment
option then the gems will be installed in a location unique to your app (you can pass this as a separate option but it defaults to vendor/bundle)
You can also run bundle package
to store all the .gem files your app uses in vendor/cache
. Running bundle install
will prefer gems in vendor/cache to gems in other locations.
gem from rubygems installs in gems folder, but same gem from github installs in bundler/gems
You're using bundler and a Gemfile in your app but not invoking your app with bundler, so when you call require 'colorize'
it doesn't work because only bundler can tell the app where to find the gem.
Your simplest solution is to invoke your app with bundler:
bundle exec ruby color.rb
Installing Gems with Bundler == Big problem
That is because you also have to address where the gem location ( specifically where bundler is installed ) in your nginx start script as well.
bin/start
#!/bin/bash
TMPDIR=/home/shadyfront/webapps/truejersey/tmp GEM_HOME=/home/shadyfront/.rvm/gems/ruby-1.8.7-p330@true /home/shadyfront/webapps/truejersey/nginx/sbin/nginx -p /home/shadyfront/webapps/truejersey/nginx/
Related Topics
Ruby: No Such File or Directory @ Rb_Sysopen - Testfile (Errno::Enoent)
Don't Have Jekyll-Paginate or One of Its Dependencies Installed
Truncate String to the First N Words
How to Reference a Lambda from Within Itself Using Ruby
Nokogiri Error When Running Bundle Install
Strategies for Overriding Database.Yml
How to Include a Yaml File Inside a Yaml File in Ruby
Rake Assets:Precompile Gets Killed When There Is a Console Session Open in Production
In Ruby/Rails, How to Encode/Escape Special Characters in Urls
Understanding Method_Added for Class Methods
Passenger Installation with Nginx Fails
Ruby/Rails Image Processing Libraries
Checking Whether the C Compiler Works... No
Why Doesn't This Work If in Ruby Everything Is an Object
Start or Ensure That Delayed Job Runs When an Application/Server Restarts