GithubHelp home page GithubHelp logo

Comments (12)

wez avatar wez commented on April 24, 2024

this a regression from switching to launchd (watchman is supposed to capture your PATH at the time you launch it).

A workaround would be to edit ~/Library/LaunchAgents/com.github.facebook.watchman.plist and add something like:

<key>EnvironmentVariables</key>
<dict>
    <key>PATH</key>
    <string>INSERT YOUR PATH HERE</string>
</dict>

(see man launchd.plist for more on this file)

then:

launchctl unload -w ~/Library/LaunchAgents/com.github.facebook.watchman.plist
launchctl load -w ~/Library/LaunchAgents/com.github.facebook.watchman.plist

I'll work up a fix sometime in the coming week.

from watchman.

dmcg avatar dmcg commented on April 24, 2024

That's a little less palatable than my solution TBH, because it doesn't update as I update .profile, and as I've just updated to Yosemite and am having to reinstall my toolchain $PATH is a bit of a moving target ;-)

Thanks for the attention, I'll look forward to a pukka fix.

from watchman.

jschaf avatar jschaf commented on April 24, 2024

I just ran into this issue. All of the homebrew tools are unavailable by default. @wez's solution works. I did the following for PATH

<key>EnvironmentVariables</key>
<dict>
  <key>PATH</key>
  <string>$PATH:/usr/local/sbin:/usr/local/bin</string>
</dict>

from watchman.

jimtla avatar jimtla commented on April 24, 2024

Any updates on this? As a hack I've added a script to freeze my current env into the plist:

#Freeze the current env to the watchman config. This is a hack to get around
# https://github.com/facebook/watchman/issues/68
ENVIRONMENT=$(env | sed 's/=/<\/key><string>/' | sed -e 's/^/<key>/' | sed -e 's/$/<\/string>/')
echo $ENVIRONMENT

PLIST=~/Library/LaunchAgents/com.github.facebook.watchman.plist

# Remove the last two lines.
sed -i '' -e '$ d' $PLIST
sed -i '' -e '$ d' $PLIST

# replace the second to last line (previously "</dict>") with our environment +
# "</dict>"
echo "<key>EnvironmentVariables</key><dict>"$ENVIRONMENT"</dict></dict>" >> $PLIST

# Replace the last line
echo "</plist>" >> $PLIST

# Reload the watchman config
launchctl unload -w ~/Library/LaunchAgents/com.github.facebook.watchman.plist
launchctl load -w ~/Library/LaunchAgents/com.github.facebook.watchman.plist

but it's annoying to manually run that after any update to my env.

from watchman.

wez avatar wez commented on April 24, 2024

We have a diff that we'll land real soon now: https://reviews.facebook.net/D36045

from watchman.

wez avatar wez commented on April 24, 2024

This has landed; we're going to cut 3.1 with this fix in it soon and submit a PR to homebrew.
Meanwhile, you can do brew install --HEAD watchman to pick up this fix.

from watchman.

sunny-mittal avatar sunny-mittal commented on April 24, 2024

I am still having an issue related to this (I think) using 3.3.0. I ran the following in my project root:

$ watchman watch `pwd`
$ watchman -- trigger `pwd` js '*.js' -- "browserify -o bundle.js"

But when I check the logs, I see a "No such file or directory" error. If I change the command to cat or something, I see the output in the log as expected. The plist confirms that my path is getting picked up, but it doesn't seem to be able to find browserify.

from watchman.

wez avatar wez commented on April 24, 2024

I think you want this:

watchman -- triggerpwdjs '*.js' -- browserify -o bundle.js

otherwise watchman will try to find the file named "browserify -o bundle.js" in your path and execute it

from watchman.

sunny-mittal avatar sunny-mittal commented on April 24, 2024

I tried that as well...no luck. I also tried it with various node-related commands and they all fail with the same error. Any other ideas? In the log file, I can see that the path is correct but it just doesn't seem to want to execute any command related to node.

from watchman.

wez avatar wez commented on April 24, 2024

I can't see your log file so I don't have any more context than you have shared on this closed issue.
I'd recommend just making a wrapper script that sets the appropriate things in the environment:

#!/bin/sh
PATH="$PATH:/some/where"
NODE_PATH="whatever is appropriate"
export PATH NODE_PATH
exec browserify -o bundle.js "$@"

from watchman.

sunny-mittal avatar sunny-mittal commented on April 24, 2024

I'll give that a shot. Thanks for your help!

from watchman.

jimtla avatar jimtla commented on April 24, 2024

For anybody looking - my hack to freeze the environment into the plist doesn't work so well anymore, but I wrote a new script to bake the current environment into a shell script:

#!/bin/bash -e -x

# Takes a bash script as the only argument, and prints the location of a new
# shell script that executes the given script with the current environment.

SCRIPT=`mktemp $TMPDIR"bake_env".XXXXXXXX`
ENVIRONMENT=$(env | sed "s/=\(.*\)\$/='\1'/g" | sed 's/^/;export /')
echo "#!/bin/bash -e" >> $SCRIPT
echo "true"$ENVIRONMENT >> $SCRIPT
ABS_PATH=`python -c "import os; print os.path.realpath('$1')"`
echo "exec $ABS_PATH \$@" >> $SCRIPT
chmod a+x $SCRIPT
echo $SCRIPT

When I want to run something with watchman I pass the target to run to that script, and then pass the output to watchman.

from watchman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.