cannot load such file -- 'nokogiri\nokogiri' ruby 2.7 - ruby

I'm running AWS Lambda locally.
When I run the lambda function this is the error I get:
{
"errorMessage": "cannot load such file -- nokogiri/nokogiri",
"errorType": "Init<LoadError>",
"stackTrace": [
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/task/vendor/ruby/2.7.0/gems/nokogiri-1.11.0.rc2/lib/nokogiri.rb:15:in `rescue in <top (required)>'",
"/var/task/vendor/ruby/2.7.0/gems/nokogiri-1.11.0.rc2/lib/nokogiri.rb:11:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/task/vendor/ruby/2.7.0/gems/google_drive-3.0.5/lib/google_drive/session.rb:8:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/task/vendor/ruby/2.7.0/gems/google_drive-3.0.5/lib/google_drive.rb:7:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/task/main.rb:7:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'"
]
}
I looked into /var/task/vendor/ruby/2.7.0/gems/nokogiri-1.11.0.rc2/lib/nokogiri.rb:15and this is the code that makes everything blow up: `require 'nokogiri/nokogiri'
These are the files in `./vendor/ruby/2.7.0/gems/nokogiri-1.11.0.rc2/lib':
nokogiri
nokogiri.rb
xsd
And these are the files in ./vendor/ruby/2.7.0/gems/nokogiri-1.11.0.rc2/lib/nokogiri/:
css
decorators
html.rb
nokogiri.bundle
version.rb
xml.rb
xslt.rb
css.rb
html
jruby
syntax_error.rb
xml
xslt
There is no file nokogiri/nokogiri hence I suppose the error. I tried to copy nokogiri.rb into directory nokogiri nut other errors pop up.
How can I move forward?
Thanks!

I was facing the same exact problem until I read this article https://www.stevenringo.com/ruby-in-aws-lambda-with-postgresql-nokogiri/ .
To summarize, the problem is when using an AWS Lambda, there is no way to execute a command on the environment/Lambda. So while you can use bundle install locally, you CANNOT use it when on the Lambda. That being said and as the article mentions, we need to find a way to package and compile dependencies ahead of time in an environment that is compatible with the Lambda environment.
This leads us to an alternate solution of compiling our dependencies from the docker container to match the lambda environment. In order to fix the problem, you need to do the following:
Install docker on your local machine
Create a Dockerfile in your ruby project with the following lines:
FROM lambci/lambda:build-ruby2.7
CMD "/bin/bash"
Build your docker image with the following command: docker build -t lambda-ruby2.7 . (Don't forget the period at the end!)
Enter the shell inside the container with the following command:
docker run --rm -it -v $PWD:/var/task -w /var/task lambda-ruby2.7
From the shell/container, run bundle install --path vendor/bundle --clean
Exit the shell
Inside the project, zip it: zip -q -r deploy.zip .
This solution worked for me. Hopefully it can be an alternative until someone figures how to do this without using Docker.

Related

How can I make AWS lambda find the grpc dependency in my function?

GRPC is giving me fits here:
{
"errorMessage": "Could not find 'grpc' (~> 1.24) among 281 total gem(s)\nChecked in 'GEM_PATH=/var/task/vendor/bundle/ruby/2.5.0:/opt/ruby/gems/2.5.0:/var/runtime', execute `gem env` for more information",
"errorType": "Init<Gem::MissingSpecError>",
"stackTrace": [
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/dependency.rb:311:in `to_specs'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1402:in `block in activate_dependencies'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1391:in `each'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1391:in `activate_dependencies'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1373:in `activate'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems.rb:215:in `rescue in try_activate'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems.rb:208:in `try_activate'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:161:in `rescue in require'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:35:in `require'",
"/var/task/vendor/bundle/ruby/2.5.0/gems/google-cloud-dialogflow-0.14.0/lib/google/cloud/dialogflow.rb:16:in `<top (required)>'",
"/var/task/google_dialog.rb:3:in `require_relative'",
"/var/task/google_dialog.rb:3:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:168:in `require'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:168:in `rescue in require'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:35:in `require'"
]
}
I see it at vendor/bundle/ruby/2.5.0/gems/grpc-1.27.0-universal-darwin/src/ruby/lib/grpc.rb
I'm writing a simple Ruby class to hook into Dialogflow, and the google gem is fairly heavy with a lot of dependencies. I've written some tests that all pass locally and in the context of the Rails application from where I'm extracting this bit of code. I'll need Nokogiri, but it appears that Google is the big user of the GRPC stuff. And it just won't find that file when when I specify is manually. Any help is greatly appreciated.
In the case of the above issue - order of operations are everything I learned. Ruby is parsing top-down instead of loading everything then parsing, which I suppose I should have known, but Rails does a lot of magical things for you.
So when I was seeing the issue above, I had the following require statements at the top of my file:
require_relative 'vendor/bundle/ruby/2.5.0/gems/nokogiri-1.10.9/lib/nokogiri.rb'
require_relative 'vendor/bundle/ruby/2.5.0/gems/google-cloud-dialogflow-0.14.0/lib/google/cloud/dialogflow.rb'
require_relative 'vendor/bundle/ruby/2.5.0/gems/google-cloud-dialogflow-0.14.0/lib/google/cloud/dialogflow/v2.rb'
require_relative 'vendor/bundle/ruby/2.5.0/gems/grpc-1.24.0-universal-darwin/src/ruby/lib/grpc.rb'
And due to the require for grpc coming after the google cloud ruby
require_relative 'vendor/bundle/ruby/2.5.0/gems/grpc-1.24.0-universal-darwin/src/ruby/lib/grpc.rb'
require_relative 'vendor/bundle/ruby/2.5.0/gems/nokogiri-1.10.9/lib/nokogiri.rb'
require_relative 'vendor/bundle/ruby/2.5.0/gems/google-cloud-dialogflow-0.14.0/lib/google/cloud/dialogflow.rb'
require_relative 'vendor/bundle/ruby/2.5.0/gems/google-cloud-dialogflow-0.14.0/lib/google/cloud/dialogflow/v2.rb'
Simply putting grpc before dialogflow resolved that issue.
Lesson - always go back to basics.

Cannot run test execution using watir/taza/rspec

I'm using Unix system and trying to run Watir/Taza/RSpec test execution.
I just perform commands for creating taza structure, site, homepage and flow:
> taza create structure
> taza site google
> taza page home google
> taza flow search google
Then I run test using next command:
rake spec:isolation:google
but I get an error:
rake aborted! LoadError: cannot load such file -- taza/tasks
/Users/ismotrov/works/test/Rakefile:3:in require' /Users/ismotrov/works/test/Rakefile:3:in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in
load' /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:689:in
raw_load_rakefile' /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:94:in block in load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in
standard_exception_handling' /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:93:in load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:77:in
block in run' /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:75:in
run' /Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/bin/rake:33:in <top
(required)>' /usr/bin/rake:23:in load' /usr/bin/rake:23:in '
Who knows what to do?
And another moment I would like to dicuss - in file config/config.yml I have the following:
---
browser: firefox
driver: watir_webdriver
But on my Mac I don't have Firefox installed. How can I use this with, for example, Chrome and can it cause my problem?
1) Try this command:
rake spec:isolation
This worked for me.
2) Watir supports Chrome browser too. So just replace 'firefox' with 'chrome' and try to run your tests.

Using `require 'classname'` causes "No such file to load -- Classname" error on Heroku

TLDR: Using require 'classname' in another model file (so I can deserialize a column) works locally but results in the No such file to load -- Classname error when deploying to Heroku.
I've made the admittedly poor design decision to serialize a model attribute which contains an array of another model's objects (UserCategoryQueue has a serialized queue of Card objects). In order to actually de-serialize these objects, I've followed the advice in YAML::load raises undefined class/module error to use require 'Card' in the files where I need to deserialize that column. That avoids the issue where YAML doesn't know what it's looking at when it gets to the Card object.
This works fine on the localhost server but has resulted in a lot of issues when deploying to Heroku, all of the form No such file to load -- Card". Initially, this occurred during the asset precompilation phase, then I precompiled the assets myself and the same error has moved to when I try to run $ heroku run rake db:migrate to get everything set up for the first time.
Sample Files:
# app/models/user_category_queue.rb
class UserCategoryQueue < ActiveRecord::Base
...
# Our queue of Cards
serialize :queue, Array
end
# app/models/quiz.rb
class Quiz < ActiveRecord::Base
...
require 'Card'
...
# grab a random card from the user's queues
# produces YAML error without the above require statement
def sample_card
self.user.user_category_queues.sample.queue.sample
end
end
This ultimately resulted in the following errors on pushing to Heroku (prior to any asset precompilation attempts on my part):
Running: rake assets:precompile
rake aborted!
No such file to load -- Card
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/app/models/quiz.rb:18:in `<class:Quiz>'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/app/models/quiz.rb:1:in `<top (required)>'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:329:in `require_or_load'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:288:in `depend_on'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:206:in `require_dependency'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/config/environment.rb:5:in `<top (required)>'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
/tmp/build_d0e6e2b8-a3fd-4a90-ae44-e703b0093401/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
As I said, even when precompiling assets, though the push went fine, the ensuing database migration had the same error pop up.
Heroku runs a case-sensitive filesystem, whereas your OS may not be case-sensitive. Try changing that require to this instead:
require 'card'
As a general rule of thumb, most files within Ruby are required using lowercase letters with underscores serving as a word separator, like this:
require 'card_shuffler'

