ArgumentError: tried to create Proc object without a block - ruby-on-rails

How can I resolve the following error:
$ rails db:migrate
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name,
spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name,
spell_checker)' instead.
rails aborted!
ArgumentError: tried to create Proc object without a block
D:/Projects/lms-2021/config/application.rb:9:in `<top (required)>'
D:/Projects/lms-2021/Rakefile:4:in `require_relative'
D:/Projects/lms-2021/Rakefile:4:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
(See full trace by running task with --trace)
These are the logs after rails db:migrate --trace:
$ rails db:migrate --trace
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
rails aborted!
ArgumentError: tried to create Proc object without a block
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:472:in `new'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:472:in `service_added'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:510:in `<module:Aws>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:18:in `<top (required)>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `block in require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:258:in `load_dependency'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-resources-2.9.24/lib/aws-sdk-resources.rb:1:in `<top (required)>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `block in require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:258:in `load_dependency'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/aws-sdk-2.9.24/lib/aws-sdk.rb:1:in `<top (required)>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:66:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:61:in `each'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:61:in `block in require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:50:in `each'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler/runtime.rb:50:in `require'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.3/lib/bundler.rb:174:in `require'
D:/Projects/lms-2021/config/application.rb:9:in `<top (required)>'
D:/Projects/lms-2021/Rakefile:4:in `require_relative'
D:/Projects/lms-2021/Rakefile:4:in `<top (required)>'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load_rakefile'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:703:in `raw_load_rakefile'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:104:in `block in load_rakefile'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:103:in `load_rakefile'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:20:in `block in perform'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:18:in `perform'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-5.1.7/lib/rails/command.rb:46:in `invoke'
D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
This is the application.rb file where the error is shown:
require 'uri'
require "uri/generic"
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Ilms
class Application < Rails::Application
config.to_prepare do
# Load application's model / class decorators
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
# Load application's view overrides
Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end
config.assets.initialize_on_precompile = false
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
end
end
I am not understanding where is the error and how to fix it. There seems no error in my code. The logs with --trace are showing the error occured in lib/ruby/gems/3.1.0/gems/aws-sdk-core-2.9.24/lib/aws-sdk-core.rb:472:in `new' which callback = Proc.new .
Database : postgresql
gem 'pg' already installed
rails v 5.1.7
ruby v 3.1.2
windows 10 pro
git bash terminal

