1
votes

I'm trying to run a Capybara/PhantomJS test in Openshift using a Ruby 1.9.3 app (not rails or web). It works well locally, but when I try bundle exec ruby test.rb it outputs:

/var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:34:in `initialize': Permission denied - bind(2) (Errno::EACCES)
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:34:in `open'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:34:in `start_server'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:26:in `initialize'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/server.rb:20:in `new'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/server.rb:20:in `start'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/server.rb:8:in `initialize'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:38:in `new'
        from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:38:in `server'
    from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:25:in `browser'
    from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:95:in `visit'
    from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/capybara-2.5.0/lib/capybara/session.rb:232:in `visit'
    from /var/lib/openshift/asdf/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/capybara-2.5.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
    from test.rb:43:in `test'
    from test.rb:58:in `<main>'

I'm using Poltergeist and manually pointing it to the phantomjs executable as seen in Poltergeit's github (exec obtained from that page, v1.98), which seems to work fine on its own and has proper executable privileges. It's located in the same dir as the ruby project, so the :phantomjs option for poltergeis is ./phantomjs.

I see from the output that the Ruby version in vendor/bundle is 1.9.1, which is not supported according to Capybara's github, but I'm not sure if this is related.

Any ideas what might be wrong here, or how to better debug this error?

1

1 Answers

1
votes

Looks like your application (or some part of it) is trying to bind to an ip address, or port, that it is not allowed to. You are only allowed to bind to your openshift ip address (not 0.0.0.0 or 127.0.0.1) and your application should bind to port 8080 so that it is publicly accessible. You can refer to this section (https://developers.openshift.com/en/managing-port-binding-routing.html) of the Developer Portal for more information about how requests are routed to your application.