How to run shell commands on server in Capistrano v3?

I'm new to Capistrano and I've tried using Capistrano's DSL to run shell commands on the server ('run', 'execute', etc.), but it appears that it was deprecated. After searching and searching for a functional equivalent, I still am lost.
Current code:
desc 'Do something'
task :do_something
execute 'echo sometext'
end
Output:
cap aborted!
undefined method `execute' for main:Object
/Users/Justin/Dropbox/xxxx/xxxx/xxxx/Capfile:45:in `block (2 levels) in <top (required)>'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bundler/gems/capistrano-2dc1627838f9/lib/capistrano/application.rb:12:in `run'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bundler/gems/capistrano-2dc1627838f9/bin/cap:3:in `<top (required)>'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bin/cap:23:in `load'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bin/cap:23:in `<main>'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => deploy:do_something
In Capistrano v3, you must specify where you want to run the code by calling on with a list of hostnames, e.g.
task :execute_on_server do
on "root#example.com" do
execute "some_command"
end
end
If you have roles set up, you can use the roles method as a convenience:
role :mailserver, "root#mail.example.com"
task :check_mail do
on roles(:mailserver) do
execute "some_command"
end
end
There is some v3 documentation here: http://www.capistranorb.com/

Cucumber Aruba trying to change directory results in a strange error

