Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

rspec doesn't execute as a program, it is parsed as if it's a code file. #344

Closed
atracy opened this issue Jun 1, 2018 · 3 comments
Closed

Comments

@atracy
Copy link

atracy commented Jun 1, 2018

Your environment

  • vscode-ruby version: 0.6.1
  • Ruby version: 2.4.1
  • VS Code version: 1.23.1
  • Operating System: 10.13.3
  • Hardware (optional): MacBook Pro

Expected behavior

Putting the following configuration in launch.json
{
"name": "RSpec - active spec file only",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "../.rbenv/shims/rspec",
"args": ["${file}"]
},

Should allow me to run my spec file like it runs at the terminal

Actual behavior

rspec bash program is opened as if it is the ruby script to be ran, and since it's a bash script and not a ruby script, I get an error that shows a syntax error in the ruby bash script.
< The following is the error message which just shows the first few lines of the rspec bash program's code where it thinks it's getting a syntax error because I guess it thinks it's supposed to open the file and not run it as a program. >

Uncaught exception: /Users/<user.name>/.rbenv/shims/rspec:3: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
[ -n "$RBENV_DEBUG" ] && set -x
^
/Users/<user.name>/.rbenv/shims/rspec:3: syntax error, unexpected ']', expecting end-of-input
[ -n "$RBENV_DEBUG" ] && set -x

Steps to reproduce the problem

  1. install rbenv
  2. install ruby 2.4.1 using rbenv
  3. setup a launcher with the configuration pasted above in the expected behavior in VS Code's launch.json file.
  4. create a spec file to run
  5. go into debug mode on VS Code
  6. select the launcher you just created (RSpec - active spec file only)
  7. Press the green arrow to Debug the spec file using the launcher.
@atracy
Copy link
Author

atracy commented Jun 7, 2018

Looks like this is an issue with how rbenv switches ruby versions. rbenv creates a shim directory, and in it, somehow creates a pointer type file to the correct version of rspec, by not using the rspec file in the shim directory, but instead, using the rspec file in the /bin directory does the trick and fixes this issue. Closing this issue.

@atracy atracy closed this as completed Jun 7, 2018
@degoeym
Copy link

degoeym commented Oct 5, 2018

@atracy Could you share your updated config to show what the updated program property looks like?

@PascalPixel
Copy link

PascalPixel commented Nov 21, 2018

@degoeym change:
"pathToBundler": "${env:HOME}/.rbenv/shims/bundle",
to:
"pathToBundler": "${workspaceRoot}/bin/bundle",,

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants