rake aborted! cannot load such file -- indirizzo - ruby-on-rails

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")

Related

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.

DEPRECATION WARNING while using bundle install

So I am trying to do bundle install . But it is throwing the below errors. What is the problem here?
bundle exec rake db:create:all
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:66)
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:67)
rake aborted!
Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)
Earlier I had tried the below:
rake db:create:all
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/runtime.rb:34:in `block in setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/runtime.rb:19:in `setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler.rb:122:in `setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/setup.rb:7:in `<top (required)>'
/home/project/config/boot.rb:4:in `<top (required)>'
/home/project/config/application.rb:1:in `<top (required)>'
/home/project/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/project/config/boot.rb:4:in `<top (required)>'
/home/project/config/application.rb:1:in `<top (required)>'
/home/project/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
$ bundle exec rake db:create:all
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:66)
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:67)
rake aborted!
Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)
You are trying to run "rake db:create:all" which would create your database but as error states - it seems you don't have your config/database.yml file. It's a configuration file that tells rails how to connect to your database. You can read more about it here.
If you really want to run bundle install, just use "bundle install" command instead. This will install all gems listed in your Gemfile.
If you will get problems with rake version conflicts, check out this stack overflow question.
It seems you have no config/database.yml file in your project's directory.
Why I think so? Follow me ...
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
Ok, let's take a look at this code where we have error:
yaml = Pathname.new(paths["config/database"].existent.first || "")
config = if yaml.exist?
require "yaml"
require "erb"
YAML.load(ERB.new(yaml.read).result) || {}
elsif ENV['DATABASE_URL']
# Value from ENV['DATABASE_URL'] is set to default database connection
# by Active Record.
{}
else
raise "Could not load database configuration. No such file - #{yaml}"
end
As you can see - if no such file or ENV variable then rails throws error.

migration error with rake db:migrate

I created a new model, but when I run the rake db: migrate command, it shoots me the following error:
rake aborted!
Gem::LoadError: You have already activated rake 10.4.0, but your Gemfile requires rake
10.3.2. Prepending `bundle exec` to your command may solve this.
/Users/yedidyaweiner/projects/music-app/config/boot.rb:4:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/config/application.rb:1:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/yedidyaweiner/projects/music-app/config/boot.rb:4:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/config/application.rb:1:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
What am I doing wrong?
use
bundle exec rake db:migrate
You can also update your gems by running
bundle update
Execute the below commands
a) delete your Gemfile.lock file
b)bundle install
It should update Gemfile.lock with correct rake.
OR
a) gem uninstall rake -v 10.4.0
b) gem install rake -v 10.3.2
then try running 'rake db:migrate'. it should work.

rake db:migrate RoR

well i try to install gem 'omniauth-twitter', create controllers and model this way
rails g controller sessions
rails g model userGem provider:string uid:string name:string
but, in the next step when i try to do a rake db:migrate, throw this error:
rake aborted!
Gem::LoadError: You have already activated rake 10.3.2, but your Gemfile requires rake 10.2.1. Prepending `bundle exec` to your command may solve this.
/home/salinas/.rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:34:in ` block in setup'
/home/salinas/.rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:19:in ` setup'
/home/salinas/.rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler.rb:119:in `setup'
/home/salinas/.rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/setup.rb:7:in ` <top (required)>'
/home/salinas/blog/config/boot.rb:4:in `<top (required)>'
/home/salinas/blog/config/application.rb:1:in `<top (required)>'
/home/salinas/blog/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/salinas/blog/config/boot.rb:4:in `<top (required)>'
/home/salinas/blog/config/application.rb:1:in `<top (required)>'
/home/salinas/blog/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Any idea how to fix it?
Run the command as:-
bundle exec rake db:migrate
Or remove the rake 10.3.2 as:-
gem uninstall rake
Select the rake-10.3.2 to uninstall.
After removing rake 10.3.2, no need to append bundle exec.

Rails 3.2: rake 10.0.3 required

When executing any rake operation, I get the following:
rake aborted!
You have already activated rake 10.1.0, but your Gemfile requires rake 10.0.3. Using bundle exec may solve this.
/home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/runtime.rb:33:in `block in setup'
/home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/runtime.rb:19:in `setup'
/home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler.rb:120:in `setup'
/home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/setup.rb:7:in `<top (required)>'
/home/cristi/code/kodion/config/boot.rb:6:in `<top (required)>'
/home/cristi/code/kodion/config/application.rb:1:in `<top (required)>'
/home/cristi/code/kodion/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
I am not sure what I can do to solve this. bundle exec doesn't solve anything.
You either need to run the command in the context of the bundle (recommended):
> bundle exec rake db:version
Or you need to uninstall the offending rake gem version.
> gem uninstall rake
> # pick version 10.1.0 from the offered choices.
I ran into this same type of error. Try this:
bundle exec rake db:migrate

Resources