Skip to content

Can‘t attach remote linux process - sh failure #2444

Closed

Description

Type: Debugger
Input information below

image

sh: 1: [: Linux: unexpected operator
sh: 1: [: Linux: unexpected operator
please help me to solve this issue.
thanks.

Describe the bug

  • OS and Version: Windows 10 1803
  • VS Code Version: 1.26.1
  • C/C++ Extension Version: 0.18.0: August 17, 2018
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is.

To Reproduce
Please include a code sample and launch.json configuration.
Steps to reproduce the behavior:
build the test and run it on ubuntu16.04.
Open the test code and Debug with attach.

Note: It works well about previous version.

Here the demo code.

test.zip

Activity

  1. Thanduel commented on Aug 24, 2018

    @Thanduel

    I have the same issue.

    my versions

    • Windows 10 1803 build 17134.228
    • vs code version 1.26.1
    • C/C++ Extension Version: 0.18.1

    I noted that the behaviour is changed by removing the pipeArg -c. What follows is the ouput in that case. I'm not really sure what is going on there but it does appear that the sh call has the -c arg even though it has been removed from the pipeArgs.

    /bin/bash: sh -c 'uname && if [ Linux == Linux ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ Linux == Darwin ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi': No such file or directory
    Command failed: "c:\windows\system32\bash.exe"  "sh -c 'uname && if [ $(uname) == "Linux" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) == "Darwin" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi'"
    /bin/bash: sh -c 'uname && if [ Linux == Linux ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ Linux == Darwin ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi': No such file or directory
    

    Launch.json:

    {
               "name": "C++ Attach",
               "type": "cppdbg",
               "request": "attach",
               "program": "/mnt/s/Work/repositories/ardupilot/ardupilot/build/sitl/bin/arduplane",
               "processId": "${command:pickRemoteProcess}",
               "windows": {
                   "MIMode": "gdb",
                   "setupCommands": [
                       {
                           "description": "Enable pretty-printing for gdb",
                           "text": "-enable-pretty-printing",
                           "ignoreFailures": true
                       }
                   ]
               },
               "pipeTransport": {
                   "pipeCwd": "",
                   "pipeProgram": "c:\\windows\\sysnative\\bash.exe",
                   "pipeArgs": ["-c"],
                   "debuggerPath": "/usr/bin/gdb"
               },
               "sourceFileMap": {
                   "/mnt/s": "s:\\"
               }
           }
    
  2. XZiar commented on Aug 26, 2018

    @XZiar

    Same issue here.
    output is:

    Linux
    sh: 1: [: Linux: unexpected operator
    sh: 1: [: Linux: unexpected operator

    Windows 10 1803 build 17134.228
    vs code version 1.26.1
    C/C++ Extension Version: 0.18.1

  3. czgtest commented on Aug 29, 2018

    @czgtest

    Same issue here when I debug c module solution

  4. formulahendry commented on Aug 29, 2018

    @formulahendry
    Member

    Same issue here using C/C++ Extension Version: 0.18.1, while it is working using 0.17.7.

  5. changed the title [-]Can‘t attach remote linux process on Windows[/-] [+]Can‘t attach remote linux process on Windows - sh failure[/+] on Aug 31, 2018
  6. changed the title [-]Can‘t attach remote linux process on Windows - sh failure[/-] [+]Can‘t attach remote linux process - sh failure[/+] on Aug 31, 2018
  7. pieandcakes commented on Aug 31, 2018

    @pieandcakes
    Contributor

    This seems to be affecting all instances of remote process picking due to this change #2340

  8. pieandcakes commented on Aug 31, 2018

    @pieandcakes
    Contributor

    Matt (@timedroid) pointed out what is wrong in #2473 and a fix.

    In the mean time the workaround would be to modify
    .vscode\extensions\ms-vscode.cpptools-0.17.7\out\src\Debugger\attachToProcess.js located in your user profile folder (%userprofile% for Windows, ~/ for Linux).

    Update line 92/93 to say:

            const command = `sh -c 'uname && if [ $(uname) = "Linux" ] ; then ${nativeAttach_1.PsProcessParser.psLinuxCommand} ; elif [ $(uname) = "Darwin" ] ; ` +
                `then ${nativeAttach_1.PsProcessParser.psDarwinCommand}; fi'`;
    
    

    The fix will be in the next update.

  9. added a commit that references this issue on Aug 31, 2018
    81621a8
  10. added a commit that references this issue on Aug 31, 2018
    ecd3eb2
  11. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on Aug 31, 2018
  12. added a commit that references this issue on Sep 18, 2018
    aa95fc2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugdebuggerfixedCheck the Milestone for the release in which the fix is or will be available.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions