After having installed my application's gems by executing:
bundle install --without production
Now I want to install the production group gems. However, when I issue:
bundle install
bundle seems to remember the previous setting and none of the production group gems are installed. How can I clean this bundle 'cache' and force it to reinstall all the gems in the Gemfile?
The quickest option is to simply delete the bundle config file located at:
.bundle/config
within your Rails project then issue the commands:
bundle update
bundle install
Sources here and here.
Related
How do I force Bundler to reinstall all of the gems in my gemfile? Or, how do I force Bundler to uninstall all of the gems it installed so I can then reinstall them myself?
I saw rails bundle clean, but this question explains how to remove gems that bundle installed but are no longer in the gemfile.
And How to reinstall a gem using bundler explains how to reinstall a single gem. I would like to reinstall all of my gems at once.
bundle install --redownload
See the reference for bundle install: https://bundler.io/v2.2/man/bundle-install.1.html
or
bundle install --force
For older versions of bundler
Brutish but clever:
Comment out your entire Gemfile. (Don't delete it)
bundle clean
Restore your Gemfile.
bundle install
You can also delete the vendor directory and do bundle install again.
If you completely want to reinstall everything from scratch you can just, locate your gem dir, for example if you use rvm it would be ~/.rvm/gems
then locate your ruby version alongside with gemset for example ruby-2.7.0#some_particular_gemset (it will be a dir) and then just delete it.
rm -rf ruby-2.7.0#some_particular_gemset
bundle install
Another way to deal with gem problems can be to sudo gem clean instead of reinstalling everything
I'm installing a ruby git-repo on several servers which have no internet connectivity. I had cloned that repo to my local machine, and used $ bundle install --path vendor/bundle to package all dependencies. Then I copied the whole directory to the target server, and tried $ bundle install --deployment, which still attempting resources from rubygems.org, hence not solving any dependencies as expected:
Fetching source index for https://ruby.taobao.org/
Could not find ffi-1.9.3 in any of the sources
According to bundler.io:
The --deployment flag activates a number of deployment-friendly conventions:
Isolate all gems into vendor/bundle
which does not work in my case. Any thing am I doing wrong?
bundle install will grab the gems from rubygems when run.
bundle package grabs the gems and packages them in vendor/cache.
The package command will copy the .gem files for your gems in the bundle into ./vendor/cache. Afterward, when you run bundle install, Bundler will use the gems in the cache in preference to the ones on rubygems.org.
http://bundler.io/bundle_package.html
gem env shows
GEM PATHS:
/usr/local/share/gems
I would like to use bundle install --deployment --path=/usr/local/share/gems to install my bundled gems.
The problem is that the bundle install creates a folder ruby and puts the gems folder inside the ruby folder.
When this happens my ruby code is unable to find the gems in its default path.
Looks like I am missing some configuration parameter. Help please.
MaurĂcio Linhares comments in the question has resolved the issue.
When using bundler to install gems use bundle exec ruby. When the bundle install --deployment happens the path information goes into .bundle/config
bundle exec ruby path-to-ruby-script.rb
The above execution Will find the gems installed by the bundle command.
Alternatively, if you want to force installation to the system gem location, I believe bundle install --deployment --system will do what you want.
I am currently working on sample ruby project (not rails).
In the rails project we can use bundle package command for storing installed ruby gems.
It will lock and cache gems from RubyGems into ./vendor/cache. folder.
Now I have to use same functionality. So how can I store gems on local machine and when we do bundle install it will fetch the required ruby gems from that source.
bundler is not part of rails, but it is an independent ruby gem itself. so given you have the bundle command available, you can just set up you Gemfile and use bundle install as you are used to.
This is also described on the bundler homepage
Use Bundler
install bundler from your server prompt (regardless of project folder) to ensure the bundle command is accessible.
gem install bundler
now that your server has bundler installed make a file under the root of your project called Gemfile and add the source and required gems something similar to:
source 'https://rubygems.org'
gem 'example_gem'
gem 'example_gem_with_version', ">=0.9.2"
...
Now your Gemfile is ready. From the root of your project run the bundle install command and specify your vendor directory
bundle install --path vendor
After it retrieves the source it will cache it under the vendor directory. To install locally without fetching from rubygems.org simply use
bundle install --local
i installed a gem from this repository using this in my Gemfile :
gem 'copy_carrierwave_file', github: 'equivalent/copy_carrierwave_file'
when i'm trying to uninstall it using :
gem uninstall copy_carrierwave_file
nothing is shown like copy_carrierwave is uninstalled successfuly from....
then if i type :
bundle show copy_carrierwave_file
it still show me the location of this gem
How i can uninstall it ?
Since git, github, and path located, or development gems are controlled by bunlder, you have just to remove put to delete gem from Gemfile. And you even don't need to run bundle install again.
$ bundle show session
Could not find gem 'session'.
Bundle Clean. Since the gems were installed using bundler, they have to be uninstalled using bundler too!
First, remove the line gem 'copy_carrierwave_file', github: 'equivalent/copy_carrierwave_file' from your Gemfile
Then, bundle clean with dry-run (just in case you see gems you don't want to remove):
bundle clean --force --dry-run
If you want to remove those gems, clean it:
bundle clean --force