Jruby: NameError: uninitialized constant Neo4j - ruby

I ran this example from git: https://github.com/andreasronge/neo4j
require "rubygems"
require 'neo4j'
Neo4j::Transaction.run do
node = Neo4j::Node.new(:name => 'andreas')
node.outgoing(:friends) << Neo4j::Node.new(:name => 'peter')
node.outgoing(:friends).each {|node| puts "name #{node[:name]}"}
end
and it outputted the error:
NameError: uninitialized constant Neo4j
const_missing at org/jruby/RubyModule.java:2626
(root) at ./neo4j.rb:4
require at org/jruby/RubyKernel.java:1027
require at ./neo4j.rb:36
(root) at /Users/ZATLUKE/RubymineProjects/nokogiri/neo4j.rb:2
load at org/jruby/RubyKernel.java:1052
(root) at -e:1
Any ideas?

Related

NoMethodError: undefined method `task' for Sinatra::Application:Class

This is the error I get when I run any rake command: undefined method 'task' for Sinatra::Application:Class
# Rakefile
require 'sinatra/activerecord'
require 'sinatra/activerecord/rake'
require_relative './config/environment'
Dir.glob('lib/tasks/*.rake').each { |r| load r}
#lib/tasks/test_report.rake
namespace :test_report do
task :generate => :environment do
...
end
end
I run into the above error when I tried to run the command.
bundle exec rake test_report:generate
You're trying to use rake API, but it's not loaded. Add this on top of your file.
require 'rake'

`<main>': undefined local variable or method `database' for main:Object (NameError)

I want to connect MongoDB with Ruby.
I've used the following Ruby file:
require 'rubygems'
require 'mongo'
#con = Mongo::Connection.new
#db = #con['tutorial']
#users = #db['users']
When I use the command ruby connect.rb I get this error:
undefined local variable or method 'database' for main:Object (NameError)
As clearly specified in the documentation, the connection should be established that way:
#con = Mongo::Client.new('mongodb://127.0.0.1:27017/tutorial')
#users = #con[:users]

NameError: uninitialized constant Game

