Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Where can we reliably get phantomjs-X.X.X-linux-x86_64.tar.bz2? #509

Closed
denodaeus opened this issue Mar 24, 2016 · 9 comments
Closed

Where can we reliably get phantomjs-X.X.X-linux-x86_64.tar.bz2? #509

denodaeus opened this issue Mar 24, 2016 · 9 comments

Comments

@denodaeus
Copy link

  1. Bitbucket regularly fails
  2. The CDN alternative issued in the readme is regularly down
  3. Okay, so I install it from disk locally, but then I'm locked into no updates
  4. This is a pretty integral part of our CI process, so what does the community recommend as a reasonable distribution mechanism? I'd be more than happy to chip a few bucks in for a reliable S3 bucket as a means of distribution.

Please help, this is super annoying. Committing a 23MB file to our repo and keeping track of this doesn't sound fun either.

@nicks
Copy link
Contributor

nicks commented Mar 24, 2016

The main PhantomJS project is looking for a sponsor for a downloads, see:
ariya/phantomjs#13953
which has more context/discussion.

Personally, i think this is a tragedy-of-the-commons problem: people are incentivized to waste resources because the resources are free. Adding more resources doesn't fix the problem because it doesn't fix the incentives.

This installer package tries a few different strategies to cache the download locally, but there's only so much we can do.

Also, minor question, re: "Okay, so I install it from disk locally, but then I'm locked into no updates". I don't see why that's true? The installer package will check if the version on disk is the correct version.

@puzrin
Copy link

puzrin commented Mar 24, 2016

What about https://rawgit.com/ ?

@frank-weindel
Copy link

I administer a CI server that builds many different projects which can potentially use many different versions of PhantomJS. Our best effort is kept to keep them the same version but its not guaranteed because of subdependencies and some projects not wanting to take the risk of changing versions.

But most of our projects are at phantomjs-prebuilt 2.1.6 (phantom 2.1.1). I've got this version also globally installed on the server. So I'm expecting all of the projects to just use the globally installed version when building/testing etc. However this is not the case. It seems like the install script detects that phantomjs-prebuilt is globally installed but decides to skip it and download the file anyway from the CDN.

Looks like an `npm install -g`; skipping installed version.
Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2

When I type /usr/bin/phantomjs --version at the command line I get 2.1.1. So I really don't understand why its not just using the preinstalled version. Any ideas?

@frank-weindel
Copy link

Okay I figured out that this is because of the way phantomjs is installed globally when using npm. /usr/bin/phantomjs actually symlinks to a node script which runs and forwards parameters to the real phantomjs binary. phantomjs-prebuilt's install script detects this and decides to just download the binary instead.

Could there not be a way for phantomjs-prebuilt's install script to grab the globally installed binary anyway in this case? Maybe the phantomjs launching script could accept a special parameter that returns the real absolute binary path?

Installing phantomjs-prebuilt globally with npm is the most convenient way to install phantomjs at a given version and hence also getting local npm installs to stop wastefully downloading the binaries from the CDN.

@ghost
Copy link

ghost commented Mar 25, 2016

@denodaeus : how do you use a local version?
I first tar -jxf the bzip2 file, move the bin/phantomjs file to /usr/local/bin/phantomjs.
But then I have the npm install action failing on a linux container because this code tries to read the file as an UTF-8 string (it's a binary!) and there must be an exception there sending the code to the promise .fail case.
There it then discards my file found from the PATH and tries to download the file from bitbucket (fail!).

@frank-weindel
Copy link

@chriwup: I know that code looks weird but it does work. It shouldn't be throwing an exception when reading a binary file, it just surely won't find "NPM_INSTALL_MARKER". That thing is there because if you NPM install phantomjs-prebuilt globally your /usr/local/bin/phantomjs will actually be this node script which serves as a launcher for the phantomjs binary.

@nicks
Copy link
Contributor

nicks commented Mar 25, 2016

i changed it to use github releases by default, we'll see how that goes

@nicks nicks closed this as completed Mar 25, 2016
@jgibson
Copy link
Contributor

jgibson commented Mar 28, 2016

Would it be possible to use npm's cache to store the downloaded binaries? That would alleviate some of the burden on whatever hosting service ends up being used. It would also provide more reliable caching than simply relying upon tmp. That would let you resolve #466.

@ghost
Copy link

ghost commented Mar 29, 2016

Here is what happened in my case:

  Considering PhantomJS found at /usr/local/bin/phantomjs
  �[91mFATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
  �[0m
  <--- Last few GCs --->

       266 ms: Scavenge 11.5 (44.1) -> 9.7 (45.1) MB, 1.7 / 0 ms [allocation failure].
      5142 ms: Mark-sweep 13.0 (175.4) -> 9.8 (176.4) MB, 1396.2 / 52 ms [allocation failure] [GC in old space requested].
      5599 ms: Mark-sweep 9.8 (304.8) -> 9.8 (305.8) MB, 373.7 / 16 ms [allocation failure] [GC in old space requested].
      5695 ms: Mark-sweep 9.8 (434.1) -> 9.7 (434.1) MB, 28.2 / 8 ms [last resort gc].
      5702 ms: Mark-sweep 9.7 (434.1) -> 8.8 (434.1) MB, 6.3 / 0 ms [last resort gc].


  <--- JS stacktrace --->

  ==== JS stack trace =========================================

  Security context: 0x237fce9e3ac1 <JS Object>
      1: slowToString [buffer.js:362] [pc=0xb03aa44a0d9] (this=0x11230ba07841 <an Uint8Array with map 0xe2e537054f1>,encoding=0x237fce9ed9b9 <String[4]: utf8>,start=0,end=67932064)
      2: arguments adaptor frame: 1->3
      3: toString [buffer.js:~389] [pc=0xb03aa4f15e1] (this=0x11230ba07841 <an Uint8Array with map 0xe2e537054f1>)
      4: arguments adaptor frame: 1->0
      5: readFileSync [fs.js:496]...

  �[91mAborted
  �[0m�[91mnpm�[0m�[91m �[0m�[91mWARN�[0m�[91m �[0m�[91minstall:[email protected]�[0m�[91m [email protected] install: `node install.js`
  �[0m�[91mnpm�[0m�[91m �[0m�[91mWARN�[0m�[91m �[0m�[91minstall:[email protected]�[0m�[91m Exit status 134

Wouldn't it be easier to just check the filesize, if it's greater than 1MB we can safely assume it's not the javascript file we're looking for (jedi trick) but the binary file. In that case we just avoid loading it as an UTF-8 string (note: @frank-weindel what I see here is clearly an exception).
What do you think?

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

No branches or pull requests

5 participants