66

Just installed phantomjs, mac os x yosemite. Whenever I run /bin/phantomjs, with any parameter, I get Killed: 9. Any idea?

azv
  • 1,583
  • 4
  • 18
  • 25

6 Answers6

99
  1. Install UPX. UPX is an executable packer and unpacker

    $ brew install upx
    
  2. Unpack the phantomjs executable

    $ upx -d phantomjs-2.0.0-macosx/bin/phantomjs
    
  3. Run the phantomjs executable

    $ ./phantomjs-2.0.0-macosx/bin/phantomjs
    
Ram
  • 1,297
  • 1
  • 11
  • 17
  • 5
    Thanks, works perfectly for me. @AndrewT. upx is an executable packer, running upx -d reverses the packing of the executable and restores it back to its original form (kind of like unzipping a file) – Brian Heese Mar 13 '15 at 10:40
  • Note to others: your path to phantomjs might be different. I had been keeping my binary in /usr/bin/phantoms – lewsid May 25 '15 at 19:17
  • 4
    This is the correct answer. The other should have its checkmark removed, and it should be put on this answer. – Utkonos Sep 20 '15 at 22:14
  • 1
    Works perfectly on OS 10.11 – Joseph Oct 25 '15 at 07:51
  • @Ram thanks, it works. but how? why do we need to unpack it? – mustafa Dec 16 '15 at 08:17
  • There may be a bug in packaging script of Phantom.JS. Their documentation indicates that executables are packed only on Windows. Unfortunately, they are packed on Mac too. Please see: http://phantomjs.org/release-preparation.html. ``` Pack phantomjs.exe with UPX: upx %PHANTOMJSDEPLOYDIR%\phantomjs.exe Zip the contents of %PHANTOMJSDEPLOYDIR%. ``` – Ram Jan 05 '16 at 22:00
  • If you've installed phantomjs 2 using brew cask install phantomjs, run upx -d /opt/homebrew-cask/Caskroom/phantomjs/2.0.0/phantomjs-2.0.0-macosx/bin/phantomjs – Ben Jan 06 '16 at 11:02
  • `$ brew install upx Killed: 9` – Ben Hillier Sep 01 '20 at 12:29
63

re: running phantomjs on osx yosemite, download the build/fix found at:

https://github.com/eugene1g/phantomjs/releases

original issue:

https://github.com/ariya/phantomjs/issues/12928

sdeburca
  • 845
  • 9
  • 9
  • 2
    So basically it's not exactly this link above, but the link that is linked in the link above (lol) which is https://github.com/eugene1g/phantomjs/releases – henritroyat Jun 06 '15 at 01:36
  • 3
    Place extracted `phantomjs` script inside e. g. `/usr/local/bin` or other `$PATH` related folder. – jmarceli Jul 07 '15 at 10:00
  • 1
    Anyone know why this hasn't been merged into the main repo yet? – TommyMac Oct 23 '15 at 18:15
2

The eugene1g release and UPX install didn't work for me on El Capitan. What did work for me was installing PhantomJS using the phantomjs2 NPM package:

npm install phantomjs2

# Optional: symlink in a dir that's on my PATH:
ln -s /usr/local/lib/node_modules/phantomjs2/lib/phantom/bin/phantomjs /usr/local/bin/phantomjs 
Blaise
  • 13,139
  • 9
  • 69
  • 97
2

$ npm install -g phantomjs worked for me on El Capitan.

The npm package isn't "official", it's maintained by a contributor, but it works. https://github.com/eugene1g/phantomjs

Aditya M P
  • 5,127
  • 7
  • 41
  • 72
1

Blunt re-install using brew

Whatever is in /usr/local/bin/phantomjs has stopped working for you.

If you've got ~30mins to spare you can reinstall and relink using brew:

  # unlink old version
  brew unlink phantomjs

  # reinstall phantomjs
  brew update && brew install phantomjs

  # (You may wish to make a refreshing herbal tea or similar beverage here...)

  # Update link to usr/local/bin
  brew link --overwrite phantomjs

If you want to test what brew will do with overwrite you can run

 brew link --overwrite --dry-run phantomjs 
Ralph Cowling
  • 2,839
  • 1
  • 20
  • 10
0

Sometimes this happens when your current shell process is killed.

I was in tmux using brew update, and brew updated tmux and bash, then bang! Everything in tmux just returns Killed: 9.

dz902
  • 4,782
  • 38
  • 41