When I run bundle install it is not installing gem of production group.
Some day ago I have run bundle install --without production. But Now I want to install gem of production also. How can I install gem with production also.
I believe once you run the bundler using --without production it remembers that setting in the config. So you should be able to undo it by changing the config per the bundle config command.
Related
I'm having a problem running bundle update with mysql2. I don't really need mysql2 in development, and it works in production, so I want to just tell my gemfile the following:
gem 'sqlite3', :group => :development
gem 'mysql2', :group => :production
Unfortunately it still says bundle update fails because of mysql2:
An error occurred while installing mysql2 (0.3.14), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.14'` succeeds before bundling.
Any reason why this is, and what can I do instead?
It's not a good idea to leave out production gems while you are in development because you want to be prepared for production from the development phase of your project in that you don't want unseen errors when you deploy. That being noted, it's still possible to run bundle update without the production group.
Execute the following and you should see 'Gems in the group production were not installed':
bundle update --without production
For your case though, since you've already installed production group gems, you may want to clean your gems and install them as follows:
> bundle clean --force
> bundle install --without production
# For test purpose
> bundle update --without production
I'm going through Micharl Hartl's well known Rails tutorial, and this piece is confusing me. Every time a new app is set up, these commands are run:
$ bundle install --without production
$ bundle update
$ bundle install
I don't really get why install is being run twice. What is the effect of these three commands run in this sequence?
You should not have to run bundle install twice as bundle update will also install all of your gems (as well as updating them to their most current version). I have not read the tutorial you mentioned but perhaps the purpose of the second install is to install all of the gems, including those reserved for production.
Your second question, what is the effect of these three commands:
bundle install --without production
Inspect the gemfile, ignoring gems that are reserved for production
Resolve all dependencies
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
bundle update
Inspect the gemfile
Resolve all dependencies from scratch using the newest version of each gem and completely ignoring Gemfile.lock
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
bundle install
Because this is the first run of the production gems, inspect the gemfile and resolve dependencies of the production gems
Use Gemfile.lock for exact versions of all other gems to be installed
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
Hoped this helped, for more detailed info about the two commands check out this and this.
$ bundle install --without production prevents bundler from installing any of the production gems. It also gets saved in your local repository and you don't have to run it more than once. Any subsequent run of bundle install will include --without production.
bundle install installs only the missing gems from your Gemfile, while bundle update updates/installs every single gem to the latest version as specified in the GemFile..
I had unicorn 4.5.0 and after I did bundle update, I observe different versions of the same gem even though I wanted to use the latest version.
unicorn (4.6.1, 4.5.0)
How do I instruct the bundler to just keep the latest version.
As far as I can see you cannot instruct bundler to keep only the latest version when updating. You can delete all the old versions of all gems in one go:
bundle exec gem cleanup
(Reference)
You can instruct bundler to just use one version by putting that version in the gem file. Sometimes, I have had conflicts with rake, even though I did not explicitly have rake in my Gemfile, so I had to put the rake version that would be usable by all the other gems at the top of my Gemfile.
If your issue is that you used to use unicorn 4.5.0, and now it has installed unicorn 4.6.1 in you local gem source, you can tell gem to uninstall the version you no longer need.
gem uninstall unicorn --version 4.5.0
If you did a bundle --deployment and populated the vendor/bundle directory, and that is where you want to remove the gem from, then I usually just delete the gem directory, however, I think you can run bundle with --path, like the following:
bundle --deployment --path vendor/bundle
gem uninstall unicorn --version 4.5.0
When you run bundler, it remembers the settings. I painfully discovered this regarding the --without switch. The --path setting will tell gem to use the local vendor/bundle directory as your local gem source. Remember to set the path back by running bundle again.
I recently had to add two gems to my gem file. When I added them to my gemfile, I pushed directly to my production server.
I SSH'd into my production server, and tried running bundle install. This is the error I go:
>> bundle install
.........
>> You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
If this is a development machine, remove the Gemfile freeze
by running `bundle install --no-deployment`.
You have added to the Gemfile:
* RedCloth
* tanker
When you add gems to your Gemfile, you MUST bundle in your dev environment before pushing and deploying.
I've setup a new environment with Ruby 1.9.2 and Passenger 3. A Rails 3 app is deployed with Capistrano. RAILS_ENV is set to staging.
When trying to boot the application, Passenger complains about a missing gem. Running
bundle --deployment
installs gems to RAILS_ROOT/vendor, but doesn't solve the error.
If I install the missing gem as a system gem (eg. sudo gem install), the error disappears but now the next gem in the Gemfile is reported as missing.
I could solve this by installing my gems to the system, but I'd like to understand why installing them to the vendor directory isn't working. My understanding is that the idea of bundler is to avoid having to keep all gems installed to the system.
I have RAILS_ROOT/.bundle/config set to:
BUNDLE_FROZEN: "1"
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: "1"
Ideally, gems should remain in a consistent location to avoid them being reinstalled every deploy. Therefore, try removing BUNDLE_PATH from your config (default location is ~/.bundle).
I'm not sure what bundle --deployment does (I couldn't see mention of this in the docs). I use something like this command in my deploy scripts:
after :'deploy:update_code' do
run "cd #{release_path} && bundle install --without test cucumber development"
end