foundation / foundation-sites

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
https://get.foundation
MIT License
29.65k stars 5.48k forks source link

"foundation new" bug ? (phantomjs) #11112

Closed udf2457 closed 6 years ago

udf2457 commented 6 years ago

I've tried this on different Linux flavours and the problem is consistently reproducible.

  1. sudo npm install --global foundation-cli
  2. foundation new with the follwing options:
    • What are you building today? A website (Foundation for Sites)
    • What's the project called? (no spaces) test
    • Which template would you like to use? ZURB Template: includes Handlebars templates and Sass/JS compilers

The below output is from my attempt on Fedora 27, prior to that I tried Centos 7. It doesn't matter if I install NPM via yum or NPM direct repo.


            .                                                                                                                                  
           /|     ,                                                                                                                            
      , /|/  \/| /|       Thanks for using ZURB Foundation for Sites!                                                                          
     /|/       |/ |       -------------------------------------------                                                                          
 |___|            |___|   Let's set up a new project.                                                                                          
 \___|  ^^   ^^   |___/   It shouldn't take more than a minute.                                                                                
     | -[O]--[O]- |                                                                                                                            
     |    ___,    |                                                                                                                            
     |    ...     |                                                                                                                            
      \__________/                                                                                                                             

Downloading the project template...                                                                                                            
Done downloading!                                                                                                                              

Installing dependencies...                                                                                                                     

> optipng-bin@3.1.4 postinstall /home/foobar/foundation/test/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_m$
dules/optipng-bin                                                                                                                              
> node lib/install.js                                                                                                                          

  ✔ optipng pre-build test passed successfully

> gifsicle@3.0.4 postinstall /home/foobar/foundation/test/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modu
les/gifsicle
> node lib/install.js

  ✔ gifsicle pre-build test passed successfully

> jpegtran-bin@3.2.0 postinstall /home/foobar/foundation/test/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_
modules/jpegtran-bin
> node lib/install.js

  ✔ jpegtran pre-build test passed successfully

> phantomjs-prebuilt@2.1.16 install /home/foobar/foundation/test/node_modules/gulp-uncss/node_modules/uncss/node_modules/phridge/node_modules/phant
omjs-prebuilt
> node install.js

PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Receiving...
  [========================================] 100%
Received 22866K total.
Extracting tar contents (via spawned process)
Error extracting archive
Phantom installation failed { Error: Command failed: tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:554:12)
  killed: false,
  code: 2,
  signal: null,
  cmd: 'tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2' } Error: Command failed: tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_
64.tar.bz2
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:554:12)

> uws@9.14.0 install /home/foobar/foundation/test/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0

> node-sass@4.8.3 install /home/foobar/foundation/test/node_modules/gulp-sass/node_modules/node-sass                                               
> node scripts/install.js          

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.8.3/linux-x64-57_binding.node                                   
Download complete                  
Binary saved to /home/foobar/foundation/test/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-57/binding.node                        
Caching binary to /home/foobar/.npm/node-sass/4.8.3/linux-x64-57_binding.node                                                                      

> node-sass@4.8.3 postinstall /home/foobar/foundation/test/node_modules/gulp-sass/node_modules/node-sass                                           
> node scripts/build.js            

Binary found at /home/foobar/foundation/test/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-57/binding.node                        
Testing binary                     
Binary is fine                     

There were some problems during the installation.                      

 ✓ New project folder created.     
 ✗ Node modules not installed. Try running npm install manually.       
 ✓ Bower components installed.     

Once you've resolved the above issues, run foundation watch while inside the test folder.   
DanielRuf commented 6 years ago

This is solely tied to the phantomjs dependency so I suggest searching there.

Also please try it without sudo.

DanielRuf commented 6 years ago

See https://github.com/Medium/phantomjs/issues/659 for multiple solutions.

DanielRuf commented 6 years ago

So bzip2 is probably missing.

More related issues: https://github.com/Medium/phantomjs/issues?q=is%3Aissue+no+such+file+is%3Aclosed

udf2457 commented 6 years ago

Usage of sudo is as per the reason given in your very own docs. ;)

Thanks for the link to the phantomjs. Will give those a go.

DanielRuf commented 6 years ago

With sudo is not the first recommended way to install it but can be used if there are permission errors and you are not in a elevated commandline session.

https://foundation.zurb.com/sites/docs/installation.html#install-with-foundation-cli

Or where is it explicitely mentioned that users should run it with sudo? We should change the docs then.

DanielRuf commented 6 years ago

Hi @udf2457, did you find a solution?

