Skip to content

Can't get watchman to work on Mac OS X #20

Closed

Description

@JustinTulloss

Hello,

I'm trying to use watchman to execute a Makefile target whenever a file changes. However, for this example I'm just trying to get it to do anything at all!

I've set up some roots:

[rdio/rdio] watchman watch-list
{
    "version": "2.9.3",
    "roots": [
        "/Users/justin/Dev/rdio/rdio/web/client/Components",
        "/Users/justin/Dev/rdio/rdio/web/client/core"
    ]
}

I've set up some triggers:

[rdio/rdio] watchman trigger-list `pwd`/web/client/Components
{
    "version": "2.9.3",
    "triggers": [
        {
            "name": "component-bits",
            "command": [
                "ls",
                "-l"
            ],
            "rules": [
                {
                    "pattern": "*.js *.less *.html",
                    "include": true,
                    "negated": false
                }
            ]
        }
    ]
}

And I'm running a command to log things: watchman --persistent --server-encoding=json log-level debug

When I modify a js file, it sees the modification but never executes anything. The relevant bits of the log file are:

{
    "version": "2.9.3",
    "log": "1389754641: tid=85434368 fse_thread: add /Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton/PlayButton.js 15400\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=84897792 add_pending: /Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton/PlayButton.js\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=84897792 lstat(/Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton/PlayButton.js) file=0x7f8a327a2890 dir=0x0\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=84897792 file changed exists=1 via_notify=1 stat-changed=0 isdir=0 /Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton/PlayButton.js\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=84897792 lstat(/Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton) file=0x7f8a32715330 dir=0x7f8a32703b00\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=84897792 file changed exists=1 via_notify=1 stat-changed=0 isdir=1 /Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=88330240 notify_thread[/Users/justin/Dev/rdio/rdio/web/client/core] assessing triggers\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=84897792 sub last=2  pending=3\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=88330240 notify_thread[/Users/justin/Dev/rdio/rdio/web/client/core] assessing triggers\n"
}
{
    "version": "2.9.3",
    "log": "1389754641: tid=84897792 notify_thread[/Users/justin/Dev/rdio/rdio/web/client/Components] assessing triggers\n"
}

After that it just continues to print lines about assessing triggers.

It appears from the source that I should eventually see some logs about processing events and the posix_spawnp line with the return code of the command. None of that seems to be happening.

Where should I start debugging this? I'm more than willing to dive into the code but I don't yet understand how the FSEvent watcher goes from adding something to the pending queue to actually spawning the appropriate processes.

Any help would be much appreciated!

Activity

  1. wez commented on Jan 15, 2014

    @wez
    Contributor

    Hi Justin,

    The pattern in your rules looks off; I'd expect to see one rule entry for each of the patterns ".js", ".less", "*.html"

    I suspect that you quoted the patterns all together like this: '*.js *.less *.html' instead of passing them like this: '*.js' '*.less' '*.html' when you ran watchman to set up your watch.

    You should be able to remove the current watch using the watch-del sub command and then re-adding it with the appropriate quoting.

    Hopefully smooth sailing from here on out :-)

  2. wez commented on Jan 15, 2014

    @wez
    Contributor

    sorry, trigger-del, not watch-del (these responses drafted quickly without RTFM'ing ;-)

  3. JustinTulloss commented on Jan 15, 2014

    @JustinTulloss
    Author

    Awesome! That works much better. I should have asked earlier instead of going straight to the source.

    Is there a way to see the output of the command that gets triggered?

    Thanks for your help!

  4. wez commented on Jan 15, 2014

    @wez
    Contributor

    The output will go to the watchman log; if you want it to go somewhere else, the current recommendation is to use a wrapper script that redirects its output and runs the actual command:

    #!/bin/sh
    exec > /path/to/my/log-file 2>&1
    
    ... perform the actual trigger here ...
    

    Then register the wrapper script as your trigger.

    I've opened #21 to track making this sort of thing easier, but have no immediate plans to add it right now

  5. JustinTulloss commented on Jan 16, 2014

    @JustinTulloss
    Author

    If watchman was running in the foreground, would there be a way to get those logs there? I'm trying to make output of failed build steps obvious.

  6. wez commented on Apr 1, 2014

    @wez
    Contributor

    Sorry, this dropped off my radar because the issue is closed; I'll answer your question in #32 which is a similar problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions