0

These are the contents of my ~/.vscode-server/server-env-setup

function _update_ps1() {
    PS1="$($GOPATH/bin/powerline-go -error $?)"
}
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
   PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

... gives this error

[2019-12-10 13:49:39.763] /mnt/c/Users/cber/.vscode/extensions/ms-vscode-remote.remote-wsl-0.40.3/scripts/wslServer.sh: 1: /home/cber/.vscode-server/server-env-setup: Syntax error: "(" unexpected
[2019-12-10 13:49:39.805] VS Code Server for WSL closed unexpectedly.

UPDATE

This version (stripped of windows line endings) does not produce any errors, but unfortunately also does not display anything in the prompt in a git repo:

GOPATH=$HOME/go
_update_ps1() {
    PS1="$($GOPATH/bin/powerline-go -error $?)"
}
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
   PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
carl
  • 375
  • 4
  • 17
  • Could you try to write `_update_ps1 () { ...` without the `function` keyword and see if it works ? (you need a space between the function name and parenthesis) – Aserre Dec 10 '19 at 14:02
  • Tried it but got a new error message – carl Dec 10 '19 at 14:08
  • Regarding your edit : it seems your variable `$GOPATH` is empty when you are running your script. Also, try running `cat -v ~/.vscode-server/server-env-setup` in a terminal. Do you see special characters like `^M` showing ? – Aserre Dec 10 '19 at 14:11
  • Tried setting GOPATH like so `GOPATH=$HOME/go`, but it doesn't seem to help. Tried running `cat -v` and i see `^M` at the end of each line – carl Dec 10 '19 at 14:27
  • You have windows line endings, which won't work in a unix environment. Try installing `dos2unix` and run `dos2unix ~/.vscode-server/server-env-setup`. You'll have to do that everytime you use a windows softare to save a unix file, unless you configure your editor to use Unix line endings all the time (they work on windows too) – Aserre Dec 10 '19 at 14:52
  • skipping `function` and removing windows line endings seem to help with the errors unfortunately no prompt shows up in a git repo :-( – carl Dec 10 '19 at 15:18
  • As I mentioned in my earlier comment, make sure `GOPATH` is not empty at runtime : try adding `echo "variable : $GOPATH"; [ -f "$GOPATH/bin/powerline-go" ] && echo file is present` just before the `if` test. If you don't see `file is present`, there is a problem with your setup – Aserre Dec 10 '19 at 15:21
  • It outputs `variable : /home/cber/go` and `file is present` – carl Dec 10 '19 at 15:25
  • try running `readlink /proc/$$/exe` in the shell opened by VSCode. If this doesn't show `/bin/bash` (or `/whatever/path/bash`), then `PROMPT_COMMAND` may not necessarily work (it's a bash specific environment variable). If that's the case, either configure VSCode to run `/bin/bash` explicitly (not `/bin/sh`), or try to find the equivalent of `PROMPT_COMMAND` for the shell VSCode is running. – Aserre Dec 10 '19 at 15:34
  • If i put that statement in `server-env-setup` if outputs `/bin/dash`, if i run it in the vs-code terminal i get `/bin/bash` – carl Dec 10 '19 at 15:43
  • what is the value of `echo "$PROMPT_COMMAND"` in your terminal ? – Aserre Dec 10 '19 at 15:46
  • I tried in both `server-env-setup` and the terminal and got empty string in both cases – carl Dec 10 '19 at 15:50
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/203991/discussion-between-aserre-and-carl). – Aserre Dec 10 '19 at 15:51

0 Answers0