udf2457 commented 6 years ago

@DanielRuf Yeah, its called Bootstrap 4. :-)

Before I posted here I'd already spent a day trying to figure out the vague error messages coming from "foundation new". So I had to go the competition as it was an urgent requirement. Hopefully Foundation 7 will adopt a little more "fail gracefully" mantra.

But I digress, rant over. I will try to find a moment tomorrow to test again, too busy today.

DanielRuf commented 6 years ago

It is not a bug in Foundation but an issue related to Phantomjs and your environment as it seems so far. The next release will use puppeteer.

SassNinja commented 6 years ago

@DanielRuf Yeah, its called Bootstrap 4. :-)

If installation is your priority and not to have the better framework it may be a solution for you. However as @DanielRuf already pointed out it's not a bug in Foundation but in phantomjs.

You can give it another try by following the link he posted (https://github.com/Medium/phantomjs/issues/659) and install bzip2 before running foundation new

udf2457 commented 6 years ago

@SassNinja @DanielRuf

Not wishing to go all philosophical here, but the sort of attitude displayed here is one of the key stupidities of the whole open source panacea (don't get me wrong I'm a big supporter of open source, but some of the prevalent attitudes are just silly).

In any other world, if your code depends on dependencies then its pure common sense that dependencies further down the tree are not ignored. It makes for a better end-user experience. If you know (I assume is the case here, I have not yet re-tested) phantomjs has a dependency on bzip2 then a one-line addition in the docs (or, better still, the logic incorporated into foundation new) would save a lot of frustration, confusion and wasted debugging time.

But in open source, no.... it just seems its just fine and dandy to include any old third-party dependency and leave it up to the end-user to debug stuff (frequently relying upon obscure and poorly written error messages) when the muck hits the fan.

DanielRuf commented 6 years ago

but some of the prevalent attitudes are just silly

Not sure what you mean. phantomjs is a thirdparty dependency where we have no control over it. bzip2 is a depenendency of it and not known to us that it is required so far. Also we switched to puppeteer in the current develop branch.

dependencies further down the tree are not ignored

Like we already wrote, bzip2 seems to be required by phantomjs or npm to unpack it but this is not an issue with Foundation but with every project that uses phantomjs that you install on your machine.

If you know (I assume is the case here, I have not yet re-tested) phantomjs has a dependency on bzip2

No, we ware not aware of this as so far no one reported a similar issue or they could solve it and searched for the issue in the issues of phantomjs and npm.

phantomjs has a dependency on bzip2 then a one-line addition in the docs

That should be in the phantomjs docs, not ours. Also we do not use phantomjs anymore (the next release scheduled for this month will use puppeteer).

But in open source, no.... it just seems its just fine and dandy to include any old third-party dependency and leave it up to the end-user to debug stuff

So far phantomjs is and was used by many opensource projects and they all face similar issues as phantomjs is not actively maintained anymore and Medium took over but did also not push the further development as Chrome headless finally arrived and now many use Chrome headless solutions.

any old third-party dependency

It is not any, phantomjs is used in many projects and the prebuilt package is not so old.

(frequently relying upon obscure and poorly written error messages) when the muck hits the fan.

The error message comes from npm and phantomjs, not from us. We have no control over the error message of other packages.

Sorry but we are all just people investing our free time to work on opensource projects and it is almost the same even in big projects. If people would pay for it and more people would contribute and help fixing things in the opensource world, then it would look different.

DanielRuf commented 6 years ago

(frequently relying upon obscure and poorly written error messages) when the muck hits the fan.

The error message comes from npm and phantomjs, not from us. We have no control over the error message of other packages.

udf2457 commented 6 years ago

That should be in the phantomjs docs, not ours.

This is exactly the point I'm making !

Who's calling phantomjs ? You are ! Do I have any use for phantomjs outside of whatever foundation new is calling it for ? No, I never even heard of phantomjs before this whole saga came up !

But whatever, hopefully your new puppeteer version will behave better with its dependencies. Until then I'll be staying away from the present version.

DanielRuf commented 6 years ago

Phantomjs is a headless webkit solution and is used for the unit tests so it was part of the devDependencies.

You can manually install foundation-zurb-template without dev dependencies using npm install --only=production

DanielRuf commented 6 years ago

But you can always globally install phantomjs on your path too. Also the bzip2 dependency is still not a thing that we are responsible for. And the fix is easy here: install bzip2 ;-)

DanielRuf commented 6 years ago

Closing as this is not a bug in Foundation or in phantomjs in general as this is just a missing native system dependency in my opinion.