I'm trying to run a script, which has a line:
require 'headless'
There are several other gems that are working perfect in the same script, here's httpd error log:
:/usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:128:in `require'
:cannot load such file -- headless
What is wrong here? I can see that I'm missing something, under
/usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/ there is no core_ext directory.
I'm just trying to move some scripts from an old server to a new server.
Put gem "headless" in your Gemfile and run bundle install
My apologies for the length of the question, but I want to make it clear I am not making any stupid mistakes!
So, I am struggling to get debugging working in RubyMine 4.5 using Ruby 1.9.3, my steps are as follows:
Fresh (i.e. having removed all previous ruby and gem directories) install of Ruby 1.9.3, Ruby Gems, DevKit and Rails (following this guide) - that works fine.
I then try to begin working with my team's ruby code. I open up the directory in RubyMine (remembering first to delete the .idea directory) and am prompted to run bundle install which I do (from console) as requested. This completes successfully. Restart RubyMine.
I then ensure Ruby is working: Tools > IRB Console > puts "test" #test => nil - Works
I now try the debugger (SHIFT + F9) and see the message:
The gem ruby-debug-base19x required by the debugger is currently not installed. Would you like to install it?"
I click cancel and check my Gemfile, the only ones related to debugging present are:
# Debugging
gem 'debugger'
#gem 'ruby-debug-base19', :require => false
#gem 'ruby-debug19', :require => false
gem 'ruby-prof', :require => false #, :git => 'git://github.com/wycats/ruby-prof.git'
Looks like we have debugger in favour of ruby-debug. Reading here, however, it seems debugger is not sufficient. I need to install ruby-debug-base19x. So, following SO, I comment out debugger from Gemfile and run
gem install ruby-debug-base19x --pre
gem install ruby-debug-ide --pre
Which run fine, so I add
gem 'ruby-debug-base19x', '0.11.30.pre10'
gem 'ruby-debug-ide', '0.4.17.beta14'
to my Gemfile, and run a bundle install from the console.
Finally, i open the debugger inside RubyMine (SHIFT + F9). And puts "test" #test => nil works again. So i try double clicking in the gutter of my script to create a breakpoint, RubyMine pauses for a second and then i get:
D:\Ruby\Ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/bin/rdebug-ide --dispatcher-port 55451 --port 55452 -- S:/code/account_groups/script/rails console
Fast Debugger (ruby-debug-ide 0.4.17.beta14, ruby-debug-base 0.11.30.pre10) listens on 127.0.0.1:55452
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/debugger-1.1.4/lib/ruby_debug.so: warning: already initialized constant VERSION
5992: Exception in DebugThread loop: undefined method `errmsg' for #<Debugger::ControlState:0x2a2f3e8>
Backtrace:
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/debugger-1.1.4/lib/ruby-debug/command.rb:160:in `errmsg'
from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/debugger-1.1.4/lib/ruby-debug/commands/breakpoints.rb:81:in `execute'
from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide/ide_processor.rb:89:in `block in process_commands'
from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide/ide_processor.rb:86:in `catch'
from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide/ide_processor.rb:86:in `process_commands'
from: D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.17.beta14/lib/ruby-debug-ide.rb:160:in `block in start_control'
Process finished with exit code 0
I have also tried using a backup copy of the code and following the same steps, i also get the following error when trying to load up the debugger:
Uncaught exception: cannot load such file -- ruby-debug
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
S:/code/account_groups_so/lib/systematic-online/r_spec_runner.rb:5:in `<top (required)>'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
S:/code/account_groups_so/config/environment.rb:12:in `block in <top (required)>'
S:/code/account_groups_so/config/environment.rb:12:in `each'
S:/code/account_groups_so/config/environment.rb:12:in `<top (required)>'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:103:in `require_environment!'
D:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:40:in `<top (required)>'
S:/code/account_groups_so/script/rails:6:in `require'
S:/code/account_groups_so/script/rails:6:in `<top (required)>'
There is nothing wrong with the script (i have used it fine before) and the trace seems related to ruby-debug-ide - what's going on?
Thanks for any help - this is driving me mad!
UPDATE: RubyMine 6+ supports debugger gem.
Make sure to remove gem 'debugger' from your Gemfile, it's a known conflict that will break debugging from RubyMine. You need only 2 gems related to debugger, exactly as stated in my another answer linked in your question.
After removing the gem you need to ensure it's not referenced anywhere in the project. In this particular case r_spec_runner.rb had require 'ruby-debug' statement causing cannot load such file -- ruby-debug error when trying to run rails console.
To escape this problem I have this line in my Gemfile:
gem 'debugger' unless ENV["RM_INFO"]
Just to document the solution from jetbrains:
Use either:
gem 'debugger', {group: [:test, :development]}.merge(ENV['RM_INFO'] ? {require: false} : {})
Or:
gem 'pry-debug', {group: [:test, :development]}.merge(ENV['RM_INFO'] ? {require: false} : {})
This makes sure that the Gemfile.lock remains unchanged, so a group with mixed RubyMine and vi/sublime/whatever can work happily, by do not requiring the gem in a RubyMine environment.
I had the same issue, and it cost me hours to get it working. Here is what finally got the debugger going (this is using RVM):
Quit RubyMine
If Ruby 1.9.3 is installed, uninstall it: rvm remove 1.9.3
Install Ruby 1.9.3 under RVM: rvm install 1.9.3 --with-gcc=clang - this produces the error "unsupported option '--with-libyaml'", but I haven't seen any ill effects from this yet
Switch to the new ruby: rvm use 1.9.3
List and remove all ruby-debug* gems: gem list | grep debug - gem uninstall <found gems>
Download linecache19 from http://rubyforge.org/frs/?group_id=8883 and install the gem, i.e.: gem install linecache19-0.5.13.gem
Lauch RubyMine, and run the debugger; it will inform about missing debug gems (i.e. ruby-debug-ide); let RubyMine install those.
That's when the debugger started working. See also this RubyMine support discussion: http://devnet.jetbrains.com/message/5443846#5443846
Finally got this working today with a huge kludge hack. I think the step that did it was
sudo chmod -R 777 ~/.rvm
Let RubyMine do its thing
I also made sure to uninstall every gem I had besides rake. I think reby-debug-ide, ruby-debug-base19x, linecache19, ruby_core_source, archive-tar-minitar, and columnize are the important ones. I also uninstalled rvm and reinstalled with clang. But I'd try just doing the chmod thing first. I tried changing to 766, but RubyMine didn't like it. So huge kludge hack it is. I now get lots of warnings about Insecure world but at least the debugger is working. Pretty sure the next version of RubyMine will not use the old ruby-debug-base19x, but instead the more recently edited gems at https://github.com/ruby-debug. So hopefully someone at the awesome JetBrains will fix it. Btw also tried running RubyMine with sudo mine but that didn't do the trick either.
I had some problems with the debugger.
I installed Rails and set the path in configuration options to the ruby.exe in the rails installation and everything is working perfect.
I am following the "Intro to rails Screencast - the tutorial I wish I had" from http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/?search_index=2
Based on that I added the following gems to my file -
group :test, :development do
gem 'turn'
gem 'rspec-rails'
gem 'capybara'
gem 'guard-rspec'
gem 'libnotify'
end
I than ran the following commands -
rails g rspec:install
guard init rspec
guard
I get the following error on running guard. I should be instead seeing the failed tests. I have already generated an integration test -
Guard here! It looks like your project has a Gemfile, yet you are
running guard outside of Bundler. If this is your intent, feel free
to ignore this message. Otherwise, consider using bundle exec guard
to ensure your dependencies are loaded correctly. (You can run guard
with --no-bundler-warning to get rid of this message.)
Guard uses Libnotify to send notifications. Guard is now watching at
'/home/murtaza/workspace/rails/tasks' Guard::RSpec is running, with
RSpec 2! Running all specs gem install minitest
/home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/testcase.rb:9:in
<class:TestCase>': uninitialized constant
Test::Unit::TestCase::Assertions (NameError) from
/home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/testcase.rb:8:in
' from
/home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/testcase.rb:4:in
<module:Test>' from
/home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/testcase.rb:3:in
' from
/home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:5:in
<top (required)>' from
/home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/assertions.rb:4:in
' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-rails-2.11.0/lib/rspec/rails/adapters.rb:2:in
<top (required)>' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-rails-2.11.0/lib/rspec/rails.rb:10:in
' from
/home/murtaza/workspace/rails/tasks/spec/spec_helper.rb:4:in <top
(required)>' from
/home/murtaza/workspace/rails/tasks/spec/requests/tasks_spec.rb:1:in
require' from
/home/murtaza/workspace/rails/tasks/spec/requests/tasks_spec.rb:1:in
<top (required)>' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:inload' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in block in load_spec_files' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:inmap' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in load_spec_files' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:inrun' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in
run' from
/home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in
block in autorun'
>
The issue is with the 'turn' gem. Removing it does the trick.
https://github.com/rspec/rspec-rails/issues/484
Try running bundle exec guard as your final command instead of running guard.
The bundle exec portion of the command tells guard to run within the gems that were loaded via Bundler. Bundler is a tool that allows your local folder to have it's own gem environment.
That's what the error message indicates:
Guard here! It looks like your project has a Gemfile, yet you are running guard outside of Bundler. If this is your intent, feel free to ignore this message. Otherwise, consider using bundle exec guard to ensure your dependencies are loaded correctly. (You can run guard with --no-bundler-warning to get rid of this message.)
I'm following through the "Learn Rails by Example" book, and I'm trying to run the tests. For some reason I can't get rspec to work properly.
If I run the rspec spec/ command as he instructs, I get the following error:
$ rspec spec/
/home/desktop/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in `block in setup':
You have already activated rspec-core 2.7.1, but your Gemfile requires rspec-core 2.6.4.
Using bundle exec may solve this. (Gem::LoadError)
The odd thing is my Gemfile doesn't specify version--
group :development do
gem 'rspec-rails'
end
group :test do
gem 'rspec'
gem 'webrat'
end
If I follow the advice from the error message and use bundle exec rspec spec/ then the first two tests pass-- but the new "about" page we built in the tutorial fails with the following error, even though as far as I can tell the page I'd built (and controller actions etc.) are exactly as they should be:
Failures:
1) PagesController GET 'about' should be successful
Failure/Error: response.should_be_success
NoMethodError:
undefined method `should_be_success' for #<ActionController::TestResponse:0x00000003539438>
# ./spec/controllers/pages_controller_spec.rb:23:in `block (3 levels) in <top (required)>'
Finished in 0.10861 seconds
3 examples, 1 failure
Failed examples:
rspec ./spec/controllers/pages_controller_spec.rb:21 # PagesController GET 'about' should be successful
I'm a pretty experienced programmer but I've run into endless issues with conflicting gem versions and a hundred different ways to accomplish all the different tasks using Rails (eg. "use RVM", "Don't use RVM", "install gems using sudo", "don't install gems using sudo" etc.)
My dev machine is running ubuntu linux.
Thanks for any help-- please explain if you would what I'm doing wrong in Ruby noob language!
Running bundle exec is correct, and is needed because you have a newer version of that gem installed that gets loaded instead of the one specified in your Gemfile.lock. Using bundle exec overrides the load path, causing only the gems specified in your Gemfile.lock to be loaded. (You may find it handy to alias bundle exec to something shorter.)
The answer to the second problem is right in the error messages:
undefined method `should_be_success'
it should be should be_success.
I'm attempting to use rspec in a rails project I've just upgraded to rails 2.3.2. I've installed rspec 1.2.6 and rspec-rails 1.2.6 as plugins in the app.
My problem is the specs don't have access to my app classes or any of the rails standard libraries.
First I had to specify the model class I want to test by using the full path from RAILS_ROOT but now as it loads the class I get the following
/app/models/person.rb:1: uninitialized constant ActiveRecord (NameError)
from ./spec/models/person_spec.rb:1:in `require'
from ./spec/models/person_spec.rb:1
from /Users/law/Projects/roster/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:15:in `load'
from /Users/law/Projects/roster/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:15:in `load_files'
from /Users/law/Projects/roster/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in `each'
from /Users/law/Projects/roster/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in `load_files'
from /Users/law/Projects/roster/vendor/plugins/rspec/lib/spec/runner/options.rb:99:in `run_examples'
from /Users/law/Projects/roster/vendor/plugins/rspec/lib/spec/runner/command_line.rb:9:in `run'
from /Users/law/Projects/roster/vendor/plugins/rspec/bin/spec:4
rake aborted!
I am launching rspec by calling rake spec from the root of the application.
Any ideas on what might be missing in this situation?
you need indeed include the spec_helper.rb in every spec file you write....
You can run individual specs that way:
$ spec specs/models/person_spec.rb
instead of always running the whole spec suite
I havn't used spec, so this may not solve your problem, but if you're writing your own rake task and need your rails environment, you have to ask for it.
task(:task_name => :environment) do
# Task Implementation Here
end