Skip to content

Command line arguments not working as expected #15435

Closed

Description

@aniljava

As per, issue #6484 (closed), the command line arguments such as -h, should work with the
current version of VS Code. But does not work as expected in normal ubuntu installation.

Binary being used:

    /usr/bin/code -> /usr/share/code/bin/code
  • VSCode Version:

      Version 1.7.1
      Commit 02611b40b24c9df2726ad8b33f5ef5f67ac30b44
      Date 2016-11-03T13:46:46.244Z
      Shell 1.3.8
      Renderer 52.0.2743.82
      Node 6.5.0
    
  • OS Version:

     Distributor ID:  Ubuntu
     Description: Ubuntu 16.04.1 LTS
     Release: 16.04
     Codename:    xenial
    

Steps to Reproduce:

code --user-data-dir=/ws/linux/config/vscode/ /root/.bashrc
code --user-data-dir=/ws/linux/config/vscode/ --help
code --user-data-dir=/ws/linux/config/vscode/ /var/logs

None of the above shows any help or open path as expected.

Activity

  1. aniljava commented on Nov 14, 2016

    @aniljava
    ContributorAuthor

    Updates:

    After a short digging around, either the main executable at /usr/share/code/bin/code is
    ignoring other arguments, including --user-data-dir when ELECTRON_RUN_AS_NODE=1 is
    present. Or $VSCODE_PATH/resources/app/out/cli.js is supressing or not using the other args.

    When the bash startup script, /usr/share/code/bin/code is used, there is no effect of
    arguments including path to open as well as other args like --help. The user-data-dir is
    not created when --user-data-dir is passed.

    Whereas, when the main executable (/usr/share/code/code) is used, it looks like the
    arguments are passed and processed correctly. path to open, --new-window, -r are working
    as expected. But i guess the absence of $VSCODE_PATH/resources/app/out/cli.js, is
    causing causing the writing back to starting shell fail. Following errors are shown when
    using main executable.

    bash: cannot set terminal process group (-1): Inappropriate ioctl for device
    bash: no job control in this shell
    
  2. joaomoreno commented on Nov 14, 2016

    @joaomoreno
    Contributor

    Strange. I just tried, but failed to reproduce. We'd need to debug the CLI code on your machine. Any chance that it's a VM you could send us?

  3. added
    info-needed
    on Nov 14, 2016
  4. aniljava commented on Nov 14, 2016

    @aniljava
    ContributorAuthor

    Not a vm. But if there are switches or edits that i can do to enable trace, i can run with trace on and share the output. I also tried apt-get remove --purge code and used the tar.gz version, same problem.

    Any chances that there might be a conflict with existing electron installation ?

  5. joaomoreno commented on Nov 14, 2016

    @joaomoreno
    Contributor
  6. added a commit that references this issue on Nov 14, 2016
  7. aniljava commented on Nov 14, 2016

    @aniljava
    ContributorAuthor

    I think i found the root cause, can you share your startup script, may be we are using
    different version that it is working on your end.

    The script is shifting and throwing away all args when used as root to check --user-data-dir.

    if [ "$(id -u)" = "0" ]; then
        while test $# -gt 0
        do
            if [[ $1 == --user-data-dir=* ]]; then
                DATA_DIR_SET=1
            fi
            shift
        done
        if [ -z $DATA_DIR_SET ]; then
            echo "It is recommended to start vscode as a normal user. To run as root, you must specify an alternate user data directory with the --user-data-dir argument." 1>&2
            exit 1
        fi
    fi
    

    Just submitted a pull request with changes that retains and passes the commandline args.

  8. joaomoreno commented on Nov 14, 2016

    @joaomoreno
    Contributor

    Great to know. Moving this to Daniel Imms (@Tyriar), he should know the details of that script. 👍

    Great work, thanks for the effort! 🍻

  9. added
    bug
    linux
    and removed
    info-needed
    on Nov 14, 2016
  10. Tyriar commented on Nov 14, 2016

    @Tyriar
    Contributor

    Fixed in #15448

  11. added
    verification-needed
    on Dec 5, 2016
  12. roblourens commented on Dec 8, 2016

    @roblourens
    Member

    Verified: sudo code --user-data-dir=./codedir --help ignores --help. sudo code-insiders --user-data-dir=./codedir --help does not ignore it.

  13. added
    verified
    on Dec 8, 2016
  14. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buglinuxverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions