5

I’m using VS Code 1.60.2 for Mac Big Sur. I have my Rails 4 instance running in a virtual machine (vagrant container) and I would like to configure the VS Code debugger. From my local terminal, I could start the server from a shell using the following script …

#!/bin/sh

ssh -t myvirtual.dev "exec bash --login -c 'foreman start -f Procfile.debug'"

So in my .vscode/launch.json file, I configured this

{
  "configurations": [
    {
      "name": "Rails server",
      "type": "Ruby",
      "request": "launch",
      "program": "/opt/scripts/start_web.sh",
      "args": [
      ]
    },

However, when I restart vs code, click the “Run/Debug” icon from the left, and click the “Run” icon next to “Rails server”, I get this error in the terminal …

Uncaught exception: /opt/scripts/start_web.sh:3: syntax error, unexpected tIDENTIFIER, expecting do or '{' or '('
ssh -t myvirtual.dev "exec bash --login -c 'f...

My virtual container has port 3000 exposed, but not sure what else to do to get the debugger configured properly.

Dave
  • 15,639
  • 133
  • 442
  • 830
  • is that wrong copy/paste or you really have wrong quote and double quote character in your command script `ssh -t myvirtual.dev "exec bash --login -c 'foreman start -f Procfile.debug’”` last 2 characters looks like you copy quote/double quote from rich text editor such as word or something. – Frederic Henri Sep 27 '21 at 19:01
  • Good catch, but yeah it's a bad cut and paste -- I wrote the question in Mac TextEdit and it transposed some chars taht I forgot to transpose back when pasting it into SO – Dave Sep 28 '21 at 22:08
  • ok but that's definitely something in this line, do u have a GitHub repo with the Vagrantfile config and script to easily replicate ? – Frederic Henri Sep 29 '21 at 06:57
  • It's not even getting that far. Even without vagrant installed, this issue can still be replicated because for some reason, VS code is not interpreting the "program" command in the launch.json file properly (it errors with "Uncaught exception: /opt/scripts/start_web.sh:3: syntax error, unexpected tIDENTIFIER, expecting do or '{' or '('") – Dave Sep 30 '21 at 02:21
  • that's weird still ... the error seems related to a non valid character in the line, so would be good to review exactly. is the script ok when you run it from terminal directly ? also I would replace the ssh by `vagrant ssh -c "exec ...." ` so vagrant will deal with the connection/authentication on the vm – Frederic Henri Oct 01 '21 at 06:30
  • Is the item given to the launch.json "program" argument treated as a Ruby script? This may explain why its choking – Dave Oct 01 '21 at 14:07
  • not sure , you might try to change the configuration type to bash and integrated terminal to see if that changes anything – Frederic Henri Oct 01 '21 at 15:00
  • You mean the thing after '"type": ...'? I tried changing taht to "bash" but VS code gives me the error, 'The debug type is not recognized. Make sure that you have a corresponding debug extension installed and that it is enabled.(1)' – Dave Oct 01 '21 at 19:50

0 Answers0