Trouble with Guard init command - ruby-on-rails-3

I'm trying to setup Guard using this tutorial, however when I run bundle exec guard init or bundle exec guard init rspec
I'm on OSX, running RVM 1.14.1 and Rails 3.2.5.
I get the following errors:
[myapplication]$ bundle exec guard init rspec
/Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/guard-1.1.0/lib/guard/cli.rb:145:in `init': undefined method `create_guardfile' for Guard:Module (NoMethodError)
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/thor-0.15.2/lib/thor/task.rb:27:in `run'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/thor-0.15.2/lib/thor/invocation.rb:120:in `invoke_task'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/thor-0.15.2/lib/thor.rb:275:in `dispatch'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/thor-0.15.2/lib/thor/base.rb:408:in `start'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/guard-1.1.0/bin/guard:6:in `<top (required)>'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/bin/guard:19:in `load'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/bin/guard:19:in `<main>'
RSpec runs fine:
[myapplication]$ bundle exec rspec
F
Failures:
1) StaticPages GET /static_pages works! (now write some real specs)
Failure/Error: get static_pages_index_path
NameError:
undefined local variable or method `static_pages_index_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fd6d176a020>
# ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 0.00887 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:5 # StaticPages GET /static_pages works! (now write some real specs)
Also my gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.5'
group :development, :test do
gem 'rspec-rails'
gem 'guard-rspec'
gem 'growl'
gem 'rb-fsevent'
gem 'spork-rails'
gem 'guard-spork'
end
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'

I just had the same problem in Ubuntu Server 11.10. In my case there was some problem with the versions of the gems. I changed the guard gem version in the Gemfile from 1.1.0 to 0.10.0 and it worked. Here is my Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'pg', '0.12.2'
group :development, :test do
#gem 'sqlite3', '1.3.5'
gem 'pg', '0.12.2'
gem 'guard','0.10.0'
gem 'rspec-rails', '2.9.0'
gem 'guard-rspec', '0.5.5'
gem 'guard-bundler'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'capybara', '1.1.2'
gem 'rb-inotify', '0.8.8'
gem 'libnotify', '0.5.9'
end
group :production do
gem 'pg', '0.12.2'
end

I've reported this issue and it has been fixed:
https://github.com/guard/guard/issues/283#issuecomment-6078721

Related

undefined method translate during Rails 2.3 -> 3.2 upgrade

