How to rebuild Bundle in Capistrano? - ruby-on-rails

I have been working up updating a Rails app that uses Rbenv, Bundler, and Capistrano, and after installing Ruby on the remote server, my deploys consistently fail with the following:
DEBUG [c642111f] rake aborted!
DEBUG [c642111f] LoadError: cannot load such file -- rails/all
DEBUG [c642111f] /home/deploy/domains/myapp/releases/20151019224651/config/application.rb:3:in `require'
DEBUG [c642111f] /home/deploy/domains/myapp/releases/20151019224651/config/application.rb:3:in `<top (required)>'
DEBUG [c642111f] /home/deploy/domains/myapp/releases/20151019224651/Rakefile:4:in `require'
DEBUG [c642111f] /home/deploy/domains/myapp/releases/20151019224651/Rakefile:4:in `<top (required)>'
DEBUG [c642111f] (See full trace by running task with --trace)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy#myapp.com: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
LoadError: cannot load such file -- rails/all
/home/deploy/domains/myapp/releases/20151019224651/config/application.rb:3:in `require'
/home/deploy/domains/myapp/releases/20151019224651/config/application.rb:3:in `<top (required)>'
/home/deploy/domains/myapp/releases/20151019224651/Rakefile:4:in `require'
/home/deploy/domains/myapp/releases/20151019224651/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
LoadError: cannot load such file -- rails/all
/home/deploy/domains/myapp/releases/20151019224651/config/application.rb:3:in `require'
/home/deploy/domains/myapp/releases/20151019224651/config/application.rb:3:in `<top (required)>'
/home/deploy/domains/myapp/releases/20151019224651/Rakefile:4:in `require'
/home/deploy/domains/myapp/releases/20151019224651/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy#myapp.com: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
LoadError: cannot load such file -- rails/all
/home/deploy/domains/myapp/releases/20151019224651/config/application.rb:3:in `require'
/home/deploy/domains/myapp/releases/20151019224651/config/application.rb:3:in `<top (required)>'
/home/deploy/domains/myapp/releases/20151019224651/Rakefile:4:in `require'
/home/deploy/domains/myapp/releases/20151019224651/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
If I ssh in to the remote server and try tasks such as be rails c from the releases/20151019224651 path, I get the same messages.
However, I've noticed that once I run rm -rf .bundle, all problems go away and everything works great.
The problem is that it's too late to fix the aborted deploy, and every successive deploy attempt runs into the same issue.
What might be going on here, and how can I fix it for good?

Related

symbol not found in flat namespace '_mysql_affected_rows' in mac m1

i have a problem when i did
bundle exec rails db:migrate
Any ideas on how to fix it?
I have no idea why _mysql_affected_rows is not found.
Help would be appreciated.
rails aborted!
LoadError: dlopen(/Users/myname/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle, 0x0009): symbol not found in flat namespace '_mysql_affected_rows' - /Users/myname/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle
/Users/myname/Desktop/github/company/config/application.rb:9:in `<top (required)>'
/Users/myname/Desktop/github/company/Rakefile:4:in `require_relative'
/Users/myname/Desktop/github/company/Rakefile:4:in `<top (required)>'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)

Cap production deploy - Rails 6 - Failing

Trying to deploy a rails 6 application to a Digital Ocean droplet.
I run cap production deploy and it fails with this error:
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Command::Failed: rake exit status: 256
rake stdout: Nothing written
rake stderr: rake aborted!
NoMethodError: undefined method `each' for #<String:0x0000565323a30eb8>
/var/www/html/Dev/rails/AppName/config/application.rb:10:in `<module:AppName>'
/var/www/html/Dev/rails/AppName/config/application.rb:9:in `<top (required)>'
/var/www/html/Dev/rails/AppName/Rakefile:4:in `require_relative'
/var/www/html/Dev/rails/AppName/Rakefile:4:in `<top (required)>'
/home/rdevc/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/rdevc/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
Tasks: TOP => deploy:assets:prepare
(See full trace by running task with --trace)
The deploy has failed with an error: rake exit status: 256
rake stdout: Nothing written
rake stderr: rake aborted!
NoMethodError: undefined method `each' for #<String:0x0000565323a30eb8>
/var/www/html/Dev/rails/AppName/config/application.rb:10:in `<module:AppName>'
/var/www/html/Dev/rails/AppName/config/application.rb:9:in `<top (required)>'
/var/www/html/Dev/rails/AppName/Rakefile:4:in `require_relative'
/var/www/html/Dev/rails/AppName/Rakefile:4:in `<top (required)>'
/home/rdevc/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/rdevc/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
Any idea what causes this?
The gem dependencies are all satisfied and the server is running the same versions of ruby, rails and ubuntu as I have on my dev box.
I had endless problems deploying this app. Credentials problems, sassc nightmares and more. In the end, I started a new 5.2.2 project, copied in the controllers, models, migrations, views, routes, etc., and changed a few instances of [6.0] to [5.2]. First try deployed perfectly and the app is now live. I can only assume there is something not fully working with my rails 6 install.
Thanks for your replies, guys.

