Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing command-line arguments in 1.3.0 #1647

Closed
nunofgs opened this issue Dec 11, 2016 · 7 comments

Comments

Projects
None yet
3 participants
@nunofgs
Copy link

commented Dec 11, 2016

What were you doing?

Attempting to run version 1.3.0 in a Docker container. Here's an example Dockerfile:

FROM python:2.7-slim

RUN apt-get update \
  && apt-get install -y build-essential git \
  && git clone -b 1.3.0 https://github.com/foosel/OctoPrint.git \
  && cd OctoPrint \
  && python setup.py install

CMD ["octoprint"]

What did you expect to happen?

When running octoprint --help I expect to see the usage message.

What happened instead?

# octoprint --help
Usage: octoprint [OPTIONS] COMMAND [ARGS]...

Error: Invalid value for "--version": 1.3.0 is not a valid boolean

Running without arguments also yields the same result.

Branch & Commit or Version of OctoPrint

1.3.0

Printer model & used firmware incl. version

Not applicable.

Browser and Version of Browser, Operating System running Browser

Docker on x86 as well as arm (a raspberry pi).

Link to octoprint.log

Not applicable.

Link to contents of terminal tab or serial.log

Not applicable.

Link to contents of Javascript console in the browser

Not applicable.

Screenshot(s) showing the problem:

Not applicable.

I have read the FAQ.

@nunofgs nunofgs changed the title Error parsing command-line arguments Error parsing command-line arguments in v1.3.0 Dec 11, 2016

@nunofgs nunofgs changed the title Error parsing command-line arguments in v1.3.0 Error parsing command-line arguments in 1.3.0 Dec 11, 2016

@GitIssueBot

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2016

Hi @nunofgs,

