ipfs / npm-kubo

Install Kubo (go-ipfs) from NPM
https://www.npmjs.com/package/kubo
MIT License
41 stars 30 forks source link

Platform architecture is undefined when trying to install #49

Open adamalton opened 2 years ago

adamalton commented 2 years ago

v18.4.0 (npm v8.12.1).

I encountered this while trying to install ipns-publisher (which has go-ipfs as a dependency) on my M1 Mac. But the issue happens even just trying to do npm install go-ipfs:

$ npm install go-ipfs
npm WARN deprecated go-ipfs@0.10.0: Version no longer supported. Upgrade to 0.12.2 or later.
npm ERR! code 1
npm ERR! path /Users/adamalton/Sites/github/ipns-publisher/node_modules/go-ipfs
npm ERR! command failed
npm ERR! command sh -c node src/post-install.js
npm ERR! https://dist.ipfs.io/go-ipfs/versions
npm ERR! Error: No binary available for arch 'undefined'
npm ERR!     at getDownloadURL (/Users/adamalton/Sites/github/ipns-publisher/node_modules/go-ipfs/src/download.js:162:11)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR!     at async download (/Users/adamalton/Sites/github/ipns-publisher/node_modules/go-ipfs/src/download.js:178:15)
npm ERR!     at async module.exports (/Users/adamalton/Sites/github/ipns-publisher/node_modules/go-ipfs/src/download.js:251:13)

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/adamalton/.npm/_logs/2022-07-12T14_47_37_653Z-debug-0.log

So the problem seems to be coming from here: https://github.com/ipfs/npm-go-ipfs/blob/8b0e3d947f0af11a8704760f1f78d7b8a02324aa/src/download.js#L126

However, this works fine:

$ node
> process.arch
'arm64'

And running this successfully works around the problem:

TARGET_ARCH='arm64' npm install

It looks like this is a problem with go-platform. If I install and run it on its own (as per the instructions in its README) I get:

$ node_modules/.bin/go-platform
darwin-undefined

I've opened an issue on that repo, but logging this ticket here so that:

  1. Other people experiencing this problem can see the workaround.
  2. If the issue doesn't get fixed in go-platform (which was last updated 7 years ago) we can look at an alternative for this repo.