Having trouble with Guard::Jammit

165 views
Skip to first unread message

l...@bloomcrush.com

unread,
May 2, 2013, 11:01:11 AM5/2/13
to guar...@googlegroups.com
Hi all,
I'm an experienced Ruby/Rails dev but a Guard newb.

I'm adding Guard to an existing Rails project with the primary goal of getting it auto packaging with an existing Jammit setup.

I've manged to get everything hooked up and when I start guard it runs the Jmmit compile as I would expect it to. However, it doesn't seem to detect any changes to the asset files.

I've verified that rb-fsevent picks up changes in the asset dir:

1.9.2p180 :001 > require 'rb-fsevent'
 => true
1.9.2p180 :003 >   fsevent = FSEvent.new
 => #<FSEvent:0x0000010081d728>
1.9.2p180 :004 > fsevent.watch File.join(Dir.pwd, 'public', 'javascripts') do |directories|
1.9.2p180 :005 >       puts "Detected change inside: #{directories.inspect}"
1.9.2p180 :006?>   end
 => []
1.9.2p180 :008 >   fsevent.run

touch public/javascritpts/common.js in a separate terminal

Detected change inside: ["/Users/leskiger/Sites/pvpowered/phoenix/public/javascripts/"]

I've also added guard-rspec and that is detecting and running specs as I would expect it to.

Here's a fully copy of my Guardfile:

notification :growl

guard :jammit, :package_on_start => true do
  watch(%r{^public/javascripts/(.*)\.js$})
  watch(%r{^public/stylesheets/(.*)\.css$})
end

