ruby-debug19: Can't get working with Ruby 1.9.1p376 - ruby

I'm trying to use ruby-debug19 with Ruby 1.9.1p376 but am getting the following error:
test.rb:2:in `require': no such file to load -- ruby-debug19 (LoadError) from test.rb:2:in `<main>'
Here's test.rb:
require 'rubygems'
require 'ruby-debug19'
Here's the output of "gem list":
*** LOCAL GEMS ***
ruby-debug19 (0.11.6)
(etc.)
So running "ruby test.rb" generates the above error.
Am I doing this wrong? I thought this was the correct way to run ruby-debug19 (by including the gem and adding "debugger" statements) and haven't been able to find any articles/posts with the same problem.
I am using RVM but the above output is all under the same version of Ruby ("ruby -v" shows 1.9.1p376 as expected, and the gem list output is specific to that version and not the OS X system-installed version 1.8.7).

Try just
require 'ruby-debug'
(Despite the gem's name)
Also you don't need require 'rubygems' anymore when using Ruby 1.9.

For ruby 1.9.3 and Rails 3.2 with pow:
In your Gemfile:
group :development do
gem 'debugger'
end
And at the bottom of config/environments/development.rb:
require 'debugger'
Debugger.start_remote
Debugger.settings[:autoeval] = true
Then connect to the debugger in your terminal using:
rdebug -c

For bundler (rails 3):
gem 'ruby-debug19', :require => 'ruby-debug'

Related

issue with sqlite3 gem while using ruby, sinatra & Rake

I have the sqlite3 gem in my Gemfile. Running 'bundle install' works without errors. When running a dababase migration using Rake:
rake db:create_migration NAME=create_messages
I get the following error:
rake aborted!
LoadError: Could not load 'active_record/connection_adapters/sqlite_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.
I even tried specifying sqlite3 with 1.3.3 and then with 1.3.4 versions in the Gemfile but that did not resolve the issue. Ruby version is 1.9.3
Following is from my environments.rb file:
configure :development do
set :database, 'sqlite:///dev.db'
set :show_exceptions, true
end
Following is from Gemfile:
source 'https://rubygems.org'
#ruby "1.9.3"
gem "sinatra"
gem "activerecord"
gem "sinatra-activerecord"
gem 'sinatra-flash'
gem 'sinatra-redirect-with-flash'
group :development do
gem 'sqlite3-ruby'
gem "tux"
end
I have also tried sqlite3 in place of sqlite3-ruby but that did not solve the issue.
Try this!
set :database, 'sqlite3:///dev.db'
This was resoved after upgrading to ruby v2.2.1 and updating all the gems again. I installed v2.2.1 via RVM.

require not working with rspec

Here is my file, test.rb:
require 'rubygems'
require 'pry'
There is no problem running it with ruby:
$ ruby test.rb
However, there is an error with rspec:
$ rspec test.rb
/path/to/test.rb:2:in `require': no such file to load -- pry (LoadError)
Versions:
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin12.5.0]
$ rspec -v
3.0.4
$ gem -v
2.0.14
$ gem list pry
*** LOCAL GEMS ***
pry (0.9.12.6)
Found the issue.
rspec was installed using bundle install.
pry was installed using gem install.
I went back and installed pry using bundle install and now rspec runs without error.
I cannot however explain why exactly the failure occurs. Anyone?
Bundler is probably storing/looking for gems in a different location than gem install. Unless you have a extremely good reason to, it's better to always use bundler and the Gemfile.
Oh, I also strongly recommend you to install a newer version of Ruby. That should be pretty simple using RVM.

Can' include gem in my code

I don't get why my script can't find the gem that I just installed. Here is the code of main.rb
require 'exifr'
At this point I get
LoadError: no such file to load — exifr
error message
Here is the output of
gem environment
GEM PATHS:
- /Users/me/.rvm/gems/ruby-1.9.3-p194
When I do
ls /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/exifr-1.1.3/bin/exifr
I get
/Users/me/.rvm/gems/ruby-1.9.3-p194/gems/exifr-1.1.3/bin/exifr
So the gem is in that location.
I'm running Mac OS Lion.
What I do wrong ?
//EDIT
gem list exifr
*** LOCAL GEMS ***
exifr (1.1.3)
1.9.3-p194 :001 > require 'exifr'
=> true
when running ruby 1.9 you do not have to require rubygems anymore, so this should not be an issue.
looking at the bin directory is not of any use, cause the gems usually live in lib.
if you do a gem list exifr your installed gem should print out like
*** LOCAL GEMS ***
exifr (1.1.3)
the next step would be to try it out via the ruby REPL
$ irb
1.9.3p125 :001 > require "exifr"
=> true
1.9.3p125 :002 > exit
this indicates that everything is installed fine.

Bundle don't works with mongo_ext

I have a problem with a very simple Gemfile:
source :rubygems
gem 'mongo'
gem 'mongo_ext'
I installed the gems with "bundle install" but it doesn't load mongo_ext.
irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'mongo'
**Notice: C extension not loaded. This is required for optimum MongoDB
Ruby driver performance. You can install the extension as follows:
gem install bson_ext
If you continue to receive this message after installing, make sure that the
bson_ext gem is in your load path and that the bson_ext and mongo gems are of
the same version.
=> true
But if I use the system irb I it is load:
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'mongo'
=> true
irb(main):003:0>
Maybe that behavior is because mongo_ext includes C extensions.
You need to add bson and bson_ext to your Gemfile:
source :rubygems
gem 'mongo'
gem 'mongo_ext'
gem 'bson'
gem 'bson_ext'
And generally speaking, it's a good idea to specify versions of the gems you are using. That way you can ensure your code works even if a gem makes breaking changes (or adds new bugs that affect you). Specify the newest version that is out at the time you start your project, but upgrade them only with care. Example:
source :rubygems
gem 'mongo', '1.5.1'
gem 'mongo_ext', '0.19.3'
gem 'bson', '1.5.1'
gem 'bson_ext', '1.5.1'

How to access 'zip' gem (or 'rubyzip') in Ruby?

I must be missing something totally obvious but I can't seem to get the 'zip' gem to work. I've installed it with rubygems just like I've done with many other gems. Rubygem says it's there but yet when I try to require it, Ruby says it's not there. I'm experiencing the same problem on both Windows and Linux. Here's a Linux session (extra output removed for brevity):
~$ ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
~$ gem list z
~$ sudo gem install zip
Successfully installed zip-2.0.2
~$ irb
irb(main):001:0> require 'zip/zip'
LoadError: no such file to load -- zip/zip
from (irb):1:in `require'
from (irb):1
from :0
And a Windows session:
C:\> ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
C:\> gem list z
C:\> gem install zip
Successfully installed zip-2.0.2
C:\> irb
irb(main):001:0> require 'zip/zip'
LoadError: no such file to load -- zip/zip
from (irb):1:in `require'
from (irb):1
I'm thinking perhaps there's some underlying dependency that 'zip' needs but I haven't found anything about that in the docs.
I've also had the same lack of success with 'rubyzip' It seems that perhaps 'zip' and 'rubyzip' are forks?
Any ideas? Or if there's a better gem out there for archiving, I'd love to hear about it. The choice of zip archiving gems is confusing. The gem 'Zippy' looks good but it requires 'zip' so I'm still stuck.
Try this.
gem install rubyzip2
then
irb> require 'rubygems'
#=> true
irb> require 'zip/zip'
#=> true
# you can also require 'zip/zipfilesystem'
With rubyzip 1.1.0 the correct require is
require 'zip'
As per the docs at http://rubydoc.info/gems/rubyzip/1.1.0

Resources