ipfs-shipyard / ipfs-deploy

Zero-Config CLI to Deploy Static Websites to IPFS
Other
1.16k stars 123 forks source link

Crash on xsel not available. #211

Closed kevincox closed 3 years ago

kevincox commented 3 years ago

I don't know if this is intended but my CI started failing. I assume this is because it is trying to copy the URL to the clipboard. This behaviour doesn't appear to be documented anywhere (but there is a copyUrl API option).

I would recomend not copying to the clipboard by default because having your clipboard editied is an unexpected default for a random CLI tool. However if that behavious is desired there should be a documented way to disable it.

$ npx ipfs-deploy -p infura results/www >env-hash
npm WARN exec The following package was not found and will be installed: ipfs-deploy
Error: Couldn't find the `xsel` binary and fallback didn't work. On Debian/Ubuntu you can install xsel with: sudo apt install xsel
    at makeError (/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/lib/linux.js:14:11)
    at xselWithFallbackSync (/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/lib/linux.js:43:10)
    at Object.copySync (/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/lib/linux.js:53:3)
    at Object.exports.writeSync (/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/index.js:45:14)
    at copyToClipboard (/root/.npm/_npx/e32067c1c911c14d/node_modules/ipfs-deploy/src/deploy.js:103:16)
    at deploy (/root/.npm/_npx/e32067c1c911c14d/node_modules/ipfs-deploy/src/deploy.js:252:5)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async main (/root/.npm/_npx/e32067c1c911c14d/node_modules/ipfs-deploy/src/cli.js:167:17) {
  fallbackError: Error: Command failed: /root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/fallbacks/linux/xsel --clipboard --input
  /root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/fallbacks/linux/xsel: Can't open display: (null)
  : Inappropriate ioctl for device

      at makeError (/root/.npm/_npx/e32067c1c911c14d/node_modules/execa/index.js:174:9)
      at Function.module.exports.sync (/root/.npm/_npx/e32067c1c911c14d/node_modules/execa/index.js:338:15)
      at xselWithFallbackSync (/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/lib/linux.js:41:17)
      at Object.copySync (/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/lib/linux.js:53:3)
      at Object.exports.writeSync (/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/index.js:45:14)
      at copyToClipboard (/root/.npm/_npx/e32067c1c911c14d/node_modules/ipfs-deploy/src/deploy.js:103:16)
      at deploy (/root/.npm/_npx/e32067c1c911c14d/node_modules/ipfs-deploy/src/deploy.js:252:5)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async main (/root/.npm/_npx/e32067c1c911c14d/node_modules/ipfs-deploy/src/cli.js:167:17) {
    code: 1,
    stdout: '',
    stderr: "/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/fallbacks/linux/xsel: Can't open display: (null)\n" +
      ': Inappropriate ioctl for device\n',
    failed: true,
    signal: null,
    cmd: '/root/.npm/_npx/e32067c1c911c14d/node_modules/clipboardy/fallbacks/linux/xsel --clipboard --input',
    timedOut: false
  }
}
kevincox commented 3 years ago

After further investigation the copy to clipboard was never working but the error was ignored with a warning. Now it fails the deploy.

hacdias commented 3 years ago

@kevincox hmm, that's very odd. Can you try adding the flag -C to see if it fixes it?

After further investigation the copy to clipboard was never working but the error was ignored with a warning. Now it fails the deploy.

Yeah, we were not making use of any errors. I decided that it's best to fail than to hide what's happening. However, this error seems to happen during installation and not runtime so I really don't understand how it is happening now.

However if that behavious is desired there should be a documented way to disable it.

-C. I should add the entire CLI usage on the docs.

I would recomend not copying to the clipboard by default because having your clipboard editied is an unexpected default for a random CLI tool.

I personally also agree with you. The default behavior till v8 was to copy to clipboard and open the browser for you. I already disabled the opening in the web browser because of the same reasons.

I want to keep in mind that this CLI was built to make it very easy for beginners to deploy a website on IPFS so it's arguable whether or not we should disable this kind of features.

Personally, I would disable it by default or remove it entirely. We already print the link to the CLI. In most interactive terminals you can just click on them and access the website. And copying it's not hard either.


Let's just see if that fixes your issue and then see how to proceed.

kevincox commented 3 years ago

I was actually misunderstanding the failure. IPFS deploy was not actually crashing, my CI was just failing due to the logging change from stderr to stdout. This issue can probably be closed, although #213 does look a bit nicer anyways so maybe it is still worth merging.

The real problem that was crashing my CI was https://github.com/ipfs-shipyard/ipfs-deploy/issues/215