0
votes

When setting up guard-coffeescript for a project, I can't seem to get guard to init the Guardfile. It appears to be missing some files. This is a fresh ruby install, and I haven't consciously deleted any of the mentioned files...

Anyways, I can reproduce the problem by creating a new directory with a Gemfile in it like so:

group :development do
  gem 'guard'
  gem 'guard-coffeescript'
end

Running bundle install succeeds without issues, but then when I run bundle exec guard init I get this error:

20:50:27 - ERROR - Could not load 'guard/coffeescript' or '~/.guard/templates/coffeescript' or find class Guard::Coffeescript
20:50:27 - ERROR - Error is: No such file or directory @ rb_sysopen - /home/jwashton/.guard/templates/coffeescript

I checked, and I don't appear to have ~/.guard. I assume that guard/coffeescript would be local, and since we just created the current directory, of course that is missing. I don't know where Guard::Coffeescript would be defined.

I have used and enjoyed other guard plugins for other projects on the same machine.

  • Using guard 2.12.0
  • Using guard-coffeescript 1.4.0
  • Using Ruby 2.1.2

update The problem doens't appear to be just with initializing the Guardfile. If I do so manually, starting Guard presents me with the following:

22:21:33 - ERROR - Could not load 'guard/coffeescript' or find class Guard::Coffeescript
22:21:33 - ERROR - Error is: cannot load such file -- guard/guard
1

1 Answers

0
votes

I'm not sure about the details for why this fixed the problem, but the problem is resolved after these four steps:

  1. Add a source line to the Gemfile. (probably source 'https://rubygems.org')
  2. Add a Javascript runtime. (I just used gem 'therubyracer')
  3. Remove the Gemfile.lock
  4. Run bundle install

At that point, guard init succeeded without problems. I hope this helps somebody! I'm still not sure what went wrong...