Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find phantomjs.exe on Windows #19

Closed
elcubo opened this issue May 31, 2016 · 16 comments
Closed

Cannot find phantomjs.exe on Windows #19

elcubo opened this issue May 31, 2016 · 16 comments

Comments

@elcubo
Copy link

elcubo commented May 31, 2016

While running tests using JRuby, Capybara and Poltergeist, I get the following error:

Cliver::Dependency::NotFound: Could not find an executable at given path 'c:/utils/phantomjs-2.1.1-windows/bin/phantomjs.EXE'.If this path was not specified explicitly, it is probably a bug in [Cliver](https://github.com/yaauie/cliver/issues).

The path to phantomjs.exe is correct and it is also part of my Windows path. Running phantomjs --version from the command prompt returns "2.1.1", so there is no doubt that the exe file is present and working.

Is there some kind of workaround that I can use to get around this problem (if it is indeed a bug, like the error message says)? Is the cause of the bug known, and are there any countermeasures? I'd really appreciate some help, as I am quite stuck.

@elcubo
Copy link
Author

elcubo commented May 31, 2016

I ran Cliver in IRB and tried to verify the same program entries that are mentioned in the error message, without being able to reproduce the error.

irb(main):001:0> require 'cliver'
=> true
irb(main):002:0> Cliver.detect('subl')
=> nil
irb(main):003:0> Cliver.detect('phantomjs.exe')
=> "c:/utils/phantomjs-2.1.1-windows/bin/phantomjs.exe"
irb(main):004:0> Cliver.detect!('phantomjs.exe')
=> "c:/utils/phantomjs-2.1.1-windows/bin/phantomjs.exe"
irb(main):005:0> Cliver.detect!('c:/utils/phantomjs-2.1.1-windows/bin/phantomjs.exe')
=> "c:/utils/phantomjs-2.1.1-windows/bin/phantomjs.exe"
irb(main):006:0> Cliver.detect!('c:/utils/phantomjs-2.1.1-windows/bin/phantomjs.EXE')
=> "c:/utils/phantomjs-2.1.1-windows/bin/phantomjs.EXE"

@yaauie
Copy link
Owner

yaauie commented May 31, 2016

If cliver can detect it in IRB, it's possible that you have multiple versions of cliver installed and the one activated from within poltergeist is an old version (e.g., running your tests via bundle exec, which activates the versions specified in your project's Gemfile.lock). A few of the early versions of cliver had some issues with Windows support (see fixes 5617ce6 and 45495a9), but the current version 0.3.2 should have them mitigated.

To see which versions you've got, run:

gem list cliver

To see which is activated by your bundle, inspect your project's Gemfile.lock file.

@elcubo
Copy link
Author

elcubo commented May 31, 2016

Thank you very much for responding. I've checked my Gem repositories like you suggested and I have just the one version, v0.3.2 installed. That's also the version being referenced in my Gemfile.lock.

I had to get past this problem, and since PhantomJS is clearly available on my computer, I monkey patched Cliver to "short circuit" the ShellCapture class by telling it which version I have available like this:

module Cliver
  class ShellCapture
    def initialize(_command)
      @stderr = ''
      @stdout = '2.1.1'
      @command_found = true
    end
  end
end

This works fine for now, but I would really be interested in finding a more permanent solution. I can supply you with more information if you want. E.g. I know that the call to Open3.popen3() in the initialize method of ShellCapture raises an exeption:

NotImplementedError: waitpid unsupported or native support failed to load; see http://wiki.jruby.org/Native-Libraries

I don't know if that helps pinpointing the problem, but I can certainly try to provide you with whatever information you need.

@yaauie
Copy link
Owner

yaauie commented May 31, 2016

I'm glad you got unblocked; with 0.3.2 you can also set the CLIVER_NO_VERIFY environment variable in order to make cliver assume that the first executable it finds on your path matches the version requirement without actually shelling out to check; in your case though I'm a bit confused because the error message you initially reported was that it couldn't find the executable at all.

I would be glad to review/merge a fix if you have the time to put one together, but I don't have a lot of spare time to actively hunt out issues on this project (and don't have a Windows VM with JRuby handy either).

@elcubo
Copy link
Author

elcubo commented Jun 1, 2016

I'll dig into it, and let you know if I come up with a solution. Thanks.

@elcubo
Copy link
Author

elcubo commented Jun 1, 2016

Seems like there is a problem with popen3 on windows in JRuby 9K. I have reported this as jruby/jruby#3948 .

@karlhe
Copy link

karlhe commented Jun 15, 2016

Encountered this as well, thanks for the workaround @elcubo !

@luke-hill
Copy link

Also encountered this issue. The patch described by @elcubo does work, however I'd be more inclined to see why it's doing this also.

Because the values it modifies are local, there's no file we can dig into and fix that we can then upload easily (Or am I wrong here?)

@elcubo
Copy link
Author

elcubo commented Aug 16, 2016

jruby/jruby#3948 is now solved: jruby/jruby#3948 (comment). It will be in the 9.1.3 release, but can be used via the nightly build as of now. Get it here: http://ci.jruby.org/

This issue can be closed.

@luke-hill
Copy link

@elcubo What release is that sorry (The 9.1.3), I'm guessing it's not a ruby or phantom release?

@elcubo
Copy link
Author

elcubo commented Aug 16, 2016

It's the upcoming JRuby version.

@luke-hill
Copy link

Aha oki. This issue also exists in regular Ruby (Along with poltergeist and phantom). Is it likely that you'll be able to back-port this to regular ruby somehow via the cliver gem?

I'm a Tester not a dev so apologies if that is a stupid thing to ask

@luke-hill
Copy link

Hi @yaauie. Had a couple of tries at this recently. One issue raised because we know the PATH is working for several instances is that could we get the gem to detect the .exe in lowercase. As for a lot of machines modifying the .exe to be upper case is tricky.

Not sure if that would cause it not to detect. But it's worth a shot right?

Also @elcubo , you mentioned this was fixed in JRuby, is there any plans for this to port down to regular ruby? This issue essentially means I can't test poltergeist without my monkey patch which is too frustrating to maintain cross branches. And because it's not everyone who gets this issue, it's not worth pushing up a monkeypatch to a repo to be cross-branch

@elcubo
Copy link
Author

elcubo commented Nov 14, 2016

I can't say I've had any such problems as this on MRI Ruby. My understanding was that it was a JRuby specific problem, and it should work fine on MRI. At least the popen3 problem was JRuby specific.

@luke-hill
Copy link

Sadly not, everything mentioned before is still an issue. Although I've re-read up about an Environment variable that can be set. Will wait for @yaauie to advise if this is worth trialling in regular Ruby

@yaauie
Copy link
Owner

yaauie commented Nov 16, 2016

@elcubo thank you for following up. I'm closing this ticket.

@luke-hill I believe your issue is separate; although it has a similar result (cliver can't detect the version of an executable), if you're still experiencing this issue could you open a new bug with complete repro steps? It would be helpful to have your PATH and PATHEXT environment variables, along with the full path to the executable you're trying to get cliver to veriify and any other special environment-specific setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants