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

2.1.8 changes phantomjs install location on Amazon Elastic Beanstalk #583

Closed
trevonromanuik opened this issue Jul 29, 2016 · 5 comments
Closed

Comments

@trevonromanuik
Copy link

When I install phantomjs-prebuilt v2.1.7 the contents of location.js are as follows:
module.exports.location = "phantom/bin/phantomjs"
module.exports.platform = "linux"
module.exports.arch = "x64"

When I install phantomjs-prebuilt v2.1.8 the contents of location.js change to:
module.exports.location = "/tmp/deployment/application/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs"
module.exports.platform = "linux"
module.exports.arch = "x64"

Now AFAIK the way Amazon Elastic Beanstalk deploys work is that once a deploy is complete it copies the contents of /tmp/deployment/application to it's proper final location and wipes the /tmp directory, so the location that location.js is pointing to no longer exists. Why would the location in location.js have changed between v2.1.7 and v2.1.8?

@AustinAutomation
Copy link

Hi, I'm also having this problem. My prerender service is designed to redeploy each week and is now failing and I cannot spin up any new prerender due to this issue. Could we please have this issue resolved asap. Thank you

@thoop
Copy link
Contributor

thoop commented Aug 2, 2016

It looks like this is due to AWS running npm install in /tmp/deployment/application, letting everything install, then moving the application to /var/app/current after everything has been installed.

Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1470158228290/phantomjs-2.1.1-linux-x86_64 -> /tmp/deployment/application/node_modules/prerender/node_modules/phridge/node_modules/phantomjs-prebuilt/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /tmp/deployment/application/node_modules/prerender/node_modules/phridge/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs

and location.js contains the full path:

module.exports.location = "/tmp/deployment/application/node_modules/prerender/node_modules/phridge/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs"

On my local OSX machine, location.js only contains a partial path:

module.exports.location = "phantom/bin/phantomjs"

I'll look into the code, but is there a reason that it's a full path on linux and a relative path on OSX?

@thoop
Copy link
Contributor

thoop commented Aug 3, 2016

It looks like this commit changed the functionality of the tryPhantomjsInLib function:

85f1d3c?diff=split#diff-f16acefe4b6553580c43edab685f50f3L351

That should take you to the right line in that commit. You'll see that before, tryPhantomjsInLib exited the process if a previous installation was found in the lib folder, leaving the lib/location.js file as-is. In the new version, tryPhantomjsInLib will overwrite the lib/location.js file with a new location set to the absolute path.

The is an edge case that's being run into because Elastic Beanstalk runs:

npm install --production
npm rebuild --production

It normally wouldn't happen, but that rebuild is causing install.js to run a second time, causing tryPhantomjsInLib to overwrite the location with an absolute path (currently in the /tmp directory). Once Elastic Beanstalk moves the application from /tmp/deployment to /var/app/current, that absolute path causes an error where it can't be found anymore.

@nicks is there a reason that change was made besides code cleanup?

@nicks
Copy link
Contributor

nicks commented Aug 3, 2016

maybe? not sure. feel free to send a PR

On Tue, Aug 2, 2016 at 8:09 PM, Todd Hooper notifications@github.com
wrote:

It looks like this commit changed the functionality of the
tryPhantomjsInLib function:

85f1d3c?diff=split#diff-f16acefe4b6553580c43edab685f50f3L351
85f1d3c?diff=split#diff-f16acefe4b6553580c43edab685f50f3L351

That should take you to the right line in that commit. You'll see that
before, tryPhantomjsInLib exited the process if a previous installation
was found in the lib folder, leaving the lib/location.js file as-is. In
the new version, tryPhantomjsInLib will overwrite the lib/location.js
file with a new location set to the absolute path.

The is an edge case that's being run into because Elastic Beanstalk runs:

npm install --production
npm rebuild --production

It normally wouldn't happen, but that rebuild is causing install.js to
run a second time, causing tryPhantomjsInLib to overwrite the location
with an absolute path (currently in the /tmp directory). Once Elastic
Beanstalk moves the application from /tmp/deployment to /var/app/current,
that absolute path causes an error where it can't be found anymore.

@nicks https://github.com/nicks is there a reason that change was made
besides code cleanup?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#583 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AARAcUH0Mk8qLNGxNdJQlmeEwIX9q5Peks5qb9w5gaJpZM4JYYgQ
.

@ponyfleisch
Copy link

For people who need a quick fix for this and can't update yet:

create a file named `.ebextensions/phantomjs.config with the following contents:

commands:
    01-installphantom:
        env:
            PATH: /sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/opt/elasticbeanstalk/node-install/node-v6.2.2-linux-x64/bin/
        command: npm install -g phantomjs-prebuilt

(replace node version with the version you're using)

@nicks nicks closed this as completed Aug 3, 2016
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