kevva / download

Download and extract files
MIT License
1.28k stars 200 forks source link

"Undefined is not a function" error #58

Closed piranna closed 9 years ago

piranna commented 9 years ago
buffer.js:203
    buf.copy(buffer, pos);
        ^
TypeError: undefined is not a function
    at Function.Buffer.concat (buffer.js:203:9)
    at DuplexWrapper.<anonymous> (/home/piranna/Proyectos/NodeOS/node_modules/nodeos-barebones/node_modules/nodeos-cross-toolchain/node_modules/download/node_modules/read-all-stream/index.js:35:21)
    at DuplexWrapper.g (events.js:199:16)
    at DuplexWrapper.emit (events.js:129:20)
    at /home/piranna/Proyectos/NodeOS/node_modules/nodeos-barebones/node_modules/nodeos-cross-toolchain/node_modules/download/node_modules/stream-combiner2/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_readable.js:934:16
    at process._tickCallback (node.js:355:11)

I get this each time that I try to use it, seems Buffer object don't have a copy() method. I'm using Node.js 0.12.0, if that matters... The script is the same as yesterday.

kevva commented 9 years ago

How does your code look?

kevva commented 9 years ago

Fixed in 4.1.2.

piranna commented 9 years ago

Now it doesn't crash, but only got extracted the first one, the others are stored in compresed form, it's extrange...

piranna commented 9 years ago
deps/binutils:
binutils-2.24.tar.gz

deps/gcc:
gcc-4.7.3.tar.gz

deps/linux:
linux-4.0-rc5.tar.gz

deps/musl:
arch       COPYRIGHT  dist     INSTALL  Makefile  src    VERSION
configure  crt        include  lib      README    tools  WHATSNEW
kevva commented 9 years ago

This works fine for me so it must be something in your code.

new Download({extract: true, strip: 1})
    .get('https://github.com/imagemin/mozjpeg-bin/archive/master.tar.gz', 'a')
    .get('https://github.com/imagemin/optipng-bin/archive/master.tar.gz', 'b')
    .run();
piranna commented 9 years ago

I will need to check it later but it's the same code as always, and it was decompressing it correctly before...

piranna commented 9 years ago

Disabling the usage of download-status it decompress them correctly, but it crashed with an EACCESS error when it found the @Longlink entry on gcc. I'll fill the issue on tar-stream (forgot to do it yesterday...)

piranna commented 9 years ago

https://github.com/mafintosh/tar-stream/issues/35

piranna commented 9 years ago

Problem confirmed:

#!/usr/bin/env node

var Download = require('download');
var progress = require('download-status');

// Source versions

const NODEJS_VERSION = "v0.11.14"

// Source URLs

const NODEJS_URL="http://nodejs.org/dist/"+NODEJS_VERSION+"/node-"+NODEJS_VERSION+".tar.gz"

Download({ extract: true, strip: 1 })
.get(NODEJS_URL, 'deps/node')
//.use(progress())
.run(function(error)
{
  if(error) throw error;

  console.log('Download finished!');
})

When the line //.use(progress()) is commented, I get the next error as I notified in the tar-stream issue:

/home/piranna/Proyectos/NodeOS/node_modules/nodeos-barebones/scripts/preinstall.js:24
  if(error) throw error;
                  ^
Error: EACCES, open '/home/piranna/Proyectos/NodeOS/node_modules/nodeos-barebones/deps/node/@LongLink'
    at Error (native)

but when uncommented, the file don't get extracted and it's stored the compressed one, so there should be there a conflict.