I have a file Word.rb
class Word
attr_accessor :word, :letters
def initialize (word)
##word = word
#letters = word.split('').map{|letter| {:letter => letter, :hidden => true} }
end
end
and another file Game.rb, which will use Word.rb
require_relative ('./Word.rb')
require 'pry'
class Game
attr_accessor :guesses, :guessed_letters, :words, :current_word
def initialize (words)
#guesses = 0
#guessed_letters = []
#words = words
#current_word = current_word
end
end
And I'm getting the following error:
NameError: uninitialized constant Game
When I try to create a instance of Game like this:
game = Game.new(['hello', 'sunshine', 'chipmunk', 'twitch'])
I just am not sure what I am doing wrong since I am requiring the Word.rb file that Game.rb will need. All files are on the same level, nothing is in a subdirectory. Interestingly, I do not get this error once I comment the require_relative line out (but of course, I need that file required). I have also tried not using require_relative and simply using require as well as a couple other varieties: parens/no parens, file extension/no file extension, etc. How do I properly require this file? I also have a lovely and robust array of words sitting in another file that I would like to require to be used and passed into Game.new().
Look What I did
$ mkdir test
$ cd test
$ gedit Word.rb
# and copied your content and saved
$ gedit Game.rb
# and copied you content and saved
$ irb
After IRB session run I did following
2.1.1 :001 > game = Game.new(['asd'])
NameError: uninitialized constant Game
from (irb):1
from /home/shiva/.rvm/rubies/ruby-2.1.1/bin/irb:11:in `<main>'
2.1.1 :002 > require 'game'
LoadError: cannot load such file -- game
2.1.1 :004 > require 'Game.rb'
LoadError: cannot load such file -- Game.rb
2.1.1 :005 > require './Game.rb'
=> true
2.1.1 :006 > game = Game.new(['shiva', 'bhusal'])
=> #<Game:0x00000003085428 #guesses=0, #guessed_letters=[], #words=["shiva", "bhusal"], #current_word=nil>
2.1.1 :007 >
Try like this

Error while creating and instance of IE

Hi all while I try to create an instance of IE I am facing the following error
my system configurations
Windows 7,64 bit
NameError: uninitialized constant Watir::IE
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'watir'
=> true
irb(main):003:0> ie=Watir::IE.new
NameError: uninitialized constant Watir::IE
from (irb):3
from D:/Ruby_1.8.7/lib/ruby/site_ruby/1.8/rubygems/specification.rb:630
irb(main):004:0>
To launch a browser in watir, you shoul use :
b = Watir::Browser.new :ie
# or :ff or :chrome or :opera ...
Note that for Internet explorer, you should download IEDriverServer.exe and add it to your path.

Bundler.require(:default) fails in Rubinius

I have a very simple app, which i tried to run with Rubinius:
Gemfile:
source 'https://rubygems.org
gem 'rake'
gem 'tiny_tds'
gem 'sequel'
lib/database.rb:
require "rubygems"
require "bundler/setup"
Bundler.require(:default)
DB = Sequel.tinytds(:host => 'SQL2012', :user => "Rails", :password => "xxx", :database => "RailsTest")
test/connection_test.rb:
require_relative "../lib/database"
DB.fetch("SELECT TOP 10 * FROM User") do |row|
puts row.to_s
end
Rakefile:
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
Rake::TestTask.new do |t|
t.test_files = FileList['test/**/*.rb']
end
task :default => :test
This runs fine with MRI 1.9.3 and MRI 2.1.0
but fails with rbx 2.2.2 :
klaus#rails-dev:$ rake test
An exception occurred running /home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/rake-10.1.1/lib/rake/rake_test_loader.rb:
no such file to load -- bigdecimal (LoadError)
Backtrace:
Rubinius::CodeLoader#load_error at kernel/common/code_loader.rb:440
Rubinius::CodeLoader#resolve_require_path at kernel/common/code_loader.rb:423
{ } in Rubinius::CodeLoader#require at kernel/common/code_loader.rb:103
Rubinius.synchronize at kernel/bootstrap/rubinius.rb:137
Rubinius::CodeLoader#require at kernel/common/code_loader.rb:102
Rubinius::CodeLoader.require at kernel/common/code_loader.rb:237
Kernel(Object)#require at kernel/common/kernel.rb:705
Object#__script__ at /home2/klaus/.rvm/gems/rbx-2.2.2/gems/tiny_tds-0.6.1/lib/tiny_tds.rb:3
Rubinius::CodeLoader.require at kernel/common/code_loader.rb:243
Kernel.require at kernel/common/kernel.rb:705
{ } in Bundler::Runtime#require at /home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76
Array#each at kernel/bootstrap/array.rb:66
{ } in Bundler::Runtime#require at /home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72
Array#each at kernel/bootstrap/array.rb:66
Bundler::Runtime#require at /home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61
Bundler.require at /home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/bundler-1.5.2/lib/bundler.rb:131
Object#__script__ at lib/database.rb:4
Rubinius::CodeLoader.require at kernel/common/code_loader.rb:243
Rubinius::CodeLoader.require_relative at kernel/common/code_loader.rb:143
Kernel(Object)#require_relative at kernel/common/kernel.rb:711
Object#__script__ at test/connection_test.rb:2
Rubinius::CodeLoader.require at kernel/common/code_loader.rb:243
Kernel(Object)#gem_original_require (require) at kernel/common/kernel.rb:705
Kernel(Object)#require at /home2/klaus/.rvm/rubies/rbx-2.2.2/site/rubygems/core_ext/kernel_require.rb:55
{ } in Object#__script__ at /home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/rake-10.1.1/lib/rake/rake_test_loader.rb:15
{ } in Enumerable(Array)#find_all at kernel/common/enumerable.rb:432
Array#each at kernel/bootstrap/array.rb:66
Enumerable(Array)#select (find_all) at kernel/common/enumerable.rb:430
Object#__script__ at /home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/rake-10.1.1/lib/rake/rake_test_loader.rb:4
Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66
Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:200
Rubinius::Loader#script at kernel/loader.rb:649
Rubinius::Loader#main at kernel/loader.rb:831
rake aborted!
Command failed with status (1): [ruby -I"lib" -I"/home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/rake-10.1.1/lib" "/home2/klaus/.rvm/gems/rbx-2.2.2#global/gems/rake-10.1.1/lib/rake/rake_test_loader.rb" "test/connection_test.rb" ]
kernel/bootstrap/proc.rb:20:in `call'
kernel/bootstrap/proc.rb:20:in `call'
kernel/bootstrap/array.rb:66:in `each'
kernel/bootstrap/array.rb:66:in `each'
kernel/common/kernel.rb:447:in `load'
kernel/delta/code_loader.rb:66:in `load_script'
kernel/delta/code_loader.rb:200:in `load_script'
kernel/loader.rb:649:in `script'
kernel/loader.rb:831:in `main'
Tasks: TOP => test
(See full trace by running task with --trace)
You probably need to add bigdecimal or rubysl to your Gemfile. rubinius has gemified their stdlib, causing issues similar to this one.

Resources