geksilla/atom-fuzzy-grep

Failed to spawn command `ag` on second window

tuananh opened this issue · 15 comments

When i open another folder with atom ., it complains that it cannot find ag in PATH.

Failed to spawn command

Hi @tuananh, sorry for late response. Did you install ag and what OS you use?

@geksilla i installed ag and it works just fine if i have 1 Atom window. Sometimes when I open another window (via atom cli), i got that error on the second window. The first window still works just fine.

I'm using latest Atom (1.0.2) and OS X (10.11)

For me it doesn't work at all with ag, and it makes no difference if there are zero, one, or more than one buffers.

Uncaught BufferedProcessError: Failed to spawn command `ag`. Make sure `ag` is installed and on your PATH

ag was installed with homebrew and symlinked to Cellar as per usual.

ls -la /usr/local/bin
lrwxr-xr-x   1 XXXXXXX  admin    43B Sep  7 17:27 ag@ -> ../Cellar/the_silver_searcher/0.30.0/bin/ag

so ag is definitely in the Path...

$ which ag
/usr/local/bin/ag

Using OS X 10.10.5 and Atom 1.0.11.

jamby commented

I'm in the same boat as @mendeza here. I have ag installed and am running OS X 10.10.3 with Atom 1.0.11, and it still is giving me the error of Failed to spawn command 'ag'.

Seems like issue with PATH settings in atom. Currently running on Linux Ubuntu 14.04, atom 1.0.11 and cannot reproduce this. Will check this on mac as well. Can you please try possible workarounds:

  • launch atom from terminal
  • or set Grep Command String with absolute path to ag

I've seen similar issues with another packages when ran atom from spotlight/alfred.
Thanks.

Possible related issue

@geksilla yeah, found a solution that worked for me: open using atom from terminal

@irjamby @mendeza @tuananh

jamby commented

I wrote a ruby script to fix this immediately, since it needs to be redone every time Atom updates if anyone else comes across this:

https://github.com/jamby/AtomGrepFix

Just remember to make sure your path is correct!

@jamby, this is awesome! In the one of the project which I contributed we hot fix $PATH variable on package activation. Also there is a package environment that can fix this problem but I don't use it since it works for OS X only. May be I will write another package that could fix env variables when atom launched not from terminal. Or provide code snippet in README that you can use in your init.coffee to fix PATH problems.

jamby commented

@geksilla If you know what I need to put inside the init.coffee to fix it for when atom isn't launched from terminal, let me know. I'll update the script to question what you want to do exactly (either for terminal or not for terminal).

So I will use environment to fix this on OS X. Currently commited required changes and info to README. Let me check it on my Mac. I will publish new version after testing.

Released new version. Please update your package and install environment package if not installed.

jamby commented

@geksilla This is now happening in the latest build of Atom (1.6.2).

@geksilla This is now happening in the build of Atom v1.8.0.

mgwio commented

@liuderchi The functionality of the environment package was added to atom natively:

This package is a no-op on Atom >= 1.7.0. It uses functionality built into Atom in 1.7.0+ and allows for that to function in prior versions of Atom.

Removing the environment package fixed this for me.