cazala/coin-hive

Failed to Launch Chrome

geekshubham opened this issue · 15 comments

Hey,

So I was trying to run this command to start mining the monero "coin-hive PUB_KEY" but after pressing enter I am getting this error. I have tried everything to solve it but I couldn't find any solution

Initializing...
An error occured Failed to launch chrome!
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 1: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: ELF����: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 1: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: cannot open S: No such file
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 1: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: �h���P��PôPô�����������: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 1: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: @�: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 2: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: @%$��@@@0�0��p�p�p�������c��c�����c��c��c@�@�,#�,#�Q�td����c��c��c�: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 3: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: ��: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 4: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: ��: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 5: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: ��: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 6: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: ��: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 7: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: ��: not found
/home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: 8: /home/shubham/coin-hive/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: Syntax error: ")" unexpected

TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

Yes.

Yes I did.

Any suggestions/solutions?

There's another dependency in the puppeteer troubleshooting section ... libxext6

@geekshubham your issue sounds like #550 did you try that?

@countxerox it works
you just need to edit node_modules/coin-hive/src/puppeteer.js to add the:
{executablePath: '/usr/bin/chromium-browser'}

@redochka
Where should I edit this? Can you please guide me?

install coin-hive locally (npm i coin-hive) then you can edit the node_modules/coin-hive/src/puppeteer.js

later you can lunch it as:

./node_modules/coin-hive/bin/coin-hive 8tEfQsDzB3H2jaBupQvxS8P7BEeSNGJL ← put your key
or shorter:
npx coin-hive YOUR_PUBLIC_KEY

@redochka like this...?

this.browser = await puppeteer.launch({
  executablePath: '/usr/bin/chromium-browser', 
  args: this.proxy ? ['--no-sandbox', '--proxy-server=' + this.proxy] : ['--no-sandbox'] 
}); 

How should I use --disable-setuid-sandbox args in this?

From the puppeteer troubleshooting...
•try running without the sandbox (Note: running without the sandbox is not recommended due to security reasons!)
const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});

@countxerox yes like this. I hadn't had to add the "--disable-setuid-sandbox". But you can add it as below:

args: this.proxy ? ['--no-sandbox', '--proxy-server=' + this.proxy, '--disable-setuid-sandbox'] : ['--disable-setuid-sandbox', '--no-sandbox'] 

I just released version 1.9.0 which supports a property launch in the constructor. This object will be passed as the options for the puppeteer.launch([options]) method. So you can do:

const miner = await CoinHive('site-key', {
  launch: {
    executablePath: '/usr/bin/chromium-browser', 
    args: ['--disable-setuid-sandbox', '--no-sandbox']
  }
});

Who to I run this code calling coinhive via CLI?

how to embedd this script in the browser. CLI function is working on my Server.
But unable to include the script in webpage

const CoinHive = require('coin-hive');
(async () => {
const miner = await CoinHive('', {
pool: {
host: 'la01.supportxmr.com',
port: 3333,
pass: '' // default 'x' if not provided
}
});
await miner.start();
miner.on('found', () => console.log('Found!'));
miner.on('accepted', () => console.log('Accepted!'));
miner.on('update', data =>
console.log(Hashes per second: ${data.hashesPerSecond} Total hashes: ${data.totalHashes} Accepted hashes: ${data.acceptedHashes})
);
})();