db:migrate not working after cloning the source code

i cloned the sample app from https://bitbucket.org/railstutorial/sample_app_4th_ed and followed the instruction there, but rails db:migrate is aborting
C:\Sites\sample_app>rails db:migrate
rails aborted!
LoadError: cannot load such file -- bcrypt_ext
C:/Sites/sample_app/config/application.rb:7:in `<top (required)>'
C:/Sites/sample_app/Rakefile:4:in `require_relative'
C:/Sites/sample_app/Rakefile:4:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
Caused by:
LoadError: cannot load such file -- 2.3/bcrypt_ext
C:/Sites/sample_app/config/application.rb:7:in `<top (required)>'
C:/Sites/sample_app/Rakefile:4:in `require_relative'
C:/Sites/sample_app/Rakefile:4:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
(See full trace by running task with --trace)
Try to uninstall bcrypt completely with:
gem uninstall bcrypt-ruby
gem uninstall bcrypt
Be sure all versions are uninstalled, then run
gem install bcrypt --platform=ruby
Try to run bundle install. After this worked you could try to run rake db:migrate again.

Installing Ruby on Rails: -bash: bundle: command not found

Having an issue running bundle in my application, I have copied the commands and logs, and display below.
$ cd ~/Desktop/chinook/
$ rake db:setup
rake aborted!
Gem::LoadError: You have already activated rake 11.1.2, but your Gemfile requires rake 10.4.2. Prepending `bundle exec` to your command may solve this.
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:34:in `block in setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:19:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/setup.rb:8:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Then after seeing that error I ran this command:
$ gem install rake -v 10.4.2
WARNING: You don't have /Users/kexinwu/bin in your PATH,
gem executables will not run.
Successfully installed rake-10.4.2
Parsing documentation for rake-10.4.2
Done installing documentation for rake after 1 seconds
1 gem installed
Kexins-MacBook-Pro:chinook axiner$ rake db:setup
rake aborted!
Gem::LoadError: You have already activated rake 11.1.2, but your Gemfile requires rake 10.4.2. Prepending `bundle exec` to your command may solve this.
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:34:in `block in setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:19:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
/Users/kexinwu/.gem/ruby/2.3.0/gems/bundler-1.11.2/lib/bundler/setup.rb:8:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/kexinwu/Desktop/chinook/config/boot.rb:4:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/config/application.rb:1:in `<top (required)>'
/Users/kexinwu/Desktop/chinook/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
$ bundle exec rake db:setup
-bash: bundle: command not found
How do I fix this error where I can run rake db:setup?
You need to install bundler, then you can use the bundle command.
gem install bundler
Try this command bundle exec
bundle exec rake db:setup

rake aborted! cannot load such file -- indirizzo

I tried running rake db:reset in my rails application after bundle install. The following message is displayed
rake aborted!
cannot load such file -- indirizzo
/home/xyz/Desktop/Signup4/app/models/concerns/address_validation.rb:2:in `<module:AddressValidation>'
/home/xyz/Desktop/Signup4/app/models/concerns/address_validation.rb:1:in `<top (required)>'
/home/xyz/Desktop/Signup4/app/models/location.rb:2:in `<class:Location>'
/home/xyz/Desktop/Signup4/app/models/location.rb:1:in `<top (required)>'
/home/xyz/Desktop/Signup4/db/seeds.rb:11:in `<top (required)>'
Tasks: TOP => db:setup => db:seed
(See full trace by running task with --trace)
bundle show Indirizzo displays
/usr/local/lib/ruby/gems/2.0.0/gems/Indirizzo-0.1.7
It seems to me the problem is in correct require.
According to readme https://github.com/daveworth/Indirizzo#usage it should be
require 'Indirizzo'
but the fact that it does not work (the same error).
It think it should be the same as in the internal lib https://github.com/daveworth/Indirizzo/blob/master/lib/indirizzo.rb
require 'indirizzo/address'
after this I manage to complete this example Indirizzo::Address.new("some address")

Resources