colszowka / phantomjs-gem

Phantomjs via Rubygems: Auto-install phantomjs on demand for current platform. Comes with poltergeist integration.
Other
222 stars 104 forks source link

Configurable download folder? #90

Open endymion opened 8 years ago

endymion commented 8 years ago

Maybe this is a dumb idea but I wanted to create an issue page to maybe help somebody in the future who has the problem I just had. I'm setting up Cucumber and Poltergeist and PhantomJS in a Docker container. I'm using the phantomjs gem to install PhantomJS because apt-get can't find the phantomjs package. The gem initially failed to install:

$ docker-compose run web bundle 
exec cucumber
Phantomjs does not appear to be installed in /root/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs, installing!
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:100   333    0   333    0     0    567      0 --:--:-- --:--:-- --:--:--  4162
bunzip2: phantomjs-2.1.1-linux-x86_64.tar.bz2 is not a bzip2 file.
tar: phantomjs-2.1.1-linux-x86_64.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
There was an error while trying to load the gem 'phantomjs/poltergeist'. (Bundler::GemRequireError)
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
/ticket-driver/config/application.rb:7:in `<top (required)>'
/ticket-driver/config/environment.rb:2:in `require_relative'
/ticket-driver/config/environment.rb:2:in `<top (required)>'
/usr/local/bundle/gems/cucumber-rails-1.4.4/lib/cucumber/rails.rb:7:in `require'
/usr/local/bundle/gems/cucumber-rails-1.4.4/lib/cucumber/rails.rb:7:in `<top (required)>'
/ticket-driver/features/support/env.rb:7:in `require'
/ticket-driver/features/support/env.rb:7:in `<top (required)>'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `each'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:61:in `run!'
/usr/local/bundle/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in `execute!'
/usr/local/bundle/gems/cucumber-2.4.0/bin/cucumber:8:in `<top (required)>'
/usr/local/bundle/bin/cucumber:16:in `load'
/usr/local/bundle/bin/cucumber:16:in `<main>'

It failed because it's trying to download the distribution file to the $HOME folder. That folder didn't exist for that user in my Ruby container.

I solved the problem by adding this to my Dockerfile:

ENV home=/var/tmp

Maybe it might have been nice to be able to specify that somehow through the Gemfile? Not sure if that's even possible? Maybe this is a dumb suggestion you should close, I just wanted to post my story to get it onto the Google radar of anybody who can't figure out how to install PhantomJS in a Docker container using this gem.

maxdbn commented 7 years ago

@endymion There's a setter method for the download folder, you can configure it like this: Phantomjs.base_dir = File.join(File.expand_path(YOUR_DESIRED_FOLDER), '.phantomjs', Phantomjs.version) Before using Phantomjs.path

sbrocos commented 6 years ago

I have this problem, but i can't resolve with this two explanations.

Ever show me the next message

Phantomjs does not appear to be installed in /root/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs, installing!

Where configure Phantomjs.base_dir? In Rails helper? In Initializers folder?

sbrocos commented 6 years ago

Fine. I Resolved, add the configuration on capybara.rb in supports for rspec. But, install phantom each run rspec... i can change this for install one?