Medium / phantomjs

NPM wrapper for installing phantomjs
Other
1.42k stars 435 forks source link

NPM installas the wrong binary of phantomjs #636

Closed NuLL3rr0r closed 7 years ago

NuLL3rr0r commented 7 years ago
Considering PhantomJS found at /usr/local/bin/phantomjs
Found PhantomJS at /usr/local/bin/phantomjs ...verifying
PhantomJS detected, but wrong version 2.0.0 @ /usr/local/bin/phantomjs.
Download already available at /tmp/phantomjs/phantomjs-2.1.1-macosx.zip
Verified checksum of previously downloaded file
Extracting zip contents
Removing /path/to/laverna/node_modules/phantomjs-prebuilt/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-macosx.zip-extract-1477926486735/phantomjs-2.1.1-macosx -> /path/to/laverna/node_modules/phantomjs-prebuilt/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /path/to/laverna/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs

I'm on FreeBSD, but it installs MacOS X binary.

$ file /path/to/laverna/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
/path/to/laverna/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|BINDS_TO_WEAK|PIE>

The same issue also addressed here: https://github.com/ariya/phantomjs/issues/12963

nomadlogic commented 7 years ago

This is actually a pretty big issue for me as well. It's unfortunate that other packages (such as grunt-mocha-phantomjs) are depending on a pre-built binary. I am able to build and run phantomjs on my FreeBSD systems without issues though, so I'd like to propose that phantomjs-prebuilt has a valid FreeBSD binary.

I am happy to assist with this work, although it's not obvious to me as to how the OSX and Linux binaries are produced so that I can use the same method for FreeBSD. Can someone point me in the right direction for this?

nomadlogic commented 7 years ago

also - this patch can probably be applied as well, since osx/darwin binaries are def not compatible with freebsd nor openbsd. there is a probably a more elegant solution where we throw an exception or warning if we don't match linux, windows nor osx - but I think this will prevent us from installing incompatible binaries on bsd hosts:

diff --git a/lib/util.js b/lib/util.js
index 3cf515a..7a3c17d 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -103,7 +103,7 @@ function getDownloadSpec() {
   } else if (platform === 'linux' && arch == 'ia32') {
     downloadUrl += 'linux-i686.tar.bz2'
     checksum = '80e03cfeb22cc4dfe4e73b68ab81c9fdd7c78968cfd5358e6af33960464f15e3'
-  } else if (platform === 'darwin' || platform === 'openbsd' || platform === 'freebsd') {
+  } else if (platform === 'darwin') {
     downloadUrl += 'macosx.zip'
     checksum = '538cf488219ab27e309eafc629e2bcee9976990fe90b1ec334f541779150f8c1'
   } else if (platform === 'win32') {
nicks commented 7 years ago

for now, you'll have to find/compile your own and put it on PATH