Working on upgrading a Rails 2.3.17 app to Rails 3.2.22.2 (running ruby 1.9.3-p551). Was able to get through the painful portion of ugprading all the gems / updating the directory structure / adding in all new/updated rails files.
The rails server is now coming up, but when i try to load up the first page, it fails with this stack trace:
NoMethodError: undefined method `translate' for # <I18n::Backend::ActiveRecord:0x007ff64dc72400>
/myapp/vendor/bundle/ruby/1.9.1/gems/i18n-0.7.0/lib/i18n/backend/chain.rb:46:in `block (2 levels) in translate'
/myapp/vendor/bundle/ruby/1.9.1/gems/i18n-0.7.0/lib/i18n/backend/chain.rb:44:in `catch'
/myapp/vendor/bundle/ruby/1.9.1/gems/i18n-0.7.0/lib/i18n/backend/chain.rb:44:in `block in translate'
/myapp/vendor/bundle/ruby/1.9.1/gems/i18n-0.7.0/lib/i18n/backend/chain.rb:43:in `each'
...
Additional notes: I have an locale.rb file in the config/initializers/ folder, which has this:
require "i18n/backend/cache"
I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize)
I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Flatten)
I18n::Backend::Simple.send(:include, I18n::Backend::Memoize)
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
I18n::Backend::Chain.send(:include, I18n::Backend::Cache)
I18n.backend = I18n::Backend::ActiveRecord.new
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
My Gemfile looks like:
source "http://rubygems.org"
gem "rails", "3.2.22.2"
gem "rake", "11.1.0"
gem "a9n", "0.3.0"
gem "geoip-c"
gem "josevalim-auth_helpers"
gem "delayed_job", "~>3.0.5"
gem "mysql2"
gem "activemerchant", "1.43.3"
gem "liquid"
gem "paperclip"
gem "mechanize", "2.7.4"
gem "net-ssh", "~>2.9.4"
gem "net-sftp", "2.0.5"
gem "authlogic", :git => "git://github.com/binarylogic/authlogic.git"
gem "rd_searchlogic"
gem "rack", "~>1.4.5"
gem "activerecord-mysql2-adapter"
gem "declarative_authorization"
gem "inherited_resources"
gem "acts_as_audited"
gem "rails-indexes"
gem "geocoder"
gem "has_magic_columns"
gem "grimen-delayed_job_mailer"
gem "asset_packager"
gem "recaptcha", "0.4.0"
gem "libxml-ruby"
gem "xml-simple"
gem "haml"
gem "airbrake", "~>4.3.7"
gem "sinatra"
gem "newrelic_rpm"
gem "will_paginate"
gem "rexml-expansion-fix"
gem "hominid"
gem "money"
gem "aasm", "~>3.4.0"
gem "dalli"
gem "acts-as-taggable-on"
gem "i18n"
gem "i18n-active_record", :require => "i18n/active_record"
gem "hpricot"
gem "rest-client"
gem "nokogiri", "~>1.6.8"
gem "exact-target"
gem "pdfkit"
gem "json"
gem "savon"
gem "twilio-ruby"
gem "oj"
gem "httparty"
gem "rforce"
gem "ruby-ntlm"
gem "ffaker"
gem "simple_qs"
gem "time_difference"
gem "aws-sdk-v1"
gem "wkhtmltopdf-binary"
gem "gyoku"
gem "mime-types"
gem "highline"
gem "exifr"
gem "encryptor","~>1.3.0"
gem "docile"
gem "american_date"
gem "gon", "~>4.0.0"
gem "rmagick", "~> 2.0" # for ruby 1.x, since 2.0 it could be removed
group :staging do
gem "ruby-prof"
end
gem "capistrano", "~> 2.15"
gem "capistrano_deploy_lock"
gem "hipchat"
end
group :spreadsheet do
gem "spreadsheet"
end
group :gpg do
gem "gpgme"
end
group :mail do
gem "mail"
gem "bounce_email"
end
group :development, :staging do
gem "pry"
gem "pry-remote"
end
group :development, :test do
gem "rspec-rails", "~> 3.0.0"
gem "rspec", "~> 3.0.0"
gem "rspec-core", "~> 3.0.0"
gem "rspec-expectations", "~> 3.0.0"
gem "fabrication"
end
group :test do
gem "bourne", "~> 1.2.1", :require => false
gem "database_cleaner", "0.9.1"
gem "mocha", "0.12.7", :require => false
gem "rack-test"
gem "simplecov"
gem "timecop"
gem "test-unit", "~>3.0"
gem "shoulda-matchers", "1.0.0", :require => false
end
any ideas why it might be generating that error message ?

rake aborted cannot load such file --v8 windows

please help, this is my gemfile. It's an old project i created on ubuntu 12.04, now i'm trying to run it on windows 8.
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'devise', '2.2.4'
gem 'execjs', :git => 'git://github.com/kennyj/execjs.git', :branch => 'rails_issue_2880'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
#gem 'therubyracer', :platforms => :ruby
gem 'twitter-bootstrap-rails'
gem 'less-rails'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
The command prompt:
C:\Users\manu\Documents\projets\rails\xibart>rake db:migrate
[WARNING] Please install gem 'therubyracer' to use Less.
rake aborted!
cannot load such file -- v8
C:/Users/manu/Documents/projets/rails/xibart/config/application.rb:7:in `<top (r
equired)>'
C:/Users/manu/Documents/projets/rails/xibart/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
Uncomment the ruby racer line to install it:
gem 'therubyracer', :platforms => :ruby

Could not update rails

