question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows Subsystem Linux usage

See original GitHub issue
  • netlify-shortener version:1.0.3
  • node version:10.14.2
  • npm (or yarn) version:6.4.1

Relevant code or config

What you did: tried to run shorten for the npm script netlify-shortener

What happened: got the following error output:

/m/c/U/s/g/netlify-short-urls ⎇ feat/use-netlify-shortner ○
❯ nr shorten                                                                                                                              ⬢ v10.14.2
> netlify-short-urls@1.0.0 shorten /mnt/c/Users/spenc/gitrepos/netlify-short-urls 
> netlify-shortener

committing: format links 
On branch feat/use-netlify-shortner 
Your branch is up to date with 'origin/feat/use-netlify-shortner'.

nothing to commit, working tree clean
pushing 
Everything up-to-date 
/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/clipboardy/lib/linux.js:10 
        throw err;
        ^

Error: xsel: Can't open display: (null) 
: Inappropriate ioctl for device

    at Function.module.exports.sync (/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/execa/index.js:303:26)
    at Object.copySync (/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/clipboardy/lib/linux.js:31:18)
    at Object.exports.writeSync.input [as writeSync] (/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/clipboardy/index.js:38:13)        
    at Object.<anonymous> (/mnt/c/Users/spenc/gitrepos/netlify-short-urls/node_modules/netlify-shortener/dist/index.js:46:12)
    at Module._compile (internal/modules/cjs/loader.js:689:30) 
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
npm ERR! code ELIFECYCLE 
npm ERR! errno 1 
npm ERR! netlify-short-urls@1.0.0 shorten: `netlify-shortener` 
npm ERR! Exit status 1
npm ERR!  
npm ERR! Failed at the netlify-short-urls@1.0.0 shorten script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: 
npm ERR!     /home/scott/.npm/_logs/2019-01-04T08_19_08_897Z-debug.log

/m/c/U/s/g/netlify-short-urls ⎇ feat/use-netlify-shortner ○

Reproduction repository: spences10/netlify-short-urls

Problem description: I’m using WSL so not sure if that is an issue or the fact that I’m on a feature branch and not master

Suggested solution: looking into CD settings on netlify now

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
LekoArtscommented, Jan 16, 2019

Changing the index.js to this made it work on WSL:

#!/usr/bin/env node

/* istanbul ignore file */
"use strict";

const fs = require('fs');

const path = require('path');

const { exec } = require('child_process');

const readPkg = require('read-pkg-up');

const {
  format,
  generateCode,
  commitAndPush,
  validateUrl,
  validateUnique
} = require('./utils');

const {
  pkg: {
    baseUrl = 'https://update-baseUrl-in-your-package.json'
  },
  path: pkgPath
} = readPkg.sync({
  cwd: path.join(__dirname, '../..')
});
const repoRoot = path.dirname(pkgPath);
const redirectPath = path.join(repoRoot, '_redirects');
const [,, longLink, code] = process.argv;
const short = `/${code || generateCode()}`;
const contents = fs.readFileSync(redirectPath, 'utf8');
let newContents = contents;

if (longLink) {
  validateUrl(longLink);
  validateUnique(short, contents);
  newContents = `${short} ${longLink}\n${contents}`;
}

fs.writeFileSync(redirectPath, format(newContents));
commitAndPush(short, longLink, repoRoot);
const link = `${baseUrl}${short}`;
exec(`echo "${link}" | clip.exe`, (err, stdout) => {
  if (err) {
    console.log('Erorr copying the link into your clipboard')
    return
  }
  console.log(`${link} has been copied to your clipboard`);
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

The Ultimate Guide to Windows Subsystem for Linux ...
Learn how to natively work within Linux on Windows 10 with Windows Subsystem for Linux (WSL in Windows) in this HUGE guide!
Read more >
Get started with the Windows Subsystem for Linux - Training
Enable the Windows Subsystem for Linux on your Windows device. · Install a Linux distribution. · Use Linux commands and work across Windows...
Read more >
What is Windows Subsystem for Linux | Microsoft Learn
The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, ...
Read more >
Basic commands for WSL | Microsoft Learn
Install WSL and the default Ubuntu distribution of Linux. Learn more. You can also use this command to install additional Linux distributions by ......
Read more >
Fun with the Windows Subsystem for Linux
At Build 2016, Microsoft introduced to the world the Windows Subsystem for Linux (Beta) [WSL], which enables developers to run native Ubuntu ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found