The ruby version I'm using is 1.8.6
I installed gem "net/ssh" using command "gem install net-ssh"
But on running the following script
require 'rubygems'
require 'net/ssh'
HOST = '10.102.5.100'
USER = 'user'
PASS = 'test'
Net::SSH.start( HOST, USER, :password => PASS ) do|ssh|
result = ssh.exec!('stat ssl')
puts result
end
Error:
/usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:106:in `load': undefined method `start_with?' for "*":String (NoMethodError)
from /usr/local/rubygems/lib/rubygems/custom_require.rb:36:in `partition'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:106:in `each'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:106:in `partition'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:106:in `load'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:81:in `foreach'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:81:in `load'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:63:in `for'
from /usr/local/rubygems/lib/rubygems/custom_require.rb:36:in `inject'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:62:in `each'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:62:in `inject'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh/config.rb:62:in `for'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh.rb:239:in `configuration_for'
from /usr/local/rubygems/gems/gems/net-ssh-2.9.1/lib/net/ssh.rb:182:in `start'
from TestSSH.rb:9
Why do I get this error?
As the comments on your question point out, the problem arises because Ruby 1.8.6 doesn't have the String#start_with? method. The best solution would be to upgrade to a newer Ruby.
That said, according to the net-ssh README, versions prior to 2.5.1 support Ruby 1.8.x. A visual inspection of the file lib/net/ssh/config.rb as of net-ssh version 2.5.0 confirms that it doesn't use the start_with? method, so you might try that one. Be sure to read the changelog to make sure that the features you need are present in the version you use.
Related
When I run cucumber, I get the following messages:
*** WARNING: You must use ANSICON 1.31 or higher (http://adoxa.110mb.com/ansicon) to get coloured output on Windows
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb:3:in `<top (required)>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:21:in `initialize'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:40:in `new'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:40:in `execute!'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:20:in `execute'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/bin/cucumber:14:in `<top (required)>'
C:/RailsInstaller/Ruby2.1.0/bin/cucumber:23:in `load'
C:/RailsInstaller/Ruby2.1.0/bin/cucumber:23:in `<main>'
MiniTest::Unit::TestCase is now Minitest::Test. From C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit/testcase.rb:8:in `<module:Unit>'
undefined method `_run_suite' for class `Test::Unit::Runner' (NameError)
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:676:in `<class:Runner>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:261:in `<module:Unit>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:15:in `<module:Test>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:7:in `<top (required)>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb:25:in `<top (required)>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:21:in `initialize'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:40:in `new'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:40:in `execute!'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:20:in `execute'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/cucumber-1.2.1/bin/cucumber:14:in `<top (required)>'
C:/RailsInstaller/Ruby2.1.0/bin/cucumber:23:in `load'
C:/RailsInstaller/Ruby2.1.0/bin/cucumber:23:in `<main>'
bundle list gives me:
DL is deprecated, please use Fiddle
Gems included by the bundle:
* builder (3.2.2)
* bundler (1.7.7)
* cucumber (1.2.1)
* diff-lcs (1.1.3)
* gherkin (2.11.8)
* json (1.8.1)
* minitest (4.7.5)
* multi_json (1.10.1)
* rspec-expectations (2.11.2)
Based on a similar question on stack exchange, I have the following in `features\support\env.rb':
require 'minitest'
module MiniTestAssertions
def self.extended(base)
base.extend(MiniTest::Assertions)
base.assertions = 0
end
attr_accessor :assertions
end
World(MiniTestAssertions)
What's my next step to getting cucumber working?
Edit:
I've tried running cucumber in a completely empty directory (expecting to get a warning that no features are defined), but get exactly the same message: the warning about minitest, then the error about undefined method '_run_suite'. Evertyhing I can find on the web about this either relates to Rails (which I'm not using) or says it's an old problem that has been fixed, so I'm completely stuck. :(
Any reason why you can't use ruby 1.9 for going through this exercise?
The latest version of the The Cucumber Book - version 3.0 - was released in Mar 2014 when ruby 1.9.3 was the most prevalently used ruby version.
The code for the book was tested with ruby 1.9.3-p194 (as mentioned in Appendix 2 - Installing Cucumber section).
The authors/pragprog may come up with a new edition of the book, and at that time they will ensure the code in the book work with ruby 2.2 or the then most commonly used version of ruby.
It is quite possible to figure out how to make these examples work for ruby 2.0 or higher version, but that is a headache I would recommend you not concern yourself at this time. Given that you are just now starting to learn about cucumber, it would be best to follow the text in the book based on the version it recommends.
After getting familiar with cucumber, and other components of the ruby world, you will appreciate why I find "How do I persuade it to use RSpec?" to be very funny. :-)
As you know, the configuration of your development environment is a tedious and error-prone task. I prefer to work in a *nix-type environment, which you could achieve on your Windows box using, say, VirtualBox or some Docker-for-Windows arrangement.
If you can get such a Docker configuration for Windows up and running, then this may be your best bet to solve the issue quickly, since Docker is all about sharing/reusing pre-configured environments/deployments, which can be a real time-saver! There are already some fine Dockerfile configurations that should help you see which components to install. See: this and that.
BTW, if you prefer to use rspec over minitest (and who wouldn't?), you'll want to use some sample code that doesn't "require 'minitest'". If you only are interested to get the current example working, you might entertain the idea that is given by the error message to "require 'minitest/autorun'". I hope it helps you--good luck!
I recently opened up irb, and now all of a sudden every time I run irb it gives me this error:
load error: /Users/addisonbean/.rvm/rubies/ruby-2.1.2/.irbrc
NoMethodError: undefined method `split' for nil:NilClass
/Users/addisonbean/.rvm/scripts/irbrc.rb:45:in `<top (required)>'
/Users/addisonbean/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/addisonbean/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/addisonbean/.rvm/rubies/ruby-2.1.2/.irbrc:11:in `<top (required)>'
/Users/addisonbean/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/irb/init.rb:236:in `load'
/Users/addisonbean/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/irb/init.rb:236:in `run_config'
/Users/addisonbean/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/irb/init.rb:19:in `setup'
irb(main):001:0>
But as I've shown you it still gives me the prompt after all the errors
This is all the code inside of /Users/addisonbean/.rvm/rubies/ruby-2.1.2/.irbrc (the numbers are line numbers)
8 if ENV["rvm_path"].nil?
9 require File.join(ENV["HOME"], "irbrc")
10 else
11 require File.join(ENV["rvm_path"], "scripts", "irbrc")
12 end
And I have no ~/.irbrcw
I would love some help on this, thanks!
Looking at line 45 of rvm's scripts/irbrc.rb, we can find that split being called on path. It would seem that for some reason, your path is nil - probably because one of those rescue nil blocks is running.
I wouldn't advise hacking around the internals of rvm, but it looks like you can fake this by setting the environment variable $rvm_ruby_string, as irbrc.rb checks that before it tries to figure it out. Setting it to "2.1.2" should match what it calculates.
These steps solved my problem:
find the current ruby version
ruby -v
example:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
remove this version
rvm remove 2.1.2
install again
rvm install 2.1.2
My system configurations Windows 7, IE8
when I try to open the firefox browser I got the following error can anyone help me how to resolve these.
C:\Users\khan>irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'watir-webdriver'
=> true
irb(main):003:0> e=Watir::Browser.new :firefox
NoMethodError: undefined method `ascii_only?' for {}:Hash
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/json_pure-1.4.3/lib/json/pure/generator.rb:393:in `to_json'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/multi_json-1.3.7/lib/multi_json/adapters/json_common.rb:11:in `dump'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/multi_json-1.3.7/lib/multi_json.rb:115:in `dump'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/json_helper.rb:23:in `json_dump'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:254:in `write_prefs'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:253:in `each'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:253:in `write_prefs'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:252:in `open'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:252:in `write_prefs'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:232:in `update_user_prefs_in'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:79:in `layout_on_disk'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:58:in `create_profile'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:34:in `launch'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/bridge.rb:20:in `initialize'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/driver.rb:31:in `new'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/driver.rb:31:in `for'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver.rb:67:in `for'
from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/watir-webdriver-0.6.2/lib/watir-webdriver/browser.rb:46:in `initialize'
from (irb):3:in `new'
from (irb):3
from ♥:0irb(main):004:0>
Based on the exception, you are using an older version of selenium-webdriver and watir-webdriver. It is possible that there is an incompatibility between your selenium-webdriver gem and your Firefox version.
Therefore, I would suggest upgrading your gems:
gem install selenium-webdriver
gem install watir-webdriver
It might also be possible that one of the dependencies is also incompatible (eg json-pure where the exception occurs). You might want to trying updating everything.
gem update
You should try to update gem,I am not sure about it,but try once.
gem update --system
I'm trying to initialize a MongoClient from a script but I am failing.
What I simply do is:
require 'mongo'
include Mongo
client = MongoClient.new("localhost", 27017)
and it fails with the following error:
/var/lib/gems/1.9.1/gems/mongo-1.9.1/lib/mongo/cursor.rb:43:in `initialize': undefined method `connection' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.9.1/gems/mongo-1.9.1/lib/mongo/db.rb:564:in `new'
from /var/lib/gems/1.9.1/gems/mongo-1.9.1/lib/mongo/db.rb:564:in `command'
from /var/lib/gems/1.9.1/gems/mongo-1.9.1/lib/mongo/mongo_client.rb:591:in `block in check_is_master'
from /usr/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
from /var/lib/gems/1.9.1/gems/mongo-1.9.1/lib/mongo/mongo_client.rb:590:in `check_is_master'
from /var/lib/gems/1.9.1/gems/mongo-1.9.1/lib/mongo/mongo_client.rb:474:in `connect'
from /var/lib/gems/1.9.1/gems/mongo-1.9.1/lib/mongo/mongo_client.rb:698:in `setup'
from /var/lib/gems/1.9.1/gems/mongo-1.9.1/lib/mongo/mongo_client.rb:155:in `initialize'
from ./test.rb:52:in `new'
from ./test.rb:52:in `<main>'
But, when I try the exact same thing from irb, it works.
Ruby version is:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
irb is:
/usr/bin/irb1.9.1 --version
irb 0.9.6(09/06/30)
I also tried requiring 'rubygems', but from what i know, Ruby 1.9 doesn't need it.
Am I forgetting something?
This issue was resolved by re-installing ruby. I never found out what the problem was and what was causing it.
Thanks for everyone's help.
This is my Rakefile
require 'bundler'
Bundler.setup
require 'active_record'
require 'sqlite3'
require 'yaml'
require 'logger'
task :migrate => :environment do
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
end
task :environment do
ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yaml'))['development'])
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
When I execute the task I got this error:
rake aborted!
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/base.rb:2449: warning: already initialized constant Class::VALID_FIND_OPTIONS
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/base.rb:2449: warning: previous definition of VALID_FIND_OPTIONS was here
undefined method `alias_method_chain' for #<Class:0x00000001606340>
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/base.rb:2002:in `method_missing'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/validations.rb:387:in `block in included'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/validations.rb:386:in `class_eval'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/validations.rb:386:in `included'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/base.rb:3210:in `include'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/base.rb:3210:in `block in <module:ActiveRecord>'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/base.rb:3208:in `class_eval'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/base.rb:3208:in `<module:ActiveRecord>'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/activerecord-2.3.18/lib/active_record/base.rb:5:in `<top (required)>'
/home/marco/desenv/technical_analysis/Rakefile:14:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/usr/local/rvm/gems/ruby-2.0.0-p0#ta/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
I had some debug and some test... Then i moved to 3.2.13 version of active record, and all worked as expected. I didn't find any docs for 3.2.18 version...
I don't mind to use 3.2.13 version, but I got curious about that.
First of all, you were using ActiveRecord 2.3.18, not 3.2.18 (the latter of which does not exist, to my knowledge). ActiveRecord 2.3 is getting to be quite old, and I don't believe it's compatible with Ruby 2.0, which you're using.
But the central issue, I think, is that in Rails 2.2-2.3, alias_method_chain was moved to the ActiveSupport module, before being moved back to Module in 3.0. You're not including ActiveSupport in your task, and I think that's what was causing the problem.
So I think a quick fix would be just to require "active_support".