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.

--app command with no arguments

See original GitHub issue

CDK doesn’t support executing a command with no arguments to run an app. Suppose that “foobar” is an executable in your $PATH. The following command doesn’t work as expected:

$ cdk --app "foobar" ls

ENOENT: no such file or directory, stat 'foobar'

while the command below works:

$ cdk --app "foobar arg" ls

You can reproduce this behavior with any executable. For instance:

$ cdk --app "cp" ls

and

$ cdk --app "cp /path1 /path2" ls

On the other hand, if the executable doesn’t exist for real, the error is:

/bin/sh: foobar: command not found
Subprocess exited with error 127

The same goes if the “no argument” app is specified in the cdk.json configuration file instead of the command line.

{
  "app": "foobar"
}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
philtaycommented, Apr 3, 2020

Thank you @shivlaks. That’s a perfectly fine solution. If possible, please also add a unit test. These things are a little tricky and it’s easy to introduce a regression.

1reaction
philtaycommented, Apr 1, 2020

@shivlaks thanks a lot for looking into this. Whatever mimics golang LookPath would do. Using the suggested package the guessExecutable function would look something like this:

async function guessExecutable(commandLine: string[]) {
  if (commandLine.length === 1) {
    const exec = await lookpath(commandLine[0]);

    if (!exec) {
      return commandLine;
    }

    const fstat = await fs.stat(exec);
    // tslint:disable-next-line:no-bitwise
    const isExecutable = (fstat.mode & fs.constants.X_OK) !== 0;
    const isWindows = process.platform === "win32";
    const handler = EXTENSION_MAP.get(path.extname(exec));

    if (handler && (!isExecutable || isWindows)) {
      return handler(exec);
    }
  }

  return commandLine;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run a program with no arguments - bash - Stack Overflow
How to run a program with no arguments · 1. just typing ./a. · @Stefan no, by default the shell passes one argument...
Read more >
set command with no arguments - bash - Ask Ubuntu
I happened to issue the command set and it seems to "cat" a script to the console.
Read more >
Unix command that takes no arguments [closed]
nologin takes no arguments and is widely available on Linux and BSD. On CentOS 4 and 5, the arch command takes no arguments....
Read more >
How can I run an application with command line arguments in ...
Starting in OS X 10.6.2, the open command can pass arguments to the ... "open -a /Applications/Firefox.app --args -P default -no-remote".
Read more >
Main() and command-line arguments | Microsoft Learn
The Main method is the entry point of a C# application. (Libraries and services do not require a Main method as an entry...
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