When I do bundle update rails, I get this error:
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
rails (= 3.2.11) x86-mingw32 depends on
activesupport (= 3.2.11) x86-mingw32
activesupport (3.1.0)
here is my gemFile, any help is apprecaited :)
source 'http://rubygems.org'
gem 'rails' , '3.2.11'
gem "heroku"
gem 'thin'
gem 'devise'#, '1.5.2'
gem 'will_paginate', '~> 3.0.2'
#gem 'nested_form', :git => 'git://github.com/fxposter/nested_form.git'
gem "simple_form"
gem "cancan"
gem 'kaminari'
gem 'foreigner'
gem "cocoon"
gem 'client_side_validations'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem "jquery-rails"
gem "validate_url", "~> 0.2.0"
gem 'pg', :group => [:production]
gem 'haml'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test, :development do
gem 'sqlite3'
gem 'turn', :require => false
gem "rspec-rails", "2.7"
#gem "rspec"
gem "spork", "> 0.9.0.rc"
gem 'guard-spork'
#gem "webrat", "~> 0.7.3"
gem 'rb-fsevent' # Not mandatory for guard to work, which is why it's not a dependency, but it is an optimization
#gem "guard-spork"
#gem 'minitest'
gem "factory_girl_rails", "~> 1.2"
#gem "webrat-rspec-rails"
gem "mocha"
gem 'capybara' #, :git => 'git://github.com/jnicklas/capybara.git'
gem 'database_cleaner'
gem 'launchy'
gem "capybara-webkit"
#gem 'rspec-multi-mock', :git => 'git://github.com/endeepak/rspec-multi-mock.git'
end
group :test do
#gem 'ruby-debug19', :require => 'ruby-debug'
end
gem 'execjs'
gem 'therubyracer'
First of all you have to delete Gemfile.lock
then update Gemfile to include rails 3.2.11
go to project directory
run bundle install
This may solve your problem

Rails 3 + Heroku: cannot load such file -- test/unit/testcase (LoadError)

I'm having the following error when running the console in heroku (heroku run console...). The application is running without problems, but I seem to be unable to run the console because of this and in development I'm not having this issue.
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- test/unit/testcase (LoadError)
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/test_case.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/console/app.rb:2:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:304:in `initialize_console'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:152:in `load_console'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:27:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
This is my Gemfile:
source 'http://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.9'
gem 'oauth', '~> 0.4.4'
gem 'twitter', '~> 1.4.1'
gem 'sendgrid'
gem 'koala'
gem 'therubyracer', '0.10.2'
gem 'execjs'
# Rails 3.1 - Asset Pipeline
gem 'json'
group :assets do
gem 'sass-rails', " >= 3.2.3"
gem 'coffee-rails', ">= 3.2.1"
gem 'uglifier', '>= 1.0.3'
gem 'bootstrap-sass'
end
gem 'coffee-script'
gem 'jquery-rails'
gem "fog"
gem 'bootstrap-wysihtml5-rails', '0.3.1.10'
group :production do
gem "heroku"
gem 'pg', '0.13'
gem 'newrelic_rpm'
gem 'newrelic_api'
end
group :test do
gem 'email_spec'
gem "cucumber-rails"
gem "rspec-rails"
gem "capybara"
gem 'culerity'
gem "selenium-webdriver"
gem "database_cleaner"
gem 'factory_girl_rails'
end
group :development, :grades, :test do
gem "launchy"
gem "mysql2"
gem "letter_opener"
gem "pry"
gem "rails-erd"
end
gem "airbrake"
gem "authlogic"
gem 'awesome_print'
gem 'cancan'
gem 'dalli'
#gem "oink"
gem 'validates_timeliness', '~> 3.0.2'
gem 'hpricot'
gem "ruby_parser"
gem "prawn_rails"
gem "thin"
gem "nested_form", :git => "git://github.com/ryanb/nested_form.git"
gem "meta_search"
gem "carrierwave"
gem "aws-s3"
gem "mini_magick"
gem 'will_paginate'
gem "spreadsheet"
gem "oauth-plugin", ">= 0.4.0.pre1"
gem 'flash_cookie_session'
gem 'haml-rails'
gem 'squeel'
gem 'rails_best_practices', :group => :development
gem 'simple_form'
gem 'taps', :group => :development
gem 'resque'
gem "audited-activerecord", "~> 3.0"
gem "lograge"
gem 'quiet_assets'
gem 'yajl-ruby', :require => "yajl"
gem 'switch_user'
I've got no idea why I'm getting this error. Any thoughts? Thanks
With Rails 3.1.12 and Ruby 2.2.0 I had to add
gem 'test-unit'
to my Gemfile.
Removing test in the .slugignore file works for me.
Apparently Heroku has changed the way it interprets the .slugignore file.
In my case, I had rpc directory in .slugignore and it wiped out rpc subdirectory of one of the gems my app is depending on, which resulted in LoadError. I'm unsure Heroku made this change intentionally. Regardless of whether .slugignore is working as they expect, removing affecting line(s) from .slugignore should fix the issue for now.
P.S. I've raised a support ticket to Heroku on this.
UPDATE: As per Heroku support, there were some changes to .slugignore parsing to make it more consistent with .gitignore, and it is working as intended. The right way to only delete the top level directory is putting /rpc instead.
Removing test dir from .slugignore fixed the issue
Remove test dir from .slugignore
We also ran into this issue today. I suspect something must have changed in Heroku's Ruby build pack.
For us it was a problem with prototype-rails trying to load ActionView::TestCase which in turn requires test/unit/testcase. The patch is pretty simple and is available as a fork.
If you're using Bundler, you might want something like:
gem 'prototype-rails', :git => 'git://github.com/ennova/prototype-rails.git'
I tried disabling multithreading (comment out config.threadsafe!) and that seems to work for now until heroku gets their act together.

