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.

Run-Commands: Arguments are incorrectly appended when using multiple commands

See original GitHub issue

Current Behavior

When attempting to run multiple commands with arguments as shown in the docs, there are two scenarios:

  1. Commands that use argument(s):
    • These run fine and are parsed correctly assuming you use {args.some_arg}
  2. Commands that do not use argument(s):
    • These commands always get the raw arguments appended to it
    • Ex: Passing the argument --name=testing, the command mkdir scripts would actually run mkdir scripts --name=testing
    • This can cause commands to fail
  • Note: This became a problem for us after upgrading Nx from 9.3.0 to 9.5.1.

Expected Behavior

Commands that do not use arguments should not have raw arguments appended to them as it can cause them to fail.

Steps to Reproduce

https://github.com/nrwl/nx-examples/pull/109

Failure Logs

Reference repro PR.

Environment

@nrwl/angular : Not Found @nrwl/cli : 9.5.1 @nrwl/cypress : 9.5.1 @nrwl/eslint-plugin-nx : 9.5.1 @nrwl/express : Not Found @nrwl/jest : 9.5.1 @nrwl/linter : 9.5.1 @nrwl/nest : 9.5.1 @nrwl/next : 9.5.1 @nrwl/node : 9.5.1 @nrwl/react : 9.5.1 @nrwl/schematics : Not Found @nrwl/tao : 9.5.1 @nrwl/web : 9.5.1 @nrwl/workspace : 9.5.1 typescript : 3.8.3

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
vsavkincommented, Jul 22, 2020

There are two separate scenarios run-commands is used for:

  1. Orchestrating multiple command invocation. Here interpolation makes total sense.
  2. Wrapping a tool (e.g., webpack). Here you want all parameters to be passed through. Your intend here is to use the tool, but you want to do it via Nx so caching works etc…

I see the following options:

  1. Keep the current behavior and add an option to not-forward:
{
    command: 'some command',
    forwardAllArgs: false
} 
  1. Default arg forwarding to false and have an option to forward:
{
    command: 'some command',
    forwardAllArgs: true
} 

I think when using command (singular), forwarding by default is what you want.

       "build": {
          "builder": "@nrwl/workspace:run-commands",
          "options": {
            "command": "webpack"
          }
        }

There is not reason not to forward. You are wrapping another tool here. For multiple commands, not forwarding is probably more reasonable–cause args won’t align.

Maybe we can introduce forwardAllArgs option, default it to false when using “commands” (plural).

What do you think?

0reactions
cliffmeyerscommented, Oct 8, 2020

I would love to see this backported to 9.x. As far as I can tell it’s not supported in 9.7.0:

An unhandled exception occurred: Schema validation failed with the following errors:
  Data path ".commands[0]" should NOT have additional properties(forwardAllArgs).
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I run two commands in one line in Windows CMD?
This problem can be resolved by using the Delayed Expansion feature (only available in batch files though). So try the following inside a...
Read more >
How To Run Multiple Commands In Parallel on Linux
In case you need to execute several processes in batches, or in chunks, you can use the shell builtin command called "wait". See...
Read more >
Automatically run commands over SSH on many servers
I'll be using public key authentication on all the servers. Here are some potential pitfalls: The ssh prompts me to put the given...
Read more >
Invoke-Command (Microsoft.PowerShell.Core)
Using a single Invoke-Command command, you can run commands on multiple computers. To run a single command on a remote computer, use the...
Read more >
Systems Manager Command document plugin reference
These parameters provide another view when listing metrics. You can use the same dimension for multiple metrics so that you can view all...
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