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.
Related
my environments are follows
os. : mac
rails : 5.0.5
rvm : ruby-2.4.0
node : v6.11.2
npm. : 5.3.0
To download needed assets I run the following command on terminal.
$ rake bower:install
and i got follow errors.
rake aborted!
NoMethodError: undefined method `load_defaults' for #<Rails::Application::Configuration:0x007feb54ef8b38>
/Users/admin/.rvm/gems/ruby-2.4.0/gems/railties-5.0.5/lib/rails/railtie/configuration.rb:95:in `method_missing'
/Users/admin/workspace/now/angular_example/config/application.rb:12:in `<class:Application>'
/Users/admin/workspace/now/angular_example/config/application.rb:10:in `<module:AngularExample>'
/Users/admin/workspace/now/angular_example/config/application.rb:9:in `<top (required)>'
/Users/admin/workspace/now/angular_example/Rakefile:4:in `require_relative'
/Users/admin/workspace/now/angular_example/Rakefile:4:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-2.4.0#global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)
In Rails 4.1.4, and maybe some other versions after 4.0.8, the first line in those files is generated as Rails.application.configure.do rather than, using a project called sample_app as an example, SampleApp::Application.configure.do as in 4.0.8.
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?
I'm on Example 46 of Learn Ruby The Hard Way - Creating a Project Skeleton
Link: http://learnrubythehardway.org/book/ex46.html
So I created all the directories which show up as the following:
skeleton/
NAME.gemspec
Rakefile
data
ext/
tests/
bin/
NAME
doc/
lib/
NAME
NAME.rb
lib/NAME
tests/
test_NAME.rb
I'm in the Skeleton directory in Powershell.
When I run rake test as the tutorial says to I get an error.
Here's the result from Powershell:
PS C:\ruby\learn\projects\skeleton> rake test
C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe -I"lib;tests" -I"C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4
.2/lib" "C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "tests/test_NAME
.rb"
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:1:in `<top (required)>'
C:/ruby/learn/projects/skeleton/tests/test_NAME.rb:2:in `<top (required)>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:15:in `block in <main>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `select'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `<main>'
MiniTest::Unit::TestCase is now Minitest::Test. From C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit/testcase.rb:8:
in `<module:Unit>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:676:in `<class:Runner>': undefined method `_run_suite' for class
`Test::Unit::Runner' (NameError)
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:261:in `<module:Unit>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:15:in `<module:Test>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:7:in `<top (required)>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/ruby/learn/projects/skeleton/tests/test_NAME.rb:2:in `<top (required)>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:15:in `block
in <main>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `select'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [ruby -I"lib;tests" -I"C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/
lib" "C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "tests/test_NAME.rb
" ]
Tasks: TOP => test
(See full trace by running task with --trace)
The book says I should get the following response:
Loaded suite tests/test_NAME
Started
.
Finished in 0.000226 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
But instead I get an error. I've search for fixes and using gem install minitest but keep in mind I don't have a gemfile and I don't know if I should for this type of project. If I needed one I assume the tutorial would say so. So what do I do to fix this issue?
You don't need a Gemfile. While you are at skeleton directory, just do:
gem install 'test-unit'
and then from the same directory:
rake test
All tests will pass.
P.S. I just reproduced the whole thing locally following your tutorial and got the error message as yours. Then, I installed the test-unit gem and after that the rake test is working without any error.
I started getting this error and would like a way to fix it:
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
I am running this from within RubyMine. I can see in my Gemfile.lock where it specifies 10.1.0. Can I just manually update my Gemfile.lock to 10.1.1?
If I do:
$gem list
....
rake (10.1.1, 10.1.0, 10.0.4, 0.9.2.2)
So I'm not sure why it isn't just working with 10.1.0?
Here's the full output from RubyMine:
/Users/jt/.rvm/rubies/ruby-1.9.3-p448/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/jt/.rvm/gems/ruby-1.9.3-p448/bin/rake spec
Testing started at 3:15 PM ...
rake aborted!
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
/Users/jt/repos/app/config/boot.rb:6:in `<top (required)>'
/Users/jt/repos/app/config/application.rb:1:in `<top (required)>'
/Users/jt/repos/app/Rakefile:5:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
(See full trace by running task with --trace)
Process finished with exit code 1
You can remove your
Gemfile.lock file
and exec
bundle update
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")