Rails 3.1.1 Guard-rspec cannot run due to Growl errors: OSERROR: -10000 MESSAGE: Apple event handler failed

I have been running Guard for RSPEC and using the growl_notify gem for a while now (2-3 months), but now I cannot get guard to run in any of my Rails 3.1.1 projects. I've done some research on the error itself, but couldn't come up with anything conclusive (except someone else has the same issue).
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'spreadsheet' # Allows for reading/writing Excel files. We also need a CSV importer, but that can come later
gem 'gmaps4rails' # Allows for Google Maps Pushpins/Markers/Places
gem 'scoped_search' # For Searching
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git" # For File Uploads
group :test, :development do
gem 'sqlite3'
gem 'turn', '<0.8.3'
gem 'rspec-rails'
gem 'capybara'
gem 'guard-rspec'
gem 'growl_notify'
gem 'launchy'
gem 'capistrano' #You don't want Capistrano on the production side (I think)
end
group :production do
gem 'pg' #use postgres for database installation as the database
end
Error:
Thomas#Thomas-Cannons-MacBook-Pro:~/development/rails/tasks$ guard
/Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/rb-appscript-0.6.1/lib/appscript.rb:542:in `_send_command': CommandError (Appscript::CommandError)
OSERROR: -10000
MESSAGE: Apple event handler failed.
COMMAND: app("/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app").register({:all_notifications=>["success", "pending", "failed", "notify"], :as_application=>"Guard", :default_notifications=>"notify"})
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/rb-appscript-0.6.1/lib/appscript.rb:642:in `method_missing'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/growl_notify-0.0.3/lib/growl_notify.rb:29:in `register'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/growl_notify-0.0.3/lib/growl_notify.rb:19:in `config'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifiers/growl_notify.rb:42:in `available?'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard- 0.9.4/lib/guard/notifier.rb:117:in `add_notification'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifier.rb:154:in `block in auto_detect_notification'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifier.rb:154:in `each'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifier.rb:154:in `any?'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifier.rb:154:in `auto_detect_notification'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard- 0.9.4/lib/guard/notifier.rb:80:in `turn_on'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard.rb:184:in `start'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/cli.rb:74:in `start'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/thor- 0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/thor- 0.14.6/lib/thor.rb:263:in `dispatch'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/bin/guard:6:in `<top (required)>'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/bin/guard:19:in `load'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/bin/guard:19:in `<main>'
Here's what worked for me. Two things:
First, Guard 0.10.x. requires Growl >= 1.3. Install Growl 1.3 from the App Store (thew reviews are really bad, but I had no trouble).
Second, the new Guard versions recommend ruby_gntp. Simply replace gem 'growl_notify' with gem 'ruby_gntp'.
This appears to be a version mismatch between Growl and growl_notify. growl_notify 0.0.3 changed the Growl application name, which near as I can tell changed with Growl 1.3 (Lion only)
I believe it works out to:
use growl_notify 0.0.2 for Growl < 1.3
use growl_notify 0.0.3 for Growl >= 1.3
use growl gem (what I did)