Cannot connect PhantomJS and Poltergeist in Rails application
Asked Answered
G

4

5

I've followed the instructions on Poltergeist github page but i keep getting an error that my PhantomJS version is wrong.

Specifically, it says:

Could not find an executable 'phantomjs' that matched the requirements '~> 1.8', '>= 1.8.1'. Found versions were {"/home/marko/projects/irs_machine/bin/phantomjs"=>"50"}.

Now, I have downloaded phantomjs v1.8.1 (and later v1.9.2) so the version is correct. This is really driving me crazy. I use Ubuntu 13.04, but I doubt that's the reason.

Googling for the error returns nothing of use.

Any ideas?

Gladiolus answered 16/9, 2013 at 10:36 Comment(0)
G
9

I've solved it!

What I found to be very strange was the fact that the error reported the phantomjs version to be "50" which is impossible.

I've tracked the error down to the "cliver" gem, a gem that detects versions of installed programs. It does so by regex matching the desired version string to the result of

 {command} -v

Now, when I run phantomjs -v i get "1.8.1", so what was happening? On closer inspection "1.8.1" wasn't all that I was getting back! To be precise, I got this:

 phantomjs -v
 Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.
 1.8.1

I had a fontconf error, and sure enough, the first number it contained was "50". Cliver matches against standard output, so it couldn't get a proper version because the system was writing errors out.

Once I reconfigured the 50-user.conf not to use line 9, the error was gone and poltergeist started working as expected.

Gladiolus answered 16/9, 2013 at 10:36 Comment(0)
F
2

In my case, using apt-get to install PhantomJS was installing an older version of PhantomJS. I had to manually install PhantomJS by downloading the tarball, unpacking it, and creating links to the executable in /bin:

  1. If you haven't already, remove the outdated version of PhantomJS you have installed.
    Using apt-get, the command for me was sudo apt-get remove phantomjs.
  2. Download the tarball from http://phantomjs.org/download.html.
    (You can use, for example, wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 to download the x86 version of PhantomJS 1.9.7 from the command lineto the current working directory.)
  3. Unpack the tarball in your home directory.
    According to https://askubuntu.com/a/25962/168631, the command is tar xjf phantomjs-1.9.7-linux-x86_64.tar.bz2, depending on which version you downloaded.
  4. Create symbolic links to the phantomjs executable in your /bin.
    • Following these instructions, I ran:
      1. sudo ln -s <snip>/<unpacked_tarball>/bin/phantomjs /usr/local/share/phantomjs
      2. sudo ln -s <snip>/<unpacked_tarball>/bin/phantomjs /usr/local/bin/phantomjs
      3. sudo ln -s <snip>/<unpacked_tarball>/bin/phantomjs /usr/bin/phantomjs
Framboise answered 27/6, 2014 at 23:8 Comment(0)
F
1

i also faced the same issue and resolved it by using the phantomjs gem ,which will install the phantomjs based on the platform you are working.

first remove the platform specific phantomjs ,so if you are using ubuntu sudo apt-get --purge remove phantomjs sudo rm /usr/bin/phantomjs sudo ln -s /node_modules/phantomjs/lib/phantom/bin/phantomjs /usr/bin/phantomjs

Fauna answered 25/10, 2015 at 7:31 Comment(0)
E
0

Try to move phantomjs to your /bin directory.

Enginery answered 16/9, 2013 at 10:43 Comment(1)
It gives me the same error, but includes the executable I put in /bin as wrong as well.Gladiolus

© 2022 - 2024 — McMap. All rights reserved.