So I create the dotfiles directory and then cd to dotfiles. However, cucumber aruba is giving me an error that says dotfiles is not a directory. I can't figure out why this is? the code in pry results in the correct behavior.
#creation
Scenario: Create a dotfiles git repository
Given the directory dotfiles does not exist in the home directory
When I successfully run `dotfiles init dotfile_one dotfile_two dotfile_three`
Then a dotfiles directory should exist in the home directory
When I change directory to the dotfiles directory ### Fails here ###
Then a file named ".git" should exist
my steps
Given /^the directory dotfiles does not exist in the home directory$/ do
step %(a directory named "#{ENV['HOME']}/dotfiles" should not exist)
end
Then /^a dotfiles directory should exist in the home directory$/ do
step %(a directory named "#{ENV['HOME']}/dotfiles" should exist)
end
When /^I change directory to the dotfiles directory$/ do
step %(I cd to "#{ENV['HOME']}/dotfiles")
end
before hook:
Before('#creation') do
FileUtils.rm_rf(File.join(ENV['HOME'], 'dotfiles'))
end
the source
module Dotfiles
class Repository
def self.init(location, dotfiles)
# create the dotfiles directory and git init
FileUtils.chdir(location) do
FileUtils.mkdir_p(File.join location, 'dotfiles')
end
FileUtils.chdir(File.join location, 'dotfiles')
end
end
end
Short version of error
When I change directory to the dotfiles directory # features/step_definitions/aruba_steps.rb:13
tmp/aruba/Users/Brian/dotfiles is not a directory. (RuntimeError)
Here is the error with full trace
#creation
Scenario: Create a dotfiles git repository # features/dotfiles_repository.feature:6
Given the directory dotfiles does not exist in the home directory # features/step_definitions/aruba_steps.rb:5
When I successfully run `dotfiles init dotfile_one dotfile_two dotfile_three` # aruba-0.5.3/lib/aruba/cucumber.rb:71
Then a dotfiles directory should exist in the home directory # features/step_definitions/aruba_steps.rb:9
When I change directory to the dotfiles directory # features/step_definitions/aruba_steps.rb:13
tmp/aruba/Users/Brian/dotfiles is not a directory. (RuntimeError)
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/aruba-0.5.3/lib/aruba/api.rb:22:in `cd'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/aruba-0.5.3/lib/aruba/cucumber.rb:52:in `block in <top (required)>'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/core_ext/instance_exec.rb:48:in `instance_exec'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/core_ext/instance_exec.rb:48:in `block in cucumber_instance_exec'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/core_ext/instance_exec.rb:69:in `cucumber_run_with_backtrace_filtering'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/core_ext/instance_exec.rb:36:in `cucumber_instance_exec'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/rb_support/rb_step_definition.rb:97:in `invoke'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/step_match.rb:25:in `invoke'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:60:in `invoke'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/rb_support/rb_world.rb:52:in `step'
/Users/Brian/gems/dotfiles/features/step_definitions/aruba_steps.rb:14:in `block in <top (required)>'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/core_ext/instance_exec.rb:48:in `instance_exec'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/core_ext/instance_exec.rb:48:in `block in cucumber_instance_exec'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/core_ext/instance_exec.rb:69:in `cucumber_run_with_backtrace_filtering'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/core_ext/instance_exec.rb:36:in `cucumber_instance_exec'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/rb_support/rb_step_definition.rb:97:in `invoke'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/step_match.rb:25:in `invoke'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_invocation.rb:60:in `invoke'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_invocation.rb:38:in `accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:106:in `block in visit_step'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:105:in `visit_step'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_collection.rb:19:in `block in accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_collection.rb:18:in `each'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/step_collection.rb:18:in `accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:100:in `block in visit_steps'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:99:in `visit_steps'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:15:in `block in execute'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:82:in `block (2 levels) in with_hooks'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:98:in `before_and_after'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:81:in `block in with_hooks'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:120:in `call'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:120:in `block (3 levels) in around'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/language_support/language_methods.rb:9:in `block in around'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/language_support/language_methods.rb:97:in `call'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/language_support/language_methods.rb:97:in `execute_around'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/language_support/language_methods.rb:8:in `around'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:119:in `block (2 levels) in around'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:123:in `call'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:123:in `around'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:93:in `around'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:80:in `with_hooks'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:13:in `execute'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/scenario.rb:32:in `block in accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/scenario.rb:79:in `with_visitor'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/scenario.rb:31:in `accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:58:in `block in visit_feature_element'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:57:in `visit_feature_element'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/feature.rb:38:in `block in accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/feature.rb:37:in `each'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/feature.rb:37:in `accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:27:in `block in visit_feature'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:26:in `visit_feature'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/features.rb:28:in `block in accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/features.rb:17:in `each'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/features.rb:17:in `each'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/features.rb:27:in `accept'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:21:in `block in visit_features'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:170:in `broadcast'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/ast/tree_walker.rb:20:in `visit_features'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:48:in `run!'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/lib/cucumber/cli/main.rb:47:in `execute!'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/gems/cucumber-1.3.4/bin/cucumber:13:in `<top (required)>'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/bin/cucumber:23:in `load'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/bin/cucumber:23:in `<main>'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
/Users/Brian/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
features/dotfiles_repository.feature:10:in `When I change directory to the dotfiles directory'
Then a file named ".git" should exist # aruba-0.5.3/lib/aruba/cucumber.rb:264
Failing Scenarios:
cucumber features/dotfiles_repository.feature:6 # Scenario: Create a dotfiles git repository
1 scenario (1 failed)
5 steps (1 failed, 1 skipped, 3 passed)
0m0.631s
Anyone have any solutions or suggestions? Don't hesitate to ask if you have a question.
Thanks in advance
I see a couple things that I would do differently. There's no guarantee that this will make a difference, but it might.
dotfiles is never used in your code. 'dotfiles' is, so why do you require it as a parameter?
def self.init(location, dotfiles)
Ruby can interpret these lines two ways:
FileUtils.mkdir_p(File.join location, 'dotfiles')
FileUtils.chdir(File.join location, 'dotfiles')
Notice the difference in parenthesis to force parameter assignment in these lines:
FileUtils.mkdir_p(File.join(location), 'dotfiles')
FileUtils.mkdir_p(File.join(location, 'dotfiles'))
FileUtils.chdir(File.join(location), 'dotfiles')
FileUtils.chdir(File.join(location, 'dotfiles'))
Instead of writing your code like:
def self.init(location, dotfiles)
# create the dotfiles directory and git init
FileUtils.chdir(location) do
FileUtils.mkdir_p(File.join location, 'dotfiles')
end
FileUtils.chdir(File.join location, 'dotfiles')
end
I'd write it like this instead:
def self.init(location)
# create the dotfiles directory and git init
FileUtils.chdir(location) do
FileUtils.mkdir('dotfiles')
end
FileUtils.chdir('dotfiles')
end
Although Ruby allows us to not use parenthesis to surround parameters to a method, that is the source of untold many questions asked on Stack Overflow because code won't work. Parenthesis are important to the interpreter, to explicitely tell it what we really mean. When you don't use them, it will follow its normal order of operations and use rules of precendence to try to figure out what section of a line should be processed first, and without the parenthesis to force order of operation, it can make mistakes.
Our choice, at that point, is to either move the operation ahead of where we're going to use its result, or use parenthesis to make it clear what should happen when.
I just ran with a similiar problem. After a long time of investigation this line caught my attention:
tmp/aruba/Users/Brian/dotfiles is not a directory. (RuntimeError)
See how it begins with 'tmp/aruba'? Needless to say, my problem also had this 'tmp/aruba/' on it. If you look at the readme at github closely enough you will find out that aruba has a "working directory where it performs its file operations".
When I followed the instructions there I got it working alright!

Resources