Skip to content

VSCode corrupts multi-line environment variables #3928

Closed

Description

On Fedora installations with some packages installed, e.g. environment-modules-3.2.10-16.fc22.x86_64 , scl-utils-2.0.1-3.fc22.x86_64, shell functions are exported in the environment:

$ printenv
…
BASH_FUNC_module()=() {  eval `/usr/bin/modulecmd bash $*`
}
BASH_FUNC_scl()=() {  local CMD=$1;
 if [ "$CMD" = "load" -o "$CMD" = "unload" ]; then
 eval "module $@";
 else
 /usr/bin/scl "$@";
 fi
}

It seems something in VS Code is misparsing or corrupting these variable definitions, because various shell commands (e.g. a build task) then output things like

/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `BASH_FUNC_module'
/bin/sh: scl: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `BASH_FUNC_scl'

before or after their real output. This obviously confuses problem matchers, showOutput and the like.

Activity

  1. added
    linux
    on Mar 10, 2016
  2. Tyriar commented on Mar 22, 2016

    @Tyriar
    Contributor

    I've seen this in the output and when playing with getting Open in Terminal working for Fedora in #4478

  3. added
    bug
    on Mar 22, 2016
  4. Tyriar commented on Mar 23, 2016

    @Tyriar
    Contributor

    Error seems related to the shellshock bug, probably not that though since upgrading to the latest bash didn't change it (bash-4.3.42-3)

  5. Tyriar commented on Mar 24, 2016

    @Tyriar
    Contributor

    Kind of seems like a Fedora issue, it's just strange that it only seems to happen when gnome-terminal is launched through Node.

  6. pflannery commented on Mar 24, 2016

    @pflannery

    been using a fedora kde plasma 5.6 and doesn't have this issue but I had to use PR #3495 to specify konsole as KDE doesn't support the gnome-terminal or x-terminal-emulator out of the box

  7. Tyriar commented on Mar 24, 2016

    @Tyriar
    Contributor

    Running gnome-terminal through gnome-terminal launches a clean terminal:

    image

    It seems to be fine running through regular node too:

    node -e "require('child_process').spawn('gnome-terminal',[],{cwd:'/usr'});"
    
  8. Tyriar commented on Mar 24, 2016

    @Tyriar
    Contributor

    Peter Flannery (@pflannery) do you have the offending lines show up after running env?

    ...
    BASH_FUNC_module()=() {  eval `/usr/bin/modulecmd bash $*`
    }
    BASH_FUNC_scl()=() {  local CMD=$1;
     if [ "$CMD" = "load" -o "$CMD" = "unload" ]; then
     eval "module $@";
     else
     /usr/bin/scl "$@";
     fi
    }
    ...
    
  9. Tyriar commented on Mar 24, 2016

    @Tyriar
    Contributor

    The env variables are added by the environment-modules package which can be removed using:

    sudo dnf remove environment-modules
    

    Not sure what it does or if it's important yet though.

  10. pflannery commented on Mar 24, 2016

    @pflannery

    Daniel Imms (@Tyriar) no it's clean on fedora kde plasma like you last screenshot

  11. Tyriar commented on Mar 24, 2016

    @Tyriar
    Contributor

    Peter Flannery (@pflannery) I mean run something like this and see if there's output:

    env | grep BASH_FUNC_
  12. 11 remaining items

  13. mtrmac commented on Mar 24, 2016

    @mtrmac
    Author

    Browsing the source without having any idea how it is organized, https://github.com/Microsoft/vscode/blob/master/src/vs/base/node/env.ts looks really suspicious (run $SHELL -ilc env, split output by lines).

  14. Tyriar commented on Mar 24, 2016

    @Tyriar
    Contributor

    I think I've found the underlying issue. I reproduced this on Ubuntu:

    1. Export a multi-line environment variable
    ❯ export TEST_ENV_VAR="multi-line
    string"
    
    1. Launch code and inspect process.env in dev tools: TEST_ENV_VAR="multi-line"
  15. Tyriar commented on Mar 24, 2016

    @Tyriar
    Contributor

    Miloslav Trmač (@mtrmac) that looks like it's it! I was suspecting somewhere env was being split by \n.

  16. Tyriar commented on Mar 24, 2016

    @Tyriar
    Contributor

    Got a fix working on Ubuntu & Fedora! Thanks Miloslav Trmač (@mtrmac) Peter Flannery (@pflannery) for the help 🎆

  17. changed the title [-]Error importing function definition for `BASH_FUNC_*'[/-] [+]Error importing function definition for `BASH_FUNC_*' (VSCode corrupts multi-line environment variables)[/+] on Mar 24, 2016
  18. added a commit that references this issue on Mar 25, 2016
    3ed0dfa
  19. changed the title [-]Error importing function definition for `BASH_FUNC_*' (VSCode corrupts multi-line environment variables)[/-] [+]VSCode corrupts multi-line environment variables[/+] on Apr 20, 2016
  20. locked and limited conversation to collaborators on Nov 18, 2017
  21. added 2 commits that reference this issue on Apr 20, 2023
    c950c0d
    8d00125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buglinuxverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions