Trying to run some Watir code as a Rake task that is giving me this error:
$ bundle exec rake update_market_rents:market_rents
DL is deprecated, please use Fiddle
(in C:/Users/310046998/sites/testpropinvest)
rake aborted!
LoadError: cannot load such file -- watir-webdriver
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
C:/Users/310046998/sites/testpropinvest/lib/tasks/update_market_rents.rake:10:in `block (2 levels) in <top (required)>'
C:/Users/310046998/sites/testpropinvest/vendor/bundle/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => update_market_rents:market_rents
(See full trace by running task with --trace)
Code:
namespace :update_market_rents do
desc "TODO"
task market_rents: :environment do
#watir code
require 'watir-webdriver'
Selenium::WebDriver::Firefox::Binary.path='C:\Program Files\Mozilla Firefox\firefox.exe'
browser = Watir::Browser.new :ff
#blah blah more code
browser.close
end
end
If I run the Watir code from the command prompt using $ ruby filename.rb, I have no problems. For some reason, when I try to run it via the Rake command I get the above error. I'm struggling to find what's happening given that I see the code work okay alone.
I've tried adding require 'rubygems' but that doesn't work.
If you are on Linux then run:
sudo apt-get install nodejs
On Mac:
brew install node
Related
I'm on Example 46 of Learn Ruby The Hard Way - Creating a Project Skeleton
Link: http://learnrubythehardway.org/book/ex46.html
So I created all the directories which show up as the following:
skeleton/
NAME.gemspec
Rakefile
data
ext/
tests/
bin/
NAME
doc/
lib/
NAME
NAME.rb
lib/NAME
tests/
test_NAME.rb
I'm in the Skeleton directory in Powershell.
When I run rake test as the tutorial says to I get an error.
Here's the result from Powershell:
PS C:\ruby\learn\projects\skeleton> rake test
C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe -I"lib;tests" -I"C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4
.2/lib" "C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "tests/test_NAME
.rb"
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:1:in `<top (required)>'
C:/ruby/learn/projects/skeleton/tests/test_NAME.rb:2:in `<top (required)>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:15:in `block in <main>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `select'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4: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>'
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:676:in `<class:Runner>': undefined method `_run_suite' for class
`Test::Unit::Runner' (NameError)
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:261:in `<module:Unit>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:15:in `<module:Test>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/test/unit.rb:7:in `<top (required)>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/ruby/learn/projects/skeleton/tests/test_NAME.rb:2:in `<top (required)>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:15:in `block
in <main>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `select'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [ruby -I"lib;tests" -I"C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/
lib" "C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "tests/test_NAME.rb
" ]
Tasks: TOP => test
(See full trace by running task with --trace)
The book says I should get the following response:
Loaded suite tests/test_NAME
Started
.
Finished in 0.000226 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
But instead I get an error. I've search for fixes and using gem install minitest but keep in mind I don't have a gemfile and I don't know if I should for this type of project. If I needed one I assume the tutorial would say so. So what do I do to fix this issue?
You don't need a Gemfile. While you are at skeleton directory, just do:
gem install 'test-unit'
and then from the same directory:
rake test
All tests will pass.
P.S. I just reproduced the whole thing locally following your tutorial and got the error message as yours. Then, I installed the test-unit gem and after that the rake test is working without any error.
I created a new model, but when I run the rake db: migrate command, it shoots me the following error:
rake aborted!
Gem::LoadError: You have already activated rake 10.4.0, but your Gemfile requires rake
10.3.2. Prepending `bundle exec` to your command may solve this.
/Users/yedidyaweiner/projects/music-app/config/boot.rb:4:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/config/application.rb:1:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/yedidyaweiner/projects/music-app/config/boot.rb:4:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/config/application.rb:1:in `<top (required)>'
/Users/yedidyaweiner/projects/music-app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
What am I doing wrong?
use
bundle exec rake db:migrate
You can also update your gems by running
bundle update
Execute the below commands
a) delete your Gemfile.lock file
b)bundle install
It should update Gemfile.lock with correct rake.
OR
a) gem uninstall rake -v 10.4.0
b) gem install rake -v 10.3.2
then try running 'rake db:migrate'. it should work.
I'm trying to debug rake task in rubymine. I created debug configuration for this task. Ruby SDK I chose project SDK. When I try to run this I got:
Gem::LoadError: You have already activated rake 10.2.2, but your Gemfile requires rake 10.1.1. Prepending `bundle exec` to your command may solve this.
/home/arkency/RubyProject/trainer/config/boot.rb:6:in `<top (required)>'
/home/arkency/RubyProject/trainer/config/application.rb:1:in `<top (required)>'
/home/arkency/RubyProject/trainer/Rakefile:5:in `<top (required)>'
/home/tomek/.gem/ruby/1.9.1/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide.rb:86:in `debug_load'
/home/tomek/.gem/ruby/1.9.1/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide.rb:86:in `debug_program'
/home/tomek/.gem/ruby/1.9.1/gems/ruby-debug-ide-0.4.22/bin/rdebug-ide:110:in `<top (required)>'
When I run task from terminal all works fine. I don't know from where rubymine takes this rake gem. How to check it? How to change to use the proper Gem? Thanks for all answers.
Click Run => Debug => Edit Configurations, select Bundler tab and check the Run the script in context of the bundle
I started getting this error and would like a way to fix it:
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
I am running this from within RubyMine. I can see in my Gemfile.lock where it specifies 10.1.0. Can I just manually update my Gemfile.lock to 10.1.1?
If I do:
$gem list
....
rake (10.1.1, 10.1.0, 10.0.4, 0.9.2.2)
So I'm not sure why it isn't just working with 10.1.0?
Here's the full output from RubyMine:
/Users/jt/.rvm/rubies/ruby-1.9.3-p448/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/jt/.rvm/gems/ruby-1.9.3-p448/bin/rake spec
Testing started at 3:15 PM ...
rake aborted!
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/Users/jt/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
/Users/jt/repos/app/config/boot.rb:6:in `<top (required)>'
/Users/jt/repos/app/config/application.rb:1:in `<top (required)>'
/Users/jt/repos/app/Rakefile:5:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
(See full trace by running task with --trace)
Process finished with exit code 1
You can remove your
Gemfile.lock file
and exec
bundle update
Hi I'm trying to use the ruby net/ssh gem (2.0.24) to connect to a remote server and run a rake task. I can run other simple tasks using the script outlined below, but rake is failing.
This is my code
Net::SSH.start("myremote_server", 'ubuntu', :keys => ['abcdef.pem'], :paranoid => false, :verbose => :debug) do |ssh|
result = ssh.exec!("cd a_rails_directory; rake sunspot:solr:start")
puts result
ssh.loop
end
and I get the following error message
rake aborted!
uninitialized constant Bundler
/home/ubuntu/a_rails_directory/config/boot.rb:9:in `rescue in <top (required)>'
/home/ubuntu/a_rails_directory/config/boot.rb:5:in `<top (required)>'
/home/ubuntu/a_rails_directory/config/application.rb:1:in `<top (required)>'
/home/ubuntu/a_rails_directory/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
I can run the rake taks quite easily when I ssh-into the remote server manually, but it doesn't work with net/ssh as I've outlined above.
Somehow, I feel like I'm not connecting with the proper shell or the proper access to the path variables, but I'm not sure and I don't know how to fix it either.
Any thoughts?
TIA
never mind. figured out how to load the relevant ruby path info
result = ssh.exec!("[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && source \"$HOME/.rvm/scripts/rvm\" ; cd rails_directory; rake sunspot:solr:start")