I am unable to find any explanation for this error but when I am running:
rake test or bundle exec rake test I am getting:
NoMethodError: undefined method `ignore' for Warning:Module
/Users/przemyslaw/projects/writefully/config/initializers/warning.rb:4:in `block in <top (required)>'
/Users/przemyslaw/projects/writefully/config/initializers/warning.rb:3:in `each'
/Users/przemyslaw/projects/writefully/config/initializers/warning.rb:3:in `<top (required)>'
/Users/przemyslaw/projects/writefully/config/environment.rb:5:in `<top (required)>'
/Users/przemyslaw/projects/writefully/test/test_helper.rb:2:in `require'
/Users/przemyslaw/projects/writefully/test/test_helper.rb:2:in `<top (required)>'
/Users/przemyslaw/projects/writefully/test/controllers/comments_controller_test.rb:1:in `require'
/Users/przemyslaw/projects/writefully/test/controllers/comments_controller_test.rb:1:in `<top (required)>'
Tasks: TOP => test:run
(See full trace by running task with --trace)
I am following a tutorial on codemy.net and there is nothing complicated or special about this project. I have only generated a new rails app, a couple of models and controllers and now when I am trying to run the test it gives me this error. There is no single test within my test files at the moment so this is nothing to do with testing. It looks like there is some issue with the 'ignore' method within the warning file:
config/initializers/warning.rb
# Rails will load this logic before booting up Rails server
unless Rails.env.development?
Gem.path.each do |path|
Warning.ignore(//, path)
end
end
Any help or idea would be appreciated. I am using rails 4.2.10 and ruby 2.5.8.
Seems like you missed installing the warning gem.
I suggest adding the line
gem "warning"
to your Gemfile and run bundler before restarting your application.
Related
I have a capistrano task I am trying to make into a gem so I can use it in multiple projects. The repository for this gem is located here:
https://github.com/FoamFactory/capistrano-monorepo-assets/tree/jwir3/initial-commit
I essentially used https://github.com/sheharyarn/capistrano-rake as a basis for creating my gem.
I've tested the actual rake script, but I'm actually not importing it into the project right now. Instead, I'm trying to get it to actually import the gem successfully. When I add the gem to my Gemfile as such:
gem 'capistrano-monorepoassets','0.0.6', path: "~/Source/capistrano-monorepo-assets/pkg"
Run bundle install, then attempt to import it using the following in my Capfile:
require 'capistrano/monorepoassets'
I get an error when I run cap --tasks --trace:
cap aborted!
LoadError: cannot load such file -- capistrano/monorepoassets
/home/scottj/Source/foamfactory/designsystem/Capfile:37:in `require'
/home/scottj/Source/foamfactory/designsystem/Capfile:37:in `<top (required)>'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:104:in `block in load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:103:in `load_rakefile'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:82:in `block in run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/capistrano-3.11.0/lib/capistrano/application.rb:14:in `run'
/home/scottj/.rvm/gems/ruby-2.6.1/gems/capistrano-3.11.0/bin/cap:3:in `<top (required)>'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/cap:23:in `load'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/cap:23:in `<main>'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `eval'
/home/scottj/.rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `<main>
I can't seem to get it to load the module using require, which is where I'm stuck. Can someone tell me what I'm doing incorrectly?
So this actually was happening because I didn't understand that bundle install doesn't support installing local gems by specifying the path in the Gemfile. This question actually covers the problem, and, more specifically, the answer here solved it for me.
I'm updating a Rails 3.2 app to Ruby 2.2.2. I've pulled the Rails version up to 3.2.22, which is necessary for Ruby 2.2.2. That went relatively well but prompted a Cucumber update, from 1.2.1 to 1.3.20. (I don't recall the details, because that was several failed efforts ago, but I think my features were passing but then exiting false before I did this.)
Now Cucumber features run fine (albeit with a ton of unrelated Ruby 2.2.2 warnings), but rspec does not. Specifically, when I run rake spec I get this error:
/path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:15:in `build_rb_world_factory': undefined method `build_rb_world_factory' for nil:NilClass (NoMethodError)
The stack trace leads through Capybara (2.4.4, pinned for other reasons), ActiveSupport, and Bundler back up to rspec-core.
All my searches trying to find similar issues just lead to the code, because it seems like the only place this method name exists is in code.
Why am I getting this error from Capybara/Cucumber when running rspec? How can I fix it?
ETA: Stack trace, with paths condensed a bit:
/path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:15:in `build_rb_world_factory': undefined method `build_rb_world_factory' for nil:NilClass (NoMethodError)
from /path/to/gems/cucumber-1.3.20/lib/cucumber/rb_support/rb_dsl.rb:50:in `World'
from /path/to/gems/capybara-2.4.4/lib/capybara/cucumber.rb:4:in `<top (required)>'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `block in require'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:236:in `load_dependency'
from /path/to/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
from /path/to/gems/capybara-screenshot-0.2.2/lib/capybara-screenshot.rb:96:in `<top (required)>'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
from /path/to/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
from /path/to/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
from /path/to/app/config/application.rb:13:in `<top (required)>'
from /path/to/app/config/environment.rb:2:in `require'
from /path/to/app/config/environment.rb:2:in `<top (required)>'
from /path/to/app/spec/spec_helper.rb:10:in `require'
from /path/to/app/spec/spec_helper.rb:10:in `<top (required)>'
from /path/to/app/spec/controllers/academic_years_controller_spec.rb:1:in `require'
from /path/to/app/spec/controllers/academic_years_controller_spec.rb:1:in `<top (required)>'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `each'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in `setup'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
from /path/to/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
from /path/to/gems/rspec-core-3.2.3/exe/rspec:4:in `<main>'
/path/to/ruby/ruby-2.2.2/bin/ruby -I/path/to/gems/rspec-core-3.2.3/lib:/path/to/gems/rspec-support-3.2.2/lib /path/to/gems/rspec-core-3.2.3/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed
My hunch is that there's a configuration file which needs to be rebuilt somewhere.
From your stacktrace - the capybara-screenshot gem is requiring capybara/cucumber even though you're running specs which aren't using cucumber. This means World is called from capybara/cucumber against a non-initialized cucumber, and gives the error. The version of capybara-screenshot you're using is really old, and the code that required capybara/cucumber has since been removed so you should probably update the version of capybara-screenshot you're using, and add
require 'capybara/cucumber'
require 'capybara-screenshot/cucumber'
to your env.rb or other cucumber support file
I'm just starting Test First Ruby & I'm having trouble running rakes to start solving problems.
I think it's either my version of RSpec or my version of Ruby that's causing the error.
Here's the error,
AT MacBook-Pro:01_temperature AT$ rake
(in /Users/AT/Desktop/learn_ruby)
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- temperature (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/AT/Desktop/learn_ruby/01_temperature/temperature_spec.rb:18:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `each'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:96:in `setup'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:84:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:69:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:37:in `invoke'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/exe/rspec:4:in `<top (required)>'
from /usr/bin/rspec:23:in `load'
from /usr/bin/rspec:23:in `<main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -S rspec /Users/AT/Desktop/learn_ruby/01_temperature/temperature_spec.rb -I/Users/AT/Desktop/learn_ruby/01_temperature -I/Users/AT/Desktop/learn_ruby/01_temperature/solution -f documentation -r ./rspec_config failed
I had a similar problem a few minutes ago but fixed by uninstalling RSpec v-3, and installing v-2.14.
Any help would be appreciated!
Your file temperature_spec is requiring what I presume is the source for the class under test, temperature - but the RSpec loader is not able to resolve the path for this file.
It would be helpful for you to post both the source of your rspec file and your class under test.
i am trying to deploy my rails application for the first time on vexxhost. i am using github as my Source code management and capistrano.
here is my deploy file
require 'bundler/capistrano'
require 'capistrano'
require 'bundler'
require 'capistrano-vexxhost'
# Account Settings
ssh_options[:forward_agent] = true
set :scm_command, "/home/user/opt/bin/git"
set :local_scm_command,"git"
set :user, "xxxxxxxx"
set :password, "xxxxxxxxx"
set :domain, "domain.com"
set :mount_path,"/home/xxxxxxxx/xxxxxxx"
set :application,"app name"
set :scm, :git
set :deploy_via, :copy
set :repository, "git#github.com:xxxxx/xxxxxxx.git"
default_run_options[:pty] = true
PROBLEM NO 1)
As soon as i installed gem 'capistrano' gem 'capistrano-vexxhost' i got the following error when trying to run my application locally (it was working before installing capistrano).
C:/Ruby193/lib/ruby/gems/1.9.1/gems/capistrano-2.14.1/lib/capistrano/configuration/loading.rb:18:in `instance': Please require this file from within a Capistrano recipe (LoadError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/capistrano-vexxhost-1.0.3/lib/capistrano-vexxhost/capistrano_integration.rb:6:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/capistrano-vexxhost-1.0.3/lib/capistrano-vexxhost.rb:2:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/capistrano-vexxhost-1.0.3/lib/capistrano-vexxhost.rb:2:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
from C:/Users/mummy/LagoAds/config/application.rb:9:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:53:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:53:in `block in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
NOTE But as i soon as i comment the Bundler.require line from the following code in the application.rb file, it successfully runs but doesn't recognize the gems
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
PROBLEM NO 2)
when is type "cap deploy:check" on my ruby command prompt i the get the following error.
PROBLEM NO 3)
when is type "cap deploy:cold" on my ruby command prompt i get the following error
Is there anything missing from my deploy.rb or is there anything i didnt do.
PLEASE I NEED HELP, I HAVE BEEN ON THIS PROBLEM FOR VERY LONG TIME. I AM NEW TO DEPLOYING WEB APPLICATIONS AND RAILS HAVE BEEN VERY DIFFICULT FOR ME
PLEASE HELP
Problems 2 & 3
Your second and third problems are the result of git and tar not being in your path. Either they are not installed at all, or your path is incomplete. See the errors I quoted below.
problem 2
'git' could not be found on the local host
'tar' could not be found on the local host
problem 3
no such file or directory git ls-remote...
Problem 1
Unfortunately I have no answer for #1. A guess would be that you need to add capistrano and/or capistrano-vexxhost to your deploy.rb.
In Ruby 1.9.2 stack trace I frequently see the method given as <top (required)>, as in this section of stack below. What does this mean? Is my Ruby install subtly broken?
Could not find abstract-1.0.0 in any of the sources
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/spec_set.rb:87:in `block in materialize'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/spec_set.rb:81:in `map!'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/spec_set.rb:81:in `materialize'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/definition.rb:90:in `specs'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/definition.rb:135:in `specs_for'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/definition.rb:124:in `requested_specs'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/environment.rb:23:in `requested_specs'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/runtime.rb:11:in `setup'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler.rb:107:in `setup'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/setup.rb:14:in `<top (required)>'
<internal:lib/rubygems/custom_require>:33:in `require'
<internal:lib/rubygems/custom_require>:33:in `rescue in require'
<internal:lib/rubygems/custom_require>:29:in `require'
It's the top level of a file i.e. whatever gets run when the file is required.
So if something fails during the setup of a library (for example some required file isn't found) it will show up in the stacktrace like that.
If everything you required is correct, it could mean that you're trying to create a class with a name that already exists for a module. For example the following file :
class Test
end
Will raise :
<top (required)>': Test is not a class (TypeError)
Because Test is implicitely a module.
I ran into this error of <top (required)> when I was doing the tutorial in the book "Jump Start Sinatra."
I got rid of the error by making sure that I ran sudo gem install <GEM_IN_YOUR_FILE>. So in my case I had a main.rb and in that file I had this
require 'sinatra'
require 'sinatra-contrib'
So I went back into the root of my project and ran sudo gem install sinatra and sudo gem install sinatra-contrib and then my project worked fine.
Your errors will vary, but because this is what I found when I searched on Google, I know others will come here for similar reasons. And I offer this solution to at least get you thinking in the right direction since this worked for me.
I had the same problem. Solved it by converting .rb files encoding to UTF-8-BOM using Notepad++.
Ninto's answer makes total sense. It's a stack trace that you get one things fail. I was running my tests by doing:
bundle exec rspec spec
and what I got was:
An error occurred while loading ./spec/foodie_spec.rb.
Failure/Error: require 'foodie/food'
SyntaxError:
/Users/honey/Dev/foodie/funnex/lib/funnex/food.rb:17: syntax error, unexpected end-of-input, expecting end
# ./lib/foodie.rb:4:in `require'
# ./lib/foodie.rb:4:in `<top (required)>'
# ./spec/foodie_spec.rb:1:in `require'
# ./spec/foodie_spec.rb:1:in `<top (required)>'
No examples found.
Finished in 0.00002 seconds (files took 0.07998 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
All I was doing wrong in my case was that I was missing and end.
But to understand the stack trace more, start from bottom of the commented out lines ie this line:
# ./spec/foodie_spec.rb:1:in `<top (required)>'
At line 1 of foodie_spec I had require 'foodie'
At line 4 of foodie.rb I had require 'foodie/food'
I errored out at line 17 of foodie/food
Stack traces in Ruby are also named backtraces or stack traceback