Cannot bundle in production - ruby-on-rails

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.

Related

Capistrano version conflict

I'm trying to upload my Rails app with:
bin/cap production deploy
but the deployment is failing with this error message:
You have requested:
capistrano ~> 3.3.0
The bundle currently has capistrano locked at 3.7.1.
Try running `bundle update capistrano`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
I tried to fix the issue by running:
bundle update capistrano
but that did not solve it.
The thing I don't get is that I don't see where my application 'asks for capistrano 3.3.0'. In my Gemfile I set Capistrano to version 3.7.
Besides the capistrano gem I'm also using:
gem capistrano-rails, '~> 1.2'
gem capistrano3-delayed-job, '~> 1.3'
gem capistrano-figaro-yml
My Gemfile is at:
https://github.com/acandael/personalsite/blob/master/Gemfile
Does someone know how I can fix this Capistrano version issue?
thanks for your help,
Anthony
Please follow all the steps in the right order (don't skip any because you did it)
cd into your project directory
run bundle exec gem uninstall capistrano -a to remove all capistrano versions from your bundle
run gem uninstall capistrano -a to remove all capistrano versions from your system. Note that you may need to run this with root access if you get an error message
run bundle install
run bundle exec gem list capistrano which should output all installed gems with a name that contains "capistrano". You are supposed to have only one version of the capistrano gem
check in your files config/deploy.rb and config/deploy/*.rb if you have a lock 3.x.x instruction, and make sure it matches the install version as show in step 5
run cap in bundle context with bundle exec cap production deploy (use exactly this command line, do not use bin/cap)
try bundle exec cap production deploy
try to remove YOUR_APP/.bindle directory and run bundle install again

Pretend other platform for `bundle install`

I am developing with bundler under Windows and am wondering how to create the Gemfile.lock for my production environment.
What seems missing are the gems for other platforms. Running bundle install on
group :production do
gem 'mysql2'
end
on Windows creates a Gemfile.lock
mysql2 (0.3.18-x86-mingw32)
When deploying to a Linux environment this is obviously not correct, I would need the Gemfile.lock to also contain the correct result for Linux. I can run bundle install on Linux and learn that indeed
mysql2 (0.3.18)
is the correct gem for Linux. I then manually update the Gemfile.lock in the repository to contain both:
mysql2 (0.3.18)
mysql2 (0.3.18-x86-mingw32)
This works clean under both platforms, but it seems a kludge.
How can I tell bundle to resolve the Gemfile.lock for another platform other than the local one? I guess I need something like bundle install --all-platforms. What am I missing?
It would appear this is a known shortcoming in bundler and the workaround seems to be to run bundle pack on every platform you need to use.
Running the following commands will fix your issue.
bundle lock --add-platform x86_64-linux
bundle install
git add . ; git commit -m fix
Reference
https://www.moncefbelyamani.com/understanding-the-gemfile-lock-file/#platforms
https://bundler.io/man/gemfile.5.html#PLATFORMS
https://github.com/rubygems/rubygems/issues/4269#issuecomment-758564690

Why is "install" run twice?

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..

bundle install not installing gem of production

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.

ROR bundle install : git://github.com/Goin/dm-migrations.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)

I have an existing ROR application I've inherited. I needed to add a GEM file to the Gemfiles list. I then ran a "bundle install". Apache (/phusion/rack) now shows the error "git://github.com/Goin/dm-migrations.git (at master) is not checked out. Please run bundle install (Bundler::GitError)". According to bundle this gem is installed however: "/usr/local/lib/ruby/gems/1.8/bundler/gems/dm-migrations-3d190029bb8c".
What is the root cause of the problem and the fix?
TY,
Fred

Resources