I'm having a hard time getting Sinatra running on my local setup, Ubuntu Karmic 9.10. The error getting thrown when I have require 'sinatra' is:
NoMethodError: undefined method `[]' for nil:NilClass
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:891:in `compile'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:883:in `gsub'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:883:in `compile'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:856:in `route'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:838:in `get'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1077
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:929:in `configure'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1076
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra.rb:4
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):2
from :0
I've tried:
Uninstalling/reinstalling Sinatra
Updating all gems
Ensuring all dependencies exist (rack)
Any ideas? Your time and help is greatly appreciated!
This is an issue apparently only coming up with 1.8-head on Linux. It is related to regexp matching. If you take a look in the code: path does match /((:\w+)|[\*#{special_chars.join}])/, but $2 is nil, even though it is supposed to be a String.
I recommend switching your ruby version for now.
Related
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.
After installing Ruby, Cucumber and Watir using gem I get the following error:
uninitialized constant Cucumber::Rb_Support (NameError)
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:41:in `constantize_name'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:13:in `block in constantize'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:12:in `each'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:12:in `constantize'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:87:in `load_programming_language'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:242:in `programming_language_for'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:226:in `load_file'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:97:in `block in load_files!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:96:in `each'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:96:in `load_files!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime.rb:242:in `load_step_definitions'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime.rb:65:in `run!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/cli/main.rb:38:in `execute!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/bin/cucumber:9:in `<top (required)>'
W:/Programme/Ruby193/bin/cucumber:23:in `load'
W:/Programme/Ruby193/bin/cucumber:23:in `<main>'**
Anyone got any idea why this is not working?
I copied the exact example from the github page.
I finally found a solution myself.
If anyone runs into this problem it is most likely caused by Ruby versions that are not compatible with Gherkin/Cucumber and/or Watir.
Although there are newer version of Ruby, the only versions that worked on my Windows 7 (Win64) machine were a combination of:
Ruby: rubyinstaller-2.0.0-p645.exe
DevKit: DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
Then I followed the installation instructions on http://www.spritecloud.com/2015/04/complete-setup-guide-for-ruby-cucumber-and-watir-on-windows/
And I used the example on https://github.com/spriteCloud/cucumber-watir-example which worked.
Following this did not create any errors and the example worked.
Good luck!
I attempted to generate a migration like:
rails generate migration RemovefromGenotypes box:integer well:string
but then I get this error:
/usr/share/rails-ruby1.8/railties/lib/rails_generator/options.rb:32:in `default_options': undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)
from /usr/share/rails-ruby1.8/railties/lib/rails_generator/base.rb:90:in `<class:Base>'
from /usr/share/rails-ruby1.8/railties/lib/rails_generator/base.rb:85:in `<module:Generator>'
from /usr/share/rails-ruby1.8/railties/lib/rails_generator/base.rb:48:in `<module:Rails>'
from /usr/share/rails-ruby1.8/railties/lib/rails_generator/base.rb:6:in `<top (required)>'
from /home/caseyr/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/caseyr/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/share/rails-ruby1.8/railties/lib/rails_generator.rb:34:in `<top (required)>'
from /home/caseyr/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/caseyr/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/share/rails-ruby1.8/railties/bin/rails:14:in `<main>'
I have no clue where to start to debug this, but would certainly appreciate it if anyone could point me in the right direction...
Thanks!
--rick
Happened to me while installing rails 2.3.14 after rails 3.2.6
It seems rails 2.3 overwrites some rails 3 files. Fixed by removing 2.3 and reinstalling 3.2
I have same issue. Use following command and problem gone
gem install rails
This will install updated rails and all thing working find again.
I am trying to run metric_fu with my rails 3.0 application.
I have checked metrical gem to avoid dependencies problems and make it easier to setup metric_fu.
I could let it work but only having one exception
/home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb:239:in `block in scan_delimited_region': undefined method `length' for nil:NilClass (NoMethodError)
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb:231:in `loop'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb:231:in `scan_delimited_region'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb:143:in `step'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/syntax-1.0.0/lib/syntax/common.rb:77:in `tokenize'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/syntax-1.0.0/lib/syntax/convertors/html.rb:16:in `convert'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:59:in `block (2 levels) in write_file_data'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:46:in `each'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:46:in `each_with_index'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:46:in `block in write_file_data'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:40:in `each_pair'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:40:in `write_file_data'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:34:in `write'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metric_fu-2.1.1/lib/base/report.rb:48:in `save_templatized_report'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metrical-0.0.7/lib/metrical.rb:54:in `run_metric_fu'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metrical-0.0.7/lib/metrical.rb:18:in `run'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/gems/metrical-0.0.7/bin/metrical:4:in `<top (required)>'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/bin/metrical:19:in `load'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180#metrics/bin/metrical:19:in `<main>'
I tried to edit this file gems/syntax-1.0.0/lib/syntax/lang/ruby.rb line#239
start_group inner_group, text if text.length > 0
and edited it to be
start_group inner_group, text if !text.blank?
It worked without exception this time and I could generate the metric_fu report but with two problems:
The mertrical task didn't finish its work. It seems it is got in an infinite loop.
Some reports like reek, roodi and rails best practices could display results successfully, but don't display charts; they display "NO Data" in place of charts
I am not sure if my ruby code update harms it or something else?
I'm trying to install Community Engine using the instructions here: http://github.com/bborn/communityengine
At first I thought it might be because I had Rails 2.3.5 and desert 0.5.3 which were higher versions than what was mentioned on the installation site. However moving to rails 2.3.4 and desert 0.5.2 did not work.
Any ideas as to what might be going on?
$ script/generate plugin_migration
/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecat
ed and will be removed on or after August 2010. Use #requirement
/cygdrive/c/users/me/jesse/projects/ceng1/config/routes.rb:2: undefined local variable or method `map' for main:Object (NameError
)
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:147:in `load_without_new_constant
_marking'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:147:in `load_without_desert'
from /usr/lib/ruby/gems/1.8/gems/desert-0.5.2/lib/desert/ruby/object.rb:18:in `load'
from /usr/lib/ruby/gems/1.8/gems/desert-0.5.2/lib/desert/ruby/object.rb:32:in `__each_matching_file'
from /usr/lib/ruby/gems/1.8/gems/desert-0.5.2/lib/desert/ruby/object.rb:17:in `load'
from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:286:in `load_routes!'
from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:286:in `each'
from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:286:in `load_routes!'
from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:266:in `reload!'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:537:in `initialize_routing'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:188:in `process'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
from /cygdrive/c/users/me/jesse/projects/ceng1/config/environment.rb:6
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/generate.rb:1
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/generate:3
UPDATE
I figured it out:
The problem is with vendor/rails
do this:
rake rails:freeze:gems
This works for me!
This might be a possible solution:
Running into issues when running Rails on Ubuntu