I trying to set breakpoint in ruby-debug when run on jruby.
first I get error some like in this post Why can't I set a breakpoint in ruby-debug?
I patched linecache like Mashmagar say. First error disappear. And now I get another error
21582: Exception in DebugThread loop: undefined method `errmsg' for #<Debugger::ControlState:0x638bbdc5>
Backtrace:
/home/darius/.rvm/gems/jruby-1.7.4#global/gems/ruby-debug-0.10.4/cli/ruby-debug/command.rb:188:in `errmsg'
from: /home/darius/.rvm/gems/jruby-1.7.4#global/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/breakpoints.rb:81:in `execute'
from: /home/darius/.rvm/gems/jruby-1.7.4#global/gems/ruby-debug-ide-0.4.17.beta17/lib/ruby-debug-ide/ide_processor.rb:89:in `process_commands'
from: org/jruby/RubyKernel.java:1254:in `catch'
from: /home/darius/.rvm/gems/jruby-1.7.4#global/gems/ruby-debug-ide-0.4.17.beta17/lib/ruby-debug-ide/ide_processor.rb:86:in `process_commands'
from: /home/darius/.rvm/gems/jruby-1.7.4#global/gems/ruby-debug-ide-0.4.17.beta17/lib/ruby-debug-ide.rb:122:in `start_control'
from: org/jruby/RubyProc.java:274:in `call'
from: org/jruby/RubyProc.java:215:in `call'
[2013-07-04 19:18:08] ERROR SystemExit: exit
org/jruby/RubyKernel.java:866:in `exit'
I use jruby-1.7.4
and ruby-debug-0.10.4 gem
Related
I saw a very similar question to mine. Everything works fine on OS X, but throws errors on ubuntu 14.04. Retracing that post, I am getting the same error. The original poster gave up and used Poltergeist / PhantomJS instead. I'd like to make this work with Chrome now that PhantomJS is no longer being maintained.
Net::ReadTimeout: Net::ReadTimeout and Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start on Rails 5.1.beta System Test
Here are my install steps on Ubuntu:
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
cat <<EOF > /etc/apt/sources.list.d/google-chrome.list
deb http://dl.google.com/linux/chrome/deb/ stable main
EOF
apt-get update
apt-get install --force-yes -y google-chrome-stable
cd /root/ && curl -O "http://chromedriver.storage.googleapis.com/2.32/chromedriver_linux64.zip"
cd /root/ && unzip chromedriver_linux64.zip && cp chromedriver /usr/bin
Taking one step at a time, I confirmed google-chrome, chromedriver installed correctly and work fine. Selenium driver also works fine.
link = ENV['LINK'] || "https://www.amazon.com"
#https://stackoverflow.com/questions/44424200/how-do-i-use-selenium-webdriver-on-headless-chrome
Selenium::WebDriver::Chrome.driver_path="/usr/bin/chromedriver" if RUBY_PLATFORM.include? "linux"
options = %w[--headless --disable-gpu]
options += %w[--binary='/usr/bin/google-chrome'] if RUBY_PLATFORM.include? "linux"
driver = Selenium::WebDriver.for :chrome, switches: options
driver.navigate.to "#{link}"
driver.save_screenshot("./screen.png")
driver.quit
The Capybara test times out while visiting the url.
require 'capybara'
include Capybara::DSL
link = ENV['LINK'] || "https://www.amazon.com"
options = %w[--headless --disable-gpu]
options += %w[--binary='/usr/bin/google-chrome'] if RUBY_PLATFORM.include? "linux"
Selenium::WebDriver::Chrome.driver_path="/usr/bin/chromedriver" if RUBY_PLATFORM.include? "linux"
Capybara.register_driver(:headless_chrome) do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( chromeOptions: { args: options } )
Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities )
end
Capybara.javascript_driver = :headless_chrome
session = Capybara::Session.new(:headless_chrome)
session.visit "#{link}"
The error is the following msg:
session.visit "#{link}"
Net::ReadTimeout: Net::ReadTimeout
from /usr/lib/ruby/2.3.0/net/protocol.rb:158:in `rbuf_fill'
from /usr/lib/ruby/2.3.0/net/protocol.rb:136:in `readuntil'
from /usr/lib/ruby/2.3.0/net/protocol.rb:146:in `readline'
from /usr/lib/ruby/2.3.0/net/http/response.rb:40:in `read_status_line'
from /usr/lib/ruby/2.3.0/net/http/response.rb:29:in `read_new'
from /usr/lib/ruby/2.3.0/net/http.rb:1437:in `block in transport_request'
from /usr/lib/ruby/2.3.0/net/http.rb:1434:in `catch'
from /usr/lib/ruby/2.3.0/net/http.rb:1434:in `transport_request'
from /usr/lib/ruby/2.3.0/net/http.rb:1407:in `request'
from /usr/lib/ruby/2.3.0/net/http.rb:1400:in `block in request'
from /usr/lib/ruby/2.3.0/net/http.rb:853:in `start'
from /usr/lib/ruby/2.3.0/net/http.rb:1398:in `request'
from /var/www/railsapp/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:107:in `response_for'
from /var/www/railsapp/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:58:in `request'
from /var/www/railsapp/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from /var/www/railsapp/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:649:in `raw_execute'
... 10 levels...
from /usr/bin/irb:11:in `<top (required)>'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `load'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:27:in `run'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:332:in `exec'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:20:in `dispatch'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:11:in `start'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle:34:in `block in <top (required)>'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
from /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle:26:in `<top (required)>'
from /usr/bin/bundle:23:in `load'
from /usr/bin/bundle:23:in `<main>'
Headless Chrome and the chromedriver that support it are relatively new. Update your selenium-webdriver to the latest versions (3.5.2 as of this answer) to have support for it. Once you've done that, if you're using the latest Capybara, you can also try just using the Capybara provided registered driver, with
if RUBY_PLATFORM.include? "linux"
Selenium::WebDriver::Chrome.driver_path = "/usr/bin/chromedriver"
Selenium::WebDriver::Chrome.path = "/usr/bin/google-chrome"
end
Capybara.javascript_driver = :selenium_chrome_headless
rather than needing to register your own driver.
I am using the hanami framework and the rspec lib to test my code and PG database. When I trying to test one action I get following error:
PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
My action has been wrapped in repository transaction:
def call(params, dependencies)
begin
dependencies.repository.transaction do
create_user(params, dependencies)
assign_tags(params, dependencies)
assign_notes(params, dependencies)
end
rescue Hanami::Model::Error, Domain::Errors::Exception => error
raise Domain::Errors::CreateUserFailed, error.message
end
end
Here you can see part of my test which are failing:
it 'should raise exception if params contains duplicated email' do
expect{service.call(duplicated_email)}
.to raise_exception(Domain::Errors::CreateUserFailed)
.with_message('Duplicated values found (id or
email)')
end
it 'should raise exception if params contains duplicated note id' do
expect{service.call(duplicated_note_id)}
.to raise_exception(Domain::Errors::CreateUserFailed)
end
First test pass but the second one raises exception I mentioned earlier. I know this is caused that previous test raised exception in transaction block. I have found solution mentioned in this answer but I don't work in my case.
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with :deletion
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
Thanks for all answers:)
EDIT:
Failure/Error:
expect{service.call(duplicated_note_id)}
.to raise_exception(Domain::Errors::CreateUserFailed)
.with_message('Duplicated values found in user notes (id)')
expected Domain::Errors::CreateUserFailed with "Duplicated values found in user notes (id)", got #<Domain::Errors::CreateUserFailed: PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
> with backtrace:
# ./lib/domain/commands/create_user.rb:17:in `rescue in call'
# ./lib/domain/commands/create_user.rb:8:in `call'
# ./spec/domain/commands/create_user_spec.rb:210:in `block (3 levels) in <top (required)>'
# ./spec/domain/commands/create_user_spec.rb:210:in `block (2 levels) in <top (required)>'
# ./spec/domain/commands/create_user_spec.rb:210:in `block (2 levels) in <top (required)>'
I ran a recipe to install the mysql-client and mysql-server on my rhel6 linux box. The recipes used were downloaded from supermarket using knife tool.
i am following this tutorial step by step.
on executing this command:
chef-solo -c solo.rb -j web.json
====
I got the following error.
Recipe: mysql::client
* package[mysql] action install (up to date)
* package[mysql-devel] action install
================================================================================
**Error executing action `install` on resource 'package[mysql-devel]'**
================================================================================
Chef::Exceptions::Exec
----------------------
returned 1, expected 0
Resource Declaration:
---------------------
# In /home/subham/chef-repo/chef-repo/cookbooks/mysql/recipes/client.rb
47: package name
48: end
Compiled Resource:
------------------
# Declared in /home/subham/chef-repo/chef-repo/cookbooks/mysql/recipes/client.rb:47:in `block in from_file'
package("mysql-devel") do
action :install
retries 0
retry_delay 2
guard_interpreter :default
package_name "mysql-devel"
version "5.1.61-4.el6"
timeout 900
cookbook_name :mysql
recipe_name "client"
end
Running handlers:
[2014-11-26T06:22:23-05:00] ERROR: Running exception handlers
Running handlers complete
[2014-11-26T06:22:23-05:00] ERROR: Exception handlers complete
[2014-11-26T06:22:23-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 1 resources updated in 29.10138575 seconds
[2014-11-26T06:22:24-05:00] ERROR: package[mysql-devel] (mysql::client line 47) had an error: Chef::Exceptions::Exec: returned 1, expected 0
[2014-11-26T06:22:24-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Stacktrace at /var/chef/cache/chef-stacktrace.out
Generated at 2014-11-26 06:22:23 -0500
Chef::Exceptions::Exec: package[mysql-devel] (mysql::client line 47) had an error: Chef::Exceptions::Exec: returned 1, expected 0
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/command.rb:158:in `handle_command_failures'
/opt/chefdk/embedded/apps/chef/lib/chef/provider/package/yum.rb:1021:in `yum_command'
/opt/chefdk/embedded/apps/chef/lib/chef/provider/package/yum.rb:1136:in `install_package'
/opt/chefdk/embedded/apps/chef/lib/chef/provider/package.rb:82:in `block in action_install'
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `call'
/opt/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/chefdk/embedded/apps/chef/lib/chef/provider.rb:156:in `converge_by'
/opt/chefdk/embedded/apps/chef/lib/chef/provider/package.rb:80:in `action_install'
/opt/chefdk/embedded/apps/chef/lib/chef/provider.rb:121:in `run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/resource.rb:648:in `run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:49:in `run_action'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `each'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `block in converge'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chefdk/embedded/apps/chef/lib/chef/resource_collection.rb:96:in `execute_each_resource'
/opt/chefdk/embedded/apps/chef/lib/chef/runner.rb:80:in `converge'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:345:in `converge'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:431:in `do_run'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:213:in `block in run'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:207:in `fork'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:207:in `run'
/opt/chefdk/embedded/apps/chef/lib/chef/application.rb:236:in `run_chef_client'
/opt/chefdk/embedded/apps/chef/lib/chef/application/solo.rb:226:in `block in run_application'
/opt/chefdk/embedded/apps/chef/lib/chef/application/solo.rb:218:in `loop'
/opt/chefdk/embedded/apps/chef/lib/chef/application/solo.rb:218:in `run_application'
/opt/chefdk/embedded/apps/chef/lib/chef/application.rb:55:in `run'
/opt/chefdk/embedded/apps/chef/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:33:in `load'
/usr/bin/chef-solo:33:in `<main>'
File at /home/subham/chef-repo/chef-repo/cookbooks/mysql/recipes/client.rb
line 46 : node['mysql']['client']['packages'].each do |name|
line 47 : package name
line 48 : end
In the header comment section of the same file
# Include Opscode helper in Recipe class to get access
# to debian_before_squeeze? and ubuntu_before_lucid?
Does it mean that this recipe will only work in debian family based systems like ubuntu and not in RHEL or fedora/Cent OS ?
If yes then what changes i need to perform ?
I am having multiple problems with jruby and activerecord-3.1.0.rc5.
For example, after i have ran my migrations, I create a simple Role object from the rails console and all is good :
jruby-1.6.3 :006 > r = Role.new(:name => "Standard")
=> #<Role id: nil, name: "Standard", created_at: nil, updated_at: nil>
I then want to display all Roles so I enter
jruby-1.6.3 :007 > Role.all
I get the following stack trace:
argumentError: wrong number of arguments (3 for 2)
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:470:in `find_by_sql'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/relation.rb:111:in `to_a'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/relation/finder_methods.rb:155:in `all'
from org/jruby/RubyBasicObject.java:1684:in `__send__'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:437:in `all'
from (irb):7:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1205:in `catch'
from org/jruby/RubyKernel.java:1205:in `catch'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands/console.rb:45:in `start'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands/console.rb:8:in `start'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands.rb:40:in `(root)'
from org/jruby/RubyKernel.java:1047:in `require'
from script/rails:6:in `(root)'
I get this error of:
ArgumentError: wrong number of arguments (3 for 2)
Quite a lot with Rails 3.1r5. The whole thing looks fubar. Has anyone else ran into these problems?
I mentioned something very similar here:
ActiverREcord seems wrecked.
Here is what I am using for my jruby data access:
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jdbc-sqlite3', :require => false
Anybody else running into these problems?
I am able to create able to run my migrations from JRuby 1.6.3 and Rails 3.1rc5 and in a console session create a simple Role object like this:
jruby-1.6.3 :001 > role = Role.new(:name => "Admin")
(1.0ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
=> #<Role id: nil, name: "Admin", created_at: nil, updated_at: nil>
All is good but when I run
Role.destroy_all
I get the following stack trace:
jruby-1.6.3 :003 > Role.destroy_all
ArgumentError: wrong number of arguments (3 for 2)
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:470:in `find_by_sql'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/relation.rb:111:in `to_a'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/relation.rb:289:in `destroy_all'
from org/jruby/RubyBasicObject.java:1684:in `__send__'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:438:in `destroy_all'
from (irb):3:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1205:in `catch'
from org/jruby/RubyKernel.java:1205:in `catch'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands/console.rb:45:in `start'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands/console.rb:8:in `start'
from /Users/paulcowan/.rvm/gems/jruby-1.6.3/gems/railties-3.1.0.rc5/lib/rails/commands.rb:40:in `(root)'
from org/jruby/RubyKernel.java:1047:in `require'
from script/rails:6:in `(root)'
It would seem all is not right between activerecord-3.1.0.rc5 and jruby.
Anybody any help on this?
There has been some progress on the activerecord-jdbc-adapter front and you can now get your setup working now by using the master branch of activerecord-jdbc-adapter. Just add the following to your Gemfile:
gem 'activerecord-jdbc-adapter', :git => 'https://github.com/nicksieger/activerecord-jdbc-adapter.git
I'd only recommend doing this if you cannot wait for the final activerecord-jdbc-adapter gem and certainly not in production.
You are correct. All is not right yet with activerecord-jdbc-adapter and Rails 3.1. I'm working on it and hope to have it ready by the time Rails 3.1 goes final.
Don't you have to specify conditions for it destroy_all?
e.g.
http://apidock.com/rails/ActiveRecord/Base/destroy_all/class