You seem to be using an old version of Rails (5.1.7, EOL status) with a very new version of Ruby (3.1.2).
This error is probably a breaking change introduced in Ruby 3 that needs libraries to be adapted for it (see this case with Anycable here: https://github.com/anycable/anycable/issues/118)
As per this article : https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html you cannot use a Ruby version higher than 2.6.0 with Rails 5.1.x
The solution would be to use Ruby 2.6.0 or to upgrade your Rails app to a newer version.

Related

superclass must be an instance of Class (given an instance of Module) (TypeError) when doing `cucumber -s`

I cant seem to be able to figure out
The error logs are as follow
superclass must be an instance of Class (given an instance of Module) (TypeError)
/home/asus/code/ruby-project/cucumber/config/application.rb:11:in `<module:Cucumber>'
/home/asus/code/ruby-project/cucumber/config/application.rb:9:in `<top (required)>'
/home/asus/code/ruby-project/cucumber/config/environment.rb:2:in `require_relative'
/home/asus/code/ruby-project/cucumber/config/environment.rb:2:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-rails-2.5.1/lib/cucumber/rails.rb:12:in `require'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-rails-2.5.1/lib/cucumber/rails.rb:12:in `<top (required)>'
/home/asus/code/ruby-project/cucumber/features/support/env.rb:7:in `require'
/home/asus/code/ruby-project/cucumber/features/support/env.rb:7:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/glue/registry_and_more.rb:122:in `require'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/glue/registry_and_more.rb:122:in `load_code_file'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:81:in `block in load_files!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:80:in `each'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime/support_code.rb:80:in `load_files!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime.rb:278:in `load_step_definitions'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/runtime.rb:74:in `run!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/lib/cucumber/cli/main.rb:29:in `execute!'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/cucumber-7.1.0/bin/cucumber:9:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/bin/cucumber:25:in `load'
/home/asus/.rbenv/versions/3.1.2/bin/cucumber:25:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `load'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:23:in `run'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:486:in `exec'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:31:in `dispatch'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/cli.rb:25:in `start'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/exe/bundle:48:in `block in <top (required)>'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/home/asus/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.22/exe/bundle:36:in `<top (required)>'
/home/asus/.rbenv/versions/3.1.2/bin/bundle:25:in `load'
/home/asus/.rbenv/versions/3.1.2/bin/bundle:25:in `<main>'
The application.rb is as followed
require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Cucumber
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end
end
There are threads with similar issues (ruby on rails : <top (required)>': superclass must be a Class (Symbol given) (TypeError)), I am not sure it can be applied in this case. I tried to reinstall rails, downgrading cucumber-rails. The issue is still persisted.
I guess the problem is that you named your Ruby on Rails application Cucumber while having the cucumber gem installed too. And that this confuses Ruby.
I suggest naming your Ruby on Rails application differently and not using the same name as a well-known gem.

LoadError: cannot load such file -- zip/zip when running any rails command after upgrade

I've just upgraded to rails 6, and I'm getting the following when running rails app:update
rails aborted!
LoadError: cannot load such file -- zip/zip
/home/ben/code/app/config/application.rb:7:in `<top (required)>'
/home/ben/code/app/Rakefile:5:in `<top (required)>'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
I've updated all the gems and it's bundling and updating the gems, the gemfile.lock looks OK as well.
Here is the backtrace:
Error:[rake --tasks] rake aborted!
LoadError: cannot load such file -- zip/zip
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:332:in `block in require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:299:in `load_dependency'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:332:in `require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/axlsx-1.3.6/lib/axlsx.rb:26:in `<top (required)>'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-2.2.19/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-2.2.19/lib/bundler/runtime.rb:61:in `each'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-2.2.19/lib/bundler/runtime.rb:61:in `block in require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-2.2.19/lib/bundler/runtime.rb:50:in `each'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-2.2.19/lib/bundler/runtime.rb:50:in `require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-2.2.19/lib/bundler.rb:174:in `require'
/home/ben/code/app/config/application.rb:7:in `<top (required)>'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/ben/code/BusinessCloudEssential/Rakefile:5:in `<top (required)>'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rake-13.0.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rake-13.0.3/lib/rake/application.rb:104:in `block in load_rakefile'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rake-13.0.3/lib/rake/application.rb:103:in `load_rakefile'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rake-13.0.3/lib/rake/application.rb:82:in `block in run'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rake-13.0.3/lib/rake/application.rb:80:in `run'
/home/ben/code/app/bin/rake:4:in `<main>'
Here is the application.rb
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require 'net/http'
require 'csv'
module RailsUpgrade
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.0
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
config.time_zone = 'London'
#WARNING: This changes the way times are stored in the database (not recommended)
config.active_record.default_timezone = :local
config.log_level = :debug
config.enable_dependency_loading = true
config.eager_load_paths << Rails.root.join('lib')
config.assets.enabled = true
config.assets.version = '1.0'
config.filter_parameters << :password
config.filter_parameters << :password_confirmation
config.filter_parameters << :card_number
config.filter_parameters += [:password, :password_confirmation, :card_number]
# config.middleware.use 'CatchJsonParseErrors'
end
end
Last time I ran rails app:update was when I updated to Rails 5.2 earlier today. So not sure what the issue is.
Thanks.
You are using axlsx version 1.3.6, which includes this line: require 'zip/zip'. That's what your error message is pointing to:
/home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/axlsx-1.3.6/lib/axlsx.rb:26:in `<top (required)>'
However, I suspect that you've also inadvertently upgraded the rubyzip gem to v1.0.0+ - where the API has changed, and you now only need to require 'zip', (NOT require 'zip/zip').
There are a few solutions, such as what's mentioned on the project README or in this similar StackOverflow question:
Downgrade rubyzip back to v0.x.
Upgrade axlsx.
Add gem 'zip-zip' to your Gemfile.

rake task does not launch for lack of Mime JSON

After installing a repository locally and bundling for a rails 4.0 application, the database creation
rake db:create
command fails returning the following error:
uninitialized constant Mime::JSON
invoking from application.rb this particular line
Bundler.require(:default, Rails.env)
this line is preceeded by:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
How can I get rake to properly process?
** update **
as per request full stack trace follows. I did manage to avoid the error by removing the jbuilder gem.
NameError: uninitialized constant Mime::JSON
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder/jbuilder_template.rb:110:in `<class:JbuilderHandler>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder/jbuilder_template.rb:108:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder.rb:358:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
/Volumes/Mo/r/uelcom/config/application.rb:7:in `<top (required)>'
/Volumes/Mo/r/uelcom/Rakefile:8:in `require'
/Volumes/Mo/r/uelcom/Rakefile:8:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/bin/rake:23:in `load'
/Users/deploy/.rbenv/versions/2.6.1/bin/rake:23:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/bin/bundle:23:in `load'
/Users/deploy/.rbenv/versions/2.6.1/bin/bundle:23:in `<main>'
It seems you are using rails 5 or above.
As of rails version 5 or above accessing Mime types through Mime::JSON is deprecated, We need to access it as Mime[:json]
Please find the following references for the same - Release Note and Pull request
Deprecated accessing mime types via constants (eg. Mime::HTML). Use the subscript operator with a symbol instead (eg. Mime[:html])
As per the backtrace of the exception you have given, the gem jbuilder is causing the issue, which accesses Mime types as Mime::JSON which is deprecated.
Please find the reference of the line which causes the error on the gem jbuilder - Jubilder - Github.
You are using the older version of the jbuilder(1.5.3), please upgrade this gem to the latest version and try
Try the below version:
Gemfile
gem 'jbuilder', '~> 2.10'

Rails cucumber undefined method `config' for nil:NilClass (NoMethodError)

I have just upgraded to ruby 1.9.3-p125 (from 1.9.3-p0). All tests were working before the upgrade. Now I get the following error when running rake features
Using the default profile...
undefined method `config' for nil:NilClass (NoMethodError)
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-rails-1.3.0/lib/cucumber/rails.rb:17:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `rescue in block in require'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/bundler-1.1.3/lib/bundler/runtime.rb:62:in `block in require'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
/home/map7/pais/config/application.rb:7:in `<top (required)>'
/home/map7/pais/config/environment.rb:2:in `require'
/home/map7/pais/config/environment.rb:2:in `<top (required)>'
/home/map7/pais/features/support/env.rb:8:in `require'
/home/map7/pais/features/support/env.rb:8:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/gems/cucumber-1.1.9/bin/cucumber:14:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/bin/cucumber:19:in `load'
/home/map7/.rvm/gems/ruby-1.9.3-p194#rails3.2/bin/cucumber:19:in `<main>'
rake aborted!
Command failed with status (1): [/home/map7/.rvm/rubies/ruby-1.9.3-p194/bin...]
Tasks: TOP => features => cucumber => cucumber:ok
(See full trace by running task with --trace)
I traced this back to the rails.rb file line 17 as mentioned in the error:
if !Rails.application.config.cache_classes
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
end
So it looks like it cannot find Rails.application when within cucumber.
If I go into the console 'rails c' and type Rails.application.config it does return the Configuration object.
I've tried upgrading my cucumber-rails gem to 1.3.0 and cucumber 1.1.9.
This is likely a load order issue with the cucumber-rails gem. If you update your Gemfile not to load it immediately it'll be required later on in the process:
gem "cucumber-rails", "1.3.0", :require => false

Deploying to Heroku

Following this tutorial, I applied the steps for deploying to Heroku under 2.3.5 Deploying the demo app.
When I run the command: > heroku rake db:migrate, I get the following:
$ heroku rake db:migrate
(in /app)
rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:Ta
skLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:R
ake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (req
uired)>'
/app/.bundle/gems/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/task.rb:37:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/task.rb:37:in `<top (require
d)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.r
ake:2:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.r
ake:2:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `load'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `block
in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `<top (
required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in
`require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in
`initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:139:in
`load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:in
`method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'
Why is that? And, how can I solve this issue?
Thanks.
I have a blog post about it here:
http://codeglot.com/posts/13-you_have_already_activated_rake_0_9_2
You have two options. Keep the latest gem and do this:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
Or you need to specify the older version of rake:
gem list
Then see which version of rake you have.
gem uninstall rake -v=0.9.1
Then in your bundler specify the older version:
gem 'rake', '0.8.7'
This link may help: fix unitialized constant rake heroku
Form that post:
Put this in your Rakefile above require 'rake':
require 'rake/dsl_definition'

Resources