It looks like there is some information missing from your bug report that will be needed in order to solve the problem. Read the Contribution Guidelines which will provide you with a template to fill out here so that your bug report is ready to be investigated (I promise I'll go away then too!).

If you did not intend to report a bug but wanted to request a feature or brain storm about some kind of development, please take special note of the title format to use as described in the Contribution Guidelines.

Please do not abuse the bug tracker as a support forum - if you have a question or otherwise need some kind of help or support refer to the Mailinglist or the G+ Community instead of here.

Also make sure you are at the right place - this is the bug tracker of the official version of OctoPrint, not the Raspberry Pi image OctoPi nor any unbundled third party OctoPrint plugins or unofficial versions. Make sure too that you have read through the Frequently Asked Questions and searched the existing tickets for your problem - try multiple search terms please.

I'm marking this one now as needing some more information. Please understand that if you do not provide that information within the next two weeks (until 2016-12-25 22:10 UTC) I'll close this ticket so it doesn't clutter the bug tracker. This is nothing personal, so please just be considerate and help the maintainers solve this problem quickly by following the guidelines linked above. Remember, the less time the devs have to spend running after information on tickets, the more time they have to actually solve problems and add awesome new features. Thank you!

Best regards,
~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being, so don't expect any replies from me :) Your ticket is read by humans too, I'm just not one of them.

@foosel

This comment has been minimized.

Copy link
Owner

commented Dec 12, 2016

Testing the same command on OctoPi:

(oprint)pi@octopi:~/OctoPrint $ octoprint --help
Usage: octoprint [OPTIONS] COMMAND [ARGS]...

Options:
  -b, --basedir PATH  Specify the basedir to use for uploads, timelapses etc.
  -c, --config PATH   Specify the config file to use.
  -v, --verbose       Increase logging verbosity
  --safe              Enable safe mode; disables all third party plugins
  --version           Show the version and exit.
  --help              Show this message and exit.

Commands:
  client   Basic API client.
  config   Basic config manipulation.
  daemon   Starts, stops or restarts in daemon mode.
  dev      Additional commands for development tasks.
  plugins  Additional commands provided by plugins.
  serve    Starts the OctoPrint server.

Same behaviour on any other checkout, regardless of OS.

Also tried a replication of your exact checkout & install steps. Differences being: no docker, virtual environment:

$ git clone -b 1.3.0 https://github.com/foosel/OctoPrint.git OctoPrint-1.3.0-Test && cd OctoPrint-1.3.0-Test && virtualenv venv && source ./venv/bin/activate && python setup.py install
[...]
$ octoprint --help
Usage: octoprint [OPTIONS] COMMAND [ARGS]...

Options:
  -b, --basedir PATH  Specify the basedir to use for uploads, timelapses etc.
  -c, --config PATH   Specify the config file to use.
  -v, --verbose       Increase logging verbosity
  --safe              Enable safe mode; disables all third party plugins
  --version           Show the version and exit.
  --help              Show this message and exit.

Commands:
  client   Basic API client.
  config   Basic config manipulation.
  daemon   Starts, stops or restarts in daemon mode.
  dev      Additional commands for development tasks.
  plugins  Additional commands provided by plugins.
  serve    Starts the OctoPrint server.

The error sounds like something seriously messed up the command line arguments here.

Now, I have to admit that I'm completely unfamiliar with Docker, and especially how it works internally, but could it be that it's doing something in its environmental setup or they way the actual executable gets called that's messing with things here?

I played around a bit with things and finally could reproduce the exact error message:

$ OCTOPRINT_VERSION=1.3.0 octoprint --help
Usage: octoprint [OPTIONS] COMMAND [ARGS]...

Error: Invalid value for "--version": 1.3.0 is not a valid boolean

Could it be that such an environment variable is set by Docker, causing the issues here? Should be easy enough to check with CMD ["env"] if I understand things right. If so, that would be the reason. Click (which is what I use for argument parsing) here is set up to also take arguments from the environment, prefixed with OCTOPRINT_. Apparently it also does that for the flag-parameter version (which I'll have to see if I can prevent that from happening), causing this issue. The question though would be via such an environment variable would even be set in the container in the first place.

foosel added a commit that referenced this issue Dec 12, 2016

Do not have CLI interpret OCTOPRINT_VERSION env var
--version is a flag, not an actual parameter (wouldn't really make sense
too). I'm not sure why that isn't the default behaviour of the built-in
version_option decorator tbh.

See #1647
@foosel

This comment has been minimized.

Copy link
Owner

commented Dec 12, 2016

For the record, with above commit I cannot reproduce anymore:

$ OCTOPRINT_VERSION=1.3.0 octoprint --help
Usage: octoprint [OPTIONS] COMMAND [ARGS]...

Options:
  -b, --basedir PATH  Specify the basedir to use for uploads, timelapses etc.
  -c, --config PATH   Specify the config file to use.
  -v, --verbose       Increase logging verbosity
  --safe              Enable safe mode; disables all third party plugins
  --version           Show the version and exit.
  --help              Show this message and exit.

Commands:
  client   Basic API client.
  config   Basic config manipulation.
  daemon   Starts, stops or restarts in daemon mode.
  dev      Additional commands for development tasks.
  plugins  Additional commands provided by plugins.
  serve    Starts the OctoPrint server.

That is available on the maintenance branch and will be released with 1.3.01.3.1.

Would still be important to know if that was actually the reason behind this in the Docker environment and why that var was even set.

@foosel foosel added this to the 1.3.1 milestone Dec 12, 2016

@foosel

This comment has been minimized.

Copy link
Owner

commented Dec 14, 2016

@nunofgs could you report back on if the above fix works for you?

@nunofgs

This comment has been minimized.

Copy link
Author

commented Dec 15, 2016

@foosel: confirmed. Works perfectly for me!

@foosel

This comment has been minimized.

Copy link
Owner

commented Dec 15, 2016

Perfect, marking this as solved then, will be released with 1.3.1 as already mentioned.

@foosel

This comment has been minimized.

Copy link
Owner

commented Jan 25, 2017

Part of 1.3.1 which has just been released.

@foosel foosel closed this Jan 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.