Ruby Koans not compatible with Ruby 2.0.0? - ruby

After successfully upgrading to Ruby 2.0.0's stable release (yay!) I decided to continue on my Koans Path to Enlightenment. However, when running the rake command within the koans folder, as I normally do, I receive this error:
rake
cd koans
/Users/jordanthornquest/.rvm/rubies/ruby-2.0.0-p0/bin/ruby path_to_enlightenment.rb
/Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:399:in `rescue in meditate': uninitialized constant EdgeCase::Sensei::AssertionError (NameError)
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:407:in `meditate'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:470:in `block in walk'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:481:in `block (3 levels) in each_step'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:479:in `each'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:479:in `block (2 levels) in each_step'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:478:in `each'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:478:in `each_with_index'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:478:in `block in each_step'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:476:in `catch'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:476:in `each_step'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:469:in `walk'
from /Users/jordanthornquest/programming/ruby-koans/koans/edgecase.rb:491:in `block in <top (required)>'
rake aborted!
Command failed with status (1): [/Users/jordanthornquest/.rvm/rubies/ruby-2...]
/Users/jordanthornquest/programming/ruby-koans/Rakefile:90:in `block in <top (required)>'
/Users/jordanthornquest/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
/Users/jordanthornquest/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => default => walk_the_path
I also installed a fresh new Koans batch from GitHub today, as well, to assure that that wasn't my problem. Neither worked for me! It still runs great with 1.9.3. It may be worth noting that I also installed Ruby 2.0 via RVM. I made sure to update to the latest RVM before doing so.
What seems to be the problem?

There is a pull request to fix this, but it has not been accepted yet: https://github.com/neo/ruby_koans/pull/84
For now, you can edit line 149 of src/edgecase.rb to be:
in_ruby_version("1.9", "2.0") do

Related

Unable to run rubocop with ruby version managed by RVM

I am using rvm to manage ruby version. I am using ruby 2.5.0. I have also installed the rubocop gem in ruby 2.5.0. I am getting below error while running rubocop.
I could see ruby version 2.5.0 when I run rvm list. Not sure where and how rubocop still looking for ruby 2.1.
Unknown Ruby version: 2.1
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:189:in `parser_class'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:197:in `create_parser'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:154:in `parse'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:36:in `initialize'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:17:in `new'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/processed_source.rb:17:in `from_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:349:in `get_processed_source'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:118:in `block in file_offenses'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:137:in `file_offense_cache'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:117:in `file_offenses'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:105:in `process_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:82:in `block in each_inspected_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:81:in `each'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:81:in `reduce'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:81:in `each_inspected_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:73:in `inspect_files'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/runner.rb:39:in `run'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/cli.rb:210:in `execute_runner'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/cli.rb:80:in `execute_runners'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/lib/rubocop/cli.rb:51:in `run'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/exe/rubocop:13:in `block in <top (required)>'
~/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.68.1/exe/rubocop:12:in `<top (required)>'
~/.rvm/gems/ruby-2.5.0/bin/rubocop:23:in `load'
~/.rvm/gems/ruby-2.5.0/bin/rubocop:23:in `<main>'
~/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:15:in `eval'
~/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:15:in `<main>'
Creating a ruboco.yml in the project root directory and adding the below line fixed the issue.
Ref
AllCops:
TargetRubyVersion: 2.5.0

How to fix undefined method 'data_store' for Resque:Module

I am developing a Rails 4.2 application, When I run command: "rake resque:scheduler" I got the error
[WARNING] Recurly logger has been disabled. If you wish to use it,
only do so in a non-production environment and make sure
the `RECURLY_INSECURE_DEBUG` environment variable is set to `true`.
The PGconn, PGresult, and PGError constants are deprecated, and will be
removed as of version 1.0.
You should use PG::Connection, PG::Result, and PG::Error instead, respectively.
Called from /Users/bacdo/.rvm/gems/ruby-2.4.3/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:238:in `block in load_dependency'
resque-scheduler: [INFO] 2019-04-26T16:18:58+07:00: Starting
rake aborted!
NoMethodError: undefined method `data_store' for Resque:Module
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler/locking.rb:100:in `redis_master_version'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler/locking.rb:62:in `supports_lua?'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler/locking.rb:86:in `build_master_lock'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler/locking.rb:58:in `master_lock'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler/locking.rb:66:in `master?'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler.rb:59:in `block in run'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler.rb:56:in `loop'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler.rb:56:in `run'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler/cli.rb:117:in `run_forever'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bundler/gems/resque-scheduler-30e40f897b52/lib/resque/scheduler/tasks.rb:18:in `block (2 levels) in <top (required)>'
/Users/bacdo/.rvm/gems/ruby-2.4.3/gems/bugsnag-5.4.1/lib/bugsnag/rake.rb:12:in `execute_with_bugsnag'
/Users/bacdo/.rvm/gems/ruby-2.4.3/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bin/ruby_executable_hooks:24:in `eval'
/Users/bacdo/.rvm/gems/ruby-2.4.3/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => resque:scheduler
(See full trace by running task with --trace)
Can you show me how to fix this issue?
Thank you very much.
I am in MacOS Mojave (10.14.4), ruby 2.4.3, Redis 4.0.14
update your version of resque: https://github.com/resque/resque-scheduler/pull/670

