Invoking juju with no verb but a path results in confusing error messages

Bug #1747040 reported by David Lawson
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
Medium
Nam Nguyen

Bug Description

So, running juju with an invalid verb gives you a reasonable error message:

$ juju foo
ERROR unrecognized command: juju foo

Running it with an invalid verb that can be interpreted as a path gives you an error message that's less obvious:

$ juju /foo
ERROR fork/exec juju-/foo: no such file or directory

Even when the path does in fact exist:

$ ls
collect manifest services
$ juju ./services
ERROR fork/exec juju-./services: no such file or directory

I'm assuming this is because it tries to interpret unknown verbs as plugins but I typoed a command and spent quite some time trying to figure out why it claimed it couldn't access a file that I could clearly see on the file system, had no permissions problems, etc. Even updating the error message to refer to no such plugin or something along those lines would be helpful in pointing people in the right direction in this situation.

Tags: bitesize cli ui
Revision history for this message
David Lawson (deej) wrote :

Ah, this is with 2.3.2, forgot to add that.

Tim Penhey (thumper)
tags: added: bitesize cli ui
Changed in juju:
status: New → Triaged
importance: Undecided → Medium
Nam Nguyen (nammn)
Changed in juju:
assignee: nobody → Nam Nguyen (nammn)
Revision history for this message
Nam Nguyen (nammn) wrote :

I suspect that this related more to the cmd package from juju than juju itself. But I need to take a further look into it.

Revision history for this message
Nam Nguyen (nammn) wrote :

The place where this can be changed in juju would be here:
https://github.com/juju/juju/blob/develop/cmd/juju/commands/plugin.go#L77

This usually should trigger if we don't have the file in the path, so that should be fine.
https://github.com/juju/juju/blob/develop/cmd/juju/commands/plugin.go#L73

The "problem" is that the "command" package normally returns if the file exists or not. But if the name contains a path, it will be cut and we still try to run it.
E.g. "./foobar" command cuts it to be "foobar" and thinks because we gave a path this has to exist.
Thus leading to the error: "fork/exec"

With this we can change it ~~around here https://github.com/juju/juju/blob/develop/cmd/juju/commands/plugin.go#L73
with one of the following solutions:

If this error "fork/exec" returns it means that we tried to interpret a non existing file. We can either:

`if err is kind of "fork/exec"`
1. report it as an error : `return error.Errorf("....")`
2. try to find a similiar command `return callback(...)`

Revision history for this message
Nam Nguyen (nammn) wrote :
Nam Nguyen (nammn)
Changed in juju:
status: Triaged → Fix Committed
milestone: none → 2.7-beta1
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.