Change bundle install location - ruby-on-rails

I've somehow changed the configuration of bundle install, so it now creates a /vendor/bundle folder in my rails project, and puts all the gems there.
How can I reset my bundle config, so it installs the gems globally instead?

Remove the .bundle directory from your project root and then do a bundle install instead of the bundle install --path vendor like previously.
The .bundle/config file stores the local path for installing gem location, if gems are installed within the app, and bundler picks up those settings next time onwards by default.

Related

Bundle - copy-paste gems from another PC

I am trying to setup a rails application. The application depends on an enormously huge number of gems. The gems were preinstalled in the vendor/gems folder of a copy I obtained from a friend. Now, considering the unavailability of those closed source gems, bundle install --path /home/umang/projectname/vendor/gems fails with the message Could not find gemname in any of the sources. Is there a way I could copy-paste the gems from the vendor/gems/ folder into my gem installation directory and make bundle believe that they are there. I copied the directory from vendor/gems to my local gem installation directory, but bundle check still suggests that those gems are missing.
Okay, it is time I answer my own question.
1. Copy-paste the gems to your gem installation directory.
2. Remove the .bundle/config or fix the conflicting setting.

Copy vendor/cache gems

I have a set of old gems I can't install from internet.
My plan is to copy what is in production server to my local environment.
gem env to know where gems are being installed.
cd to_gems_dir
there are a of of folders there,
I copied cache folder to my local machine
under vendor/cache inside project folder.
run bundle to check everything is OK.
But is not, bundler tries to install some gems, some others not. I don't know too much about bundler and gems envs, so my question is what am I doing wrong here? any other ideas to replicate remote gem set in my local machine?
This is what I did:
for file in vendor/cache/*; do gem i --local $file; done
Then all gems where installed, finally:
bundle check
The Gemfile's dependencies are satisfied

Why are gems installed in my project directory?

I have rvm installed and have created .ruby-version specifying 1.9.3 and .ruby-gemset specifying my_project in my project directory. And when i run gem env gemdir it returns: /Users/danielfriisjensen/.rvm/gems/ruby-1.9.3-p392#my_project.
However, when I run bundle install, all the gems that I have specified in my gemfile are put in my_project/vendor/bundle/gems
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

rails - Unexpected behaviour of 'bundle install': installation into a folder in the app directory

I've started a simple rails application. I tried to install Compass and Haml, (using gem install) and ran 'bundle install'. The bundler re-installed all the gems and placed them in a new folder '/haml' inside the main directory of the rails application.
Your bundle is complete! It was installed into ./haml
Is that expected? Shouldn't these gems be placed in the rvm directory, not in the application directory?
$ bundle install --system
Will solve your problem.
Gems will be installed to your default system location for gems. If your system gems are stored in a root-owned location (such as in Mac OSX), bundle will ask for your root password to install them there.
While installing gems, Bundler will check vendor/cache and then your system's gems. If a gem isn't cached or installed, Bundler will try to install it from the sources you have declared in your Gemfile.
The --system option is the default. Pass it to switch back after using the --path option as described below.

bundle install and RVM

I've run "bundle install" on an existing Rails 3 app which has the gems in vendor/cache (I guess they were packed via "bundle package" before) and valid Gemfile and Gemfile.lock files.
What I saw is, it created a folder .bundle in my home dir.
I am using also RVM. When I tried "gem list", I didn't see any of the gems in vendor/cache installed.
Am I doing something wrong? Everywhere the bundler articles say, execute "bundle" or "bundle install" to install the gems in the Gemfile and Gemfile.lock files. Is the problem connected with the RVM usage?
Thanks for any advice.
If you give an argument to bundle install, it will keep installing the gems inside this directory, even if you rm -rf that directory and start from scratch with the pure bundle install, as noted in Emil's comment. This new directory is taken by default by bundler, and it even supersedes what you declare in the .rvmrc file.
To remove this constraint, simply edit the .bundle/config file and delete the file declaring BUNDLE_PATH, e.g.,
BUNDLE_PATH: /usr/local/lib/
Look in rvm env gemdir, also check what you've got set in .rvmrc in terms of a gemset. Do bundle install and it should get all the gems.
Check .bundle by doing $ cat .bundle to see its content , and check if it is copying the gems to vendor/ruby. This will only be the case if bundle install --path vendor/ruby was supplied (Ref).

Resources