guard 'rspec', :version => 2 do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { "spec" }

  # Rails example
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }

  # Capybara request specs
  watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |m| "spec/requests/#{m[1]}_spec.rb" }

  # Turnip features and steps
  watch(%r{^spec/acceptance/(.+)\.feature$})
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})   { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end



And the applicable portion of the Gemfile:

group :development, :test do
...
  gem 'growl'

  gem 'guard'
  gem 'rb-inotify', :require => false
  gem 'rb-fsevent', :require => false
  gem 'rb-fchange', :require => false
  gem 'guard-jammit'
  gem 'guard-rspec'

end


Current locked gem versions:
rails: 3.0.9
jammit: 0.6.3
guard: 1.8.0
guard_jammit: 1.0.1


Running on MacOS 10.7.4. Project in git. No dropbox, etc.

Any suggestions would be greatly appreciated.

Thanks!
Les

Rémy Coutable

unread,
May 2, 2013, 4:51:32 PM5/2/13
to guar...@googlegroups.com
Hi Les,

could you try running only guard-jammit in debug mode and let us know the output: guard -P jammit -d

Btw, since version 1.8, Guard depends on Listen >= 1.0 so you don't have to specify rb-inotify, rb-fsevent nor rb-fchange anymore (Listen takes care of these dependencies). You also don't even have to specify guard in your Gemfile (guard-rspec and guard-jammit already depends on it).

Let us know with the debug output!

Cheers,
Rémy

Les Kiger

unread,
May 2, 2013, 7:16:59 PM5/2/13
to guar...@googlegroups.com
Hi Rémy,

Here is that output:

$ bundle exec guard -P jammit -d
16:14:02 - DEBUG - Command execution: growlnotify --version
16:14:02 - INFO - Guard uses Growl to send notifications.
16:14:02 - DEBUG - Command execution: hash stty
16:14:02 - DEBUG - Guard starts all plugins
16:14:02 - DEBUG - Hook :start_begin executed for Guard::Jammit
16:14:02 - INFO - Using Jammit version 0.6.3
16:14:02 - DEBUG - Command execution: java -version 2>&1
16:14:02 - INFO - Jammit successfully packaged the assets.
16:14:02 - DEBUG - Hook :start_end executed for Guard::Jammit
16:14:02 - INFO - Guard is now watching at '/Users/leskiger/Sites/pvpowered/phoenix'
16:14:03 - DEBUG - Command execution: stty -g 2>/dev/null
16:14:03 - DEBUG - Start interactor
[1] {Jammit} guard(main)>
Changed public/javascritpts/common.js at this point, no additional output


Helpful at all? I see that it's running the start_begin and start_end hooks, but I don't see much else to go on there.


Also, thanks for the info on the dependencies. I'll make those changes. The Guard main readme could use some updating to reflect. :)

Les

--
You received this message because you are subscribed to a topic in the Google Groups "guard-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/guard-dev/pnnnMYi-tOA/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to guard-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michael Kessler

unread,
May 3, 2013, 4:09:39 AM5/3/13
to guar...@googlegroups.com
Hi Les

I just did a quick check to see if all is working fine on my machine:

$ mkdir testjammit

$ cd testjammit

$ echo "source 'https://rubygems.org'\ngem 'guard-jammit'\n" > Gemfile

$ bundle Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using coderay (1.0.9)
Using cssmin (1.0.3)
Using ffi (1.8.1)
Using formatador (0.2.4)
Using rb-fsevent (0.9.3)
Using rb-inotify (0.9.0)
Using rb-kqueue (0.2.0)
Using listen (1.0.3)
Using lumberjack (1.0.3)
Using method_source (0.8.1)
Using slop (3.4.4)
Using pry (0.9.12.1)
Using thor (0.18.1)
Using guard (1.8.0)
Using jsmin (1.0.1)
Using jammit (0.6.6)
Using guard-jammit (1.0.1)
Using bundler (1.3.5)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

$ bundle exec guard init 09:52:18 - INFO - Writing new Guardfile to /Users/michi/testjammit/Guardfile
09:52:18 - INFO - jammit guard added to Guardfile, feel free to edit it

$ cat Guardfile # A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard :jammit do
watch(%r{^public/javascripts/(.*)\.js$})
watch(%r{^public/stylesheets/(.*)\.css$})
end

$ mkdir -p public/javascripts

$ mkdir -p public/stylesheets

$ mkdir config

$ echo "javascripts:\n common:\n - public/javascripts/*.js\nstylesheets:\n common:\n - public/stylesheets/*.css" > config/assets.yml

$ cat config/assets.yml
javascripts:
common:
- public/javascripts/*.js
stylesheets:
common:
- public/stylesheets/*.css

$ bundle exec guard 09:57:20 - INFO - Guard uses TerminalTitle to send notifications.
09:57:20 - INFO - Using Jammit version 0.6.6
Jammit Warning: No assets match 'public/stylesheets/*.css'
Jammit Warning: No assets match 'public/javascripts/*.js'
09:57:20 - INFO - Jammit successfully packaged the assets.

09:57:20 - INFO - Guard is now watching at '/Users/michi/testjammit'
[1] guard(main)> .touch public/stylesheets/style.css
Jammit Warning: No assets match 'public/javascripts/*.js'
09:57:42 - INFO - Jammit successfully packaged the assets.

[1] guard(main)> .touch public/javascripts/script.js
09:58:04 - INFO - Jammit successfully packaged the assets.

[1] guard(main)>
09:58:12 - INFO - Bye bye…

So all fine here, guard-jammit works as expected. Since rb-fsevent works fine, because the other Guard plugins are working, I assume you have a typo/wrong path somewhere (You write you touched inside `public/javascritpts`, but the path is `public/javascripts`.

You can always debug a watch method by providing a block, like

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard :jammit do
watch(%r{^public/javascripts/(.*)\.js$}) do |m|
puts "javascripts changed", m.inspect
m[0]
end

watch(%r{^public/stylesheets/(.*)\.css$}) do |m|
puts "stylesheets changed", m.inspect
m[0]
end
end

And then the output looks like

$ bundle exec guard 10:08:40 - INFO - Guard uses TerminalTitle to send notifications.
10:08:40 - INFO - Using Jammit version 0.6.6
10:08:40 - INFO - Jammit successfully packaged the assets.

10:08:40 - INFO - Guard is now watching at '/Users/michi/testjammit'
[1] guard(main)> .touch public/javascripts/script.js
javascripts changed
["public/javascripts/script.js", "script"]
10:08:42 - INFO - Jammit successfully packaged the assets.

[1] guard(main)> .touch public/stylesheets/style.css
stylesheets changed
["public/stylesheets/style.css", "style"]
10:08:45 - INFO - Jammit successfully packaged the assets.

[1] guard(main)>
10:08:47 - INFO - Bye bye…

I hope that helps
Michael



>> guard :jammit, :package_on_start => true do
>> watch(%r{^public/javascripts/(.*)\.js$})
>> watch(%r{^public/stylesheets/(.*)\.css$})
>> end


> You received this message because you are subscribed to the Google Groups "guard-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to guard-dev+...@googlegroups.com.

Les Kiger

unread,
May 6, 2013, 2:15:00 PM5/6/13
to guar...@googlegroups.com
Hi Michael,

Thanks so much for your detailed reproduction.

As a sanity check, I reproduced your reproduction and found something interesting. Guard is not detecting changes for Jammit even in this vanilla project. It runs the compile on start, but then it seems like it "hangs" when I touch an asset.

I say "hangs" because if I type 'exit' in the Guard terminal, it hangs up. Then if I ctrl-c, it gives me output like it had just finished running jammit. Then a second exit actually closes the Guard terminal:


$ bundle exec guard
11:07:44 - INFO - Guard uses TerminalTitle to send notifications.
11:07:44 - INFO - Using Jammit version 0.6.6
Jammit Warning: No assets match 'public/javascripts/*.js'
11:07:44 - INFO - Jammit successfully packaged the assets.

11:07:44 - INFO - Guard is now watching at '/Users/leskiger/temp/testjammit'
[1] guard(main)> .touch public/stylesheets/style.css
[2] guard(main)> exit
11:07:48 - INFO - Bye bye…
<hangs, I crtrl-c>
Jammit Warning: No assets match 'public/javascripts/*.js'
11:07:57 - INFO - Jammit successfully packaged the assets.
[1] guard(main)> exit
11:08:04 - INFO - Bye bye…

I can't seem to reproduce the hang in jammit alone:

$ jammit
Jammit Warning: No assets match 'public/javascripts/*.js'
$


If I add the debugging blocks to the Guardfile, then it seems to lock up really solid (ctrl-c doesn't yield any results after the Bye bye… message) and I have to kill the process externally:

$ bundle exec guard
11:12:51 - INFO - Guard uses TerminalTitle to send notifications.
11:12:51 - INFO - Using Jammit version 0.6.6
Jammit Warning: No assets match 'public/javascripts/*.js'
11:12:51 - INFO - Jammit successfully packaged the assets.

11:12:51 - INFO - Guard is now watching at '/Users/leskiger/temp/testjammit'
[1] guard(main)> .touch public/stylesheets/style.css
[2] guard(main)> exit
11:12:58 - INFO - Bye bye...
^C
^C^C
^C^C
Terminated: 15


I have to admit, I'm a but stumped. Any further ideas?

Thanks so much!
Les

Michael Kessler

unread,
May 6, 2013, 2:41:58 PM5/6/13
to guar...@googlegroups.com
Hi Les

That looks like a threading issue. The only thing that comes to mind is that we had some strange issues with Rubies not having proper readline support. Do you have your Ruby version built with libedit or libreadline? If you don't know, it's likely that you have libedit and you should try: https://github.com/guard/guard/wiki/Add-proper-Readline-support-to-Ruby-on-Mac-OS-X

You can also disable the interactor to see if libedit is the problem:

$ bundle exec guard -i

Michael

Les Kiger

unread,
May 10, 2013, 2:17:51 PM5/10/13
to guar...@googlegroups.com
I've had very limited time to play with this this week, so wanted to apologize for the lack of updates. I'll write in when I have more to report.

Les

J. B. Rainsberger

unread,
Aug 28, 2013, 4:11:16 AM8/28/13
to guar...@googlegroups.com
On Monday, 6 May 2013 21:41:58 UTC+3, netzpirat wrote:
Hi Les

That looks like a threading issue. The only thing that comes to mind is that we had some strange issues with Rubies not having proper readline support. Do you have your Ruby version built with libedit or libreadline? If you don't know, it's likely that you have  libedit and you should try: https://github.com/guard/guard/wiki/Add-proper-Readline-support-to-Ruby-on-Mac-OS-X

You can also disable the interactor to see if libedit is the problem:

$ bundle exec guard -i

Jumping in...

I have this problem, running OS 10.8.4, rvm 1.20.12, and after rebuilding ruby 1.9.3-p429 using the "Add Proper Readline Support..." instructions. `bundle exec guard -i` works OK, but `bundle exec guard` still has Pry opening when a file changes. This happens for all guard plugins.

I don't know what else to try to diagnose the problem, nor am I sure how to verify that my ruby uses readline over libedit. I'll search for how to verify that, but in the meantime, what can I do to get more information about what's happening?

Thanks.
--jbrains

J. B. Rainsberger

unread,
Aug 28, 2013, 4:17:15 AM8/28/13
to guar...@googlegroups.com
Not sure whether this suffices, but I *think* this means that I'm using readline:

Where I explicitly installed ruby with readline, according to the instructions...
➜  ~ git:(master) ✗ rvm use 1.9.3-p429
Using /Users/jbrains/.rvm/gems/ruby-1.9.3-p429
➜  ~ git:(master) ✗ find $MY_RUBY_HOME | grep -i readline
/Users/jbrains/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/x86_64-darwin12.4.0/readline.bundle
➜  ~ git:(master) ✗ find $MY_RUBY_HOME | grep -i libedit
[Nothing]

Where I have a previously-installed ruby without following the instructions for including readline... (I guess I did it without realising it)
➜  ~ git:(master) ✗ rvm use 1.9.3-p286
Using /Users/jbrains/.rvm/gems/ruby-1.9.3-p286
➜  ~ git:(master) ✗ find $MY_RUBY_HOME | grep -i readline
/Users/jbrains/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/x86_64-darwin12.2.0/readline.bundle
➜  ~ git:(master) ✗ find $MY_RUBY_HOME | grep -i libedit
[Nothing]

Does this mean that I've installed ruby with proper readline support? If not, then how else can I check? If so, then what the hell do I do now?!?! :)

Thanks.
--jbrains

J. B. Rainsberger

unread,
Aug 28, 2013, 4:34:38 AM8/28/13
to guar...@googlegroups.com
OK. I've upgraded rvm, checked that I have readline installed by Homebrew correctly, .rvm/user/db points to Homebrew readline, I've reinstalled rubies. No luck.

I included gem rb-readline in my project, bundle install, bundle exec guard. No luck.

I am, as we say in the curling countries, out of rocks. Not urgent, but it's bothering me, so I appreciate any help you can offer.

Thanks.
--jbrains 
Reply all
Reply to author
Forward
0 new messages