symlink() NotImplementedError rabl

Adding to gemfile failed and hence I tried gem install rabl. It fails with the following error message, looks like its OS specific... I'm on Windows 7 and using Ruby 2.2 on Rails 5 api
G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:388:in `symlink': symlink() function is unimplemented on this machine (NotImplementedError)
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:388:in `block (2 levels) in extract_tar_gz'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package/tar_reader.rb:65:in `each'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:365:in `block in extract_tar_gz'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:459:in `block in open_tar_gz'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:456:in `wrap'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:456:in `open_tar_gz'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:364:in `extract_tar_gz'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:345:in `block (2 levels) in extract_files'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package/tar_reader.rb:65:in `each'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:342:in `block in extract_files'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package/file_source.rb:30:in `open'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package/file_source.rb:30:in `with_read_io'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:339:in `extract_files'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/installer.rb:772:in `extract_files'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/installer.rb:302:in `install'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/resolver/specification.rb:97:in `install'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/request_set.rb:166:in `block in install'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/request_set.rb:156:in `each'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/request_set.rb:156:in `install'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/commands/install_command.rb:205:in `install_gem'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/commands/install_command.rb:255:in `block in install_gems'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/commands/install_command.rb:251:in `each'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/commands/install_command.rb:251:in `install_gems'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/commands/install_command.rb:158:in `execute'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/command.rb:310:in `invoke_with_build_args'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/command_manager.rb:169:in `process_args'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/command_manager.rb:139:in `run'
from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/gem_runner.rb:55:in `run'
from G:/Ruby/ruby/bin/gem:21:in `<main>'
Edit: After lots of googling, found this here
Attempting to use the deploy resource on Windows fails with:
symlink() function is unimplemented on this machine (NotImplementedError)
This is because Ruby's underlying File.symlink() method does not support Windows.
In the short-term this should be mentioned in the docs. Longer term I think this could be fixed in the same way that the "link" directive works. This method may not work for soft links due to limitations with NTFS.
So, it is definitely Windows specific, but wondering why there's no other post or link explaining that its incompatible with Windows. Isn't this fixable in Windows?
This is controversial, but some say symlinking has been implemented on Ruby 2.3. I would try installing it first.

"uninitialized constant Cucumber::Rb_Support (NameError)" when running Cucumber for Ruby & Watir

After installing Ruby, Cucumber and Watir using gem I get the following error:
uninitialized constant Cucumber::Rb_Support (NameError)
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:41:in `constantize_name'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:13:in `block in constantize'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:12:in `each'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/constantize.rb:12:in `constantize'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:87:in `load_programming_language'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:242:in `programming_language_for'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:226:in `load_file'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:97:in `block in load_files!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:96:in `each'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime/support_code.rb:96:in `load_files!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime.rb:242:in `load_step_definitions'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/runtime.rb:65:in `run!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/lib/cucumber/cli/main.rb:38:in `execute!'
W:/Programme/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-2.0.2/bin/cucumber:9:in `<top (required)>'
W:/Programme/Ruby193/bin/cucumber:23:in `load'
W:/Programme/Ruby193/bin/cucumber:23:in `<main>'**
Anyone got any idea why this is not working?
I copied the exact example from the github page.
I finally found a solution myself.
If anyone runs into this problem it is most likely caused by Ruby versions that are not compatible with Gherkin/Cucumber and/or Watir.
Although there are newer version of Ruby, the only versions that worked on my Windows 7 (Win64) machine were a combination of:
Ruby: rubyinstaller-2.0.0-p645.exe
DevKit: DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
Then I followed the installation instructions on http://www.spritecloud.com/2015/04/complete-setup-guide-for-ruby-cucumber-and-watir-on-windows/
And I used the example on https://github.com/spriteCloud/cucumber-watir-example which worked.
Following this did not create any errors and the example worked.
Good luck!

Jekyll - Error Running 'Jekyll Serve'

EDIT: Found the answer (see my answer below!). It involves using version 1.4.2 instead of 1.4.3, so if anyone has any ideas on getting 1.4.3 working, that could be helpful as well. Thanks!
EDIT 2: Thanks to a comment below, it seems that 1.4.3 does have a problem when running on windows. https://github.com/jekyll/jekyll/issues/1948
I have just setup jekyll on my windows 7 computer. I have ruby installed along with the dev pack.
I have run gem install jekyll and that completed with success. I have created a new site as per the jekyll documentation.
The problem I am experiencing happens when I try to run jekyll serve. Please find below the error output.
PS C:\jekyll\test-site> jekyll serve --trace
Configuration file: C:/jekyll/test-site/_config.yml
Source: C:/jekyll/test-site
Destination: C:/jekyll/test-site/_site
Generating... C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': Invalid argument - C:/jekyll/test-site/_site/C: (Errno::EINVAL)
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:205:in `each'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:205:in `mkdir_p'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/convertible.rb:168:in `write'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:259:in `block in write'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:397:in `block (2 levels) in each_site_file'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:396:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:396:in `block in each_site_file'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:395:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:395:in `each_site_file'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:259:in `write'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/site.rb:41:in `process'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/command.rb:18:in `process_site'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/commands/build.rb:23:in `build'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/lib/jekyll/commands/build.rb:7:in `process'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyll:97:in `block (2 levels) in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.1.5/lib/commander/command.rb:180:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.1.5/lib/commander/command.rb:180:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.1.5/lib/commander/command.rb:155:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.1.5/lib/commander/runner.rb:402:in `run_active_command'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.1.5/lib/commander/runner.rb:78:in `run!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.1.5/lib/commander/delegates.rb:11:in `run!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.1.5/lib/commander/import.rb:10:in `block in <top (required)>
I have looked around but am a novice with ruby, so I have no idea what to look for or how to find the error here. Any help would be much appriciated.
Thanks,
Joe
Answering my own question, I managed to find a solution.
This appears to be a problem with Jekyll version 1.4.3. To fix the issue I uninstalled jekyll and installed version 1.4.2.
gem uninstall jekyll
gem install jekyll --version "=1.4.2"
Doing this and everything should work fine if you have the same issue as me on windows.
I guess this is because version 1.4.3 is new (released on 13th) and is unstable on windows.
Just came across the same issue with Jekyll's plugin "Category Archive Generator" (https://github.com/shigeya/jekyll-category-archive-plugin)
Most likely you have a plugin - in the _plugins folder - which is using the File.join() method. e.g. File.join('/', dest, #dir, #category_dir_name, 'index.html')
Modify this by deleting the first element leaving you with File.join(dest, #dir, #category_dir_name, 'index.html')
I had the same problem on Ubuntu Precise 12.04. The issue was that I had ruby1.8 installed. I also had ruby1.9.1 installed. I removed ruby1.8, and then Jekyll installed fine.

Resources