Rails with ruby-debugger throw 'Symbol not found: _ruby_current_thread (LoadError)'
UPDATE:
Looks like you only need to put this in your gemfile:
gem "debugger"
and now works.
Old article follows
====================================
Jerome is correct, but lacking in the details. Here is the blow by blow, taken from this https://gist.github.com/1331533, in particular thanks to andrewroth's post. I've tested this as of the time of this post. One hopes that the changes will be deployed somewhere standard soon.
Installing ruby debugger on ruby 1.9.3-p125:
export PATCH_LEVEL=`ruby -e 'puts RUBY_PATCHLEVEL'`
export RVM_SRC=$HOME/.rvm/rubies/ruby-1.9.3-p$PATCH_LEVEL/include/ruby-1.9.1
gem install archive-tar-minitar
gem install ruby_core_source -- --with-ruby-include=/$RVM_SRC
export RVM_SRC=$HOME/.rvm/rubies/ruby-1.9.3-p$PATCH_LEVEL/include/ruby-1.9.1/ruby-1.9.3-p$PATCH_LEVEL
wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
wget http://rubyforge.org/frs/download.php/63094/ruby-debug19-0.11.6.gem
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
gem install linecache19-0.5.13.gem -- --with-ruby-include=/$RVM_SRC
# if that step failed, and you are running OSX Lion, then following this post can help you:
# http://stackoverflow.com/questions/8032824/cant-install-ruby-under-lion-with-rvm-gcc-issues
# this happens if you recently installed xcode from the app store.
# bizarrely, for me I had to do this: ln -s /usr/bin/gcc /usr/bin/gcc-4.2
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/$RVM_SRC
Then edit Gemfile:
gem 'linecache19', '0.5.13', :path => "~/.rvm/gems/ruby-1.9.3-p#{RUBY_PATCHLEVEL}/gems/linecache19-0.5.13/"
gem 'ruby-debug-base19', '0.11.26', :path => "~/.rvm/gems/ruby-1.9.3-p#{RUBY_PATCHLEVEL}/gems/ruby-debug-base19-0.11.26/"
gem 'ruby-debug19', :require => 'ruby-debug'
Then install:
bundle install
ruby-debug with Ruby 1.9.3?
Update (April 28, 2012)
Try the new debugger gem as a replacement for ruby-debug.
(credit to @ryanb)
Update (March 2, 2012)
Installation of linecache19 and ruby-debug-base19 can be easily done with:
bash < <(curl -L https://raw.github.com/gist/1333785)
(credit to @fredostarr)
Original answer
Have you looked at ruby-debug19 on ruby-1.9.3-preview1?
Here's a temporary solution:
http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debugExcerpt from the site:
First download linecache19-0.5.13.gem and
ruby-debug-base19-0.11.26.gem from
http://rubyforge.org/frs/?group_id=8883, then …$ gem install linecache19-0.5.13.gem
Building native extensions. This could take a while...
Successfully installed linecache19-0.5.13
1 gem installed
$ gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/Users/santiago/.rbenv/source/ruby-1.9.3-p0
Building native extensions. This could take a while...
Successfully installed ruby-debug-base19-0.11.26
1 gem installed
$ irb
irb(main):001:0> require 'ruby-debug'
=> true
Rails 3.2.0 rspec debugger not working
Stick this in your Gemfile:
# one-liner to install these properly: bash < <(curl -L https://raw.github.com/gist/1333785)
gem 'linecache19', '0.5.13'
gem 'ruby-debug-base19', '0.11.26'
You'll need to run that one-liner in order for bundler to pick up the proper gems.
EDIT: I forgot to link to the posts I used to get debugging working:
- ruby-debug with Ruby 1.9.3?
- ruby-debug19 on ruby-1.9.3-preview1
Rails 3.1 and Ruby 1.9.3p125: ruby-debug19 still crashes with Symbol not found: _ruby_threadptr_data_type
A fork of ruby-debug just called 'debugger' now exists that incorporates many of the fixes people had been deploying on top of ruby-debug19, so you should be able to just change your Gemfile to
gem 'debugger'
... and off you go.
Cannot use ruby-debug19 with 1.9.3-p0?
UPDATE: ruby-debug19 is not maintained anymore. This question and my answer have become irrelevant, it's far easier to use the 'debugger' gem instead.
See Debugging in ruby 1.9
I also ran into this, and found the solution in Ruby 1.9.3 and ruby-debug. You need to install not-yet-officially-released versions of ruby-debug-base19 and linecache19. The currently released versions indeed cause the exception you had.
Use this gist.
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
linecache19-0.5.13.gem
ruby_core_source-0.1.5.gem
ruby-debug19-0.11.6.gem
ruby-debug-base19-0.11.26.gem
#Then in your console
export RVM_SRC=/your/path/to/ruby-1.9.3
# Note, your source path should be something like /home/user/.rvm/src/ruby-1.9.3-p0
gem install archive-tar-minitar
gem install ruby_core_source-0.1.5.gem -- --with-ruby-include=/$RVM_SRC
gem install linecache19-0.5.13.gem -- --with-ruby-include=/$RVM_SRC
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/$RVM_SRC
gem install ruby-debug19-0.11.6.gem -- --with-ruby-include=/$RVM_SRC
railstutorial where is debug information coming from
Interesting question! I searched all library sources of a rails project for 'hash-with-ivars'
and only a single place came up: the psych
ruby library for (de-)serializing arbitrary objects to and from YAML. Specifically, these are links to the source code for reading and writing this YAML structure.
In Chapter 7 of the Rails Tutorial, this output comes out as the output of the debug(params)
command that you are instructed to put in a template. The debug
command apparently calls the psych
library to show a readable representation of the object (params
in this case).
Now, params
- the universal Rails data structure to hold parameters passed from URLs or forms - is an object that behaves like a Hash
but is not pure hash: it is an instance of class ActionController::Parameters
which is a subclass of Hash
, let's see the class definition:
module ActionController
# ...
class Parameters < ActiveSupport::HashWithIndifferentAccess
# ...
end
end
while HashWithIndifferentAccess
is a direct subclass of Hash
.
As a subclass of Hash
, the params
object can hold other data besides the hash itself and this is what psych
actually supports when trying to print the object in a readable form. Besides printing all the hash elements (under the elements
key), it tries to also list all instance variables of the object and prints it under the ivars
key.
So, all in all, this debug print simply says that the object debugged is an instance of the ActionController::Parameters
class, which is a subclass of Hash
, that besides it's hash elements has also a @permitted
instance variable defined and it is currently set to false
. The two elements, by the way, the controller
and action
are parameters used internally by Rails for routing.
When you look into the source of the class again, you will indeed find the @permitted
variable right in the constructor:
class Parameters < ActiveSupport::HashWithIndifferentAccess
# ...
def initialize(attributes = nil)
super(attributes)
@permitted = self.class.permit_all_parameters
end
end
Finally, from the documentation we can conclude that the @permitted
variable holds the state of the params permission. I.e. it is set to true
after the params are permitted by using the permit
method:
permitted = params.require(:person).permit(:name, :age)
permitted.permitted? # this prints out the @permitted instance variable
# => true
Update: why the RailsTutorial's debug output differs
The debug output at the RailsTutorial differs a bit - it does not print ivar
s. Why? It is because the feature for serializing hash-with-ivars
was added to the psych
gem in its version 2.0.9. The psych
gem is now a part of the Ruby standard library and this particular version of it has been added to the stdlib 2.3.0 preview1 version.
So, the mysteriously different output has a simple explanation: the RailsTutorial author most probably used ruby 2.2 or earlier when writing the book and this ruby version did not display instance variables in the Hash
debug output yet. Actually, there are hints in the tutorial that suggest that the author used ruby 2.1.5.
Why would `rvm install ruby-2.1.0` install preview1?
Silly clarification question (and I would post it as a comment if I had enough reputation), but have you updated RVM lately?
rvm get stable
(or if you want to live on the edge, rvm get head
) would, I expect, update the internal list of released ruby versions.
Why is my pry-byebug package giving so much output when a command executes some error?
so I recently just used rvm to download and set my default version of Ruby to 2.6.5. The verbose output has now ceased entirely.
Error installing debugger: Failed to build gem native extension with ruby-1.9.3-p362
I ran into same issue. I tried:
bundle update debugger
My Gemfile had this:
gem 'debugger'
And it worked, I did not have to change Gemfile. Output of bundle shows something like this
...
Installing debugger-ruby_core_source (1.1.6)
Installing debugger-linecache (1.1.2) with native extensions
Installing debugger (1.1.4) with native extensions
...
Related Topics
Undefined Local Variable for Hash in Method Ruby
Ruby, !! Operator (A/K/A the Double-Bang)
Installing Postgresql on Ubuntu for Ruby on Rails
How to Click First Link in List of Items After Upgrading to Capybara 2.0
How to Install Ruby 2.1.4 on Ubuntu 14.04
How to Round a Time Down to the Nearest 15 Minutes in Ruby
Why Does My Rails Rollback When I Try to User.Save
Extract All Email Addresses from Some .Txt Documents Using Ruby
How to Test If Parameters Exist in Rails
Best Way to Pretty Print a Hash
How to Integrate Paypal with Ruby on Rails
How to Solve Insecure World Writable Dir /Usr in Path,Mode 040777 Warning on Ruby
How to Implement a "Callback" in Ruby
Ruby Custom Error Classes: Inheritance of the Message Attribute