Open smrtsmrf opened 5 years ago
Welcome to the Ruby community!
I vaguely remember hearing about a similar issue with it acting differently when opened via the UI vs the dock, but I can't remember the details and I can't find it. I'm also not seemingly able to reproduce it myself.
A few things to check/try:
code .
automatically opens the current directory as a workspace. In the 'File Explorer' sidebar does it have a big button for 'Open Folder'?.ruby-version
file anywhere in your project (or in its parent directories)? That might explain the differing Ruby version being used, since I believe rvm will usually prioritize that file if it can find it. Gemfile
for the project have a ruby
version specified? e.g. ruby '2.6.3'
echo $SHELL
should tell you what your shell is.Unfortunately, I use rbenv instead of rvm, so I'm not really sure what else it could be.
Out of curiosity, does the vscode-ruby extension work for you?
Oh, I just noticed the ruby-2.6.2@mayhem
thing. I think you're using RVM gemsets? That might be why it's working in strange ways. I'm not sure what to do about it, though. https://rvm.io/gemsets/basics
Are you using the RVM local dir ruby version thing? That seems like it might be the issue if it exists, since it will use whatever your default ruby is (I think, at least).
@connorshea how do you figure out what commands to run?
@connorshea
.ruby-version
file, which specifies 2.6.2. So in the error that I posted, I don't know why it's looking for gems in a 2.6.3 folder. There is nothing in the Gemfile that references 2.6.3terminal.integrated.env.osx
If I run the bundle exec rspec
command from the integrated terminal, it works fine. But when the extension runs that command, that's when I get the error. The integrated terminal seems to be using the right path (2.6.2), but the extension seems to be looking in 2.6.3.
It may be useful to know that 2.6.3 is my default ruby version. But I even tried setting my default to 2.6.2 and I still had errors.
Try installing the gems in your global gemset with:
rvm @global do gem install
That helped me a little bit
@joaovbalmeida, I'm new to ruby and rvm, but by doing that, it seems like it's just installing every gem both in the local project directory, as well as the global gemset. The problem would arise if/when different projects depend on different versions of the same gem.
@smrtsmrf I'm fairly certain that Bundler handles that automatically using the Gemfile
/Gemfile.lock
, so it shouldn't matter if you have different versions of the same gem in separate projects. It'll only load the one specified in the Gemfile.lock
. I don't think using gemsets should really be necessary unless you're doing something weird.
Well, as I mentioned, I'm new to ruby (and hence rvm as well). Just started at a new job and I followed the ruby setup they use. Unfortunately, they don't use VS Code though, so no help as far as this extension goes. :(
Now I've been getting mixed results though - sometimes opening Code with the terminal doesn't load the extension properly. But sometimes it does. It makes me think there's some kind of race condition going on with something. But I don't know enough about VS Code or ruby to make a call on that.
As of right now, I'm getting all failures rather than mixed results, and the extension isn't working at all. These are the errors I get (which are the same errors I was getting when I tried to open Code through the spotlight/UI)
Command failed: rspec --require /Users/<user>/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.6.0/custom_formatter.rb --format CustomFormatter --order defined --dry-run SimpleCov failed with exit 1
Ruby Test Explorer failed to find an RSpec test suite. Make sure RSpec is installed and your configured RSpec command is correct.
I figured out that I get those errors when I have a syntax error or something in my spec file. It sure would be nice if there was a way to indicate that was the problem, rather than the whole extension just not even loading when I close and open up Code again. So, I can still open and use Code and this extension via the terminal. Good news.
Unfortunately, the problem with opening from the spotlight/UI still persists, even when the syntax errors are taken care of, so something else is going on there.
I am using
rvm
for different ruby versions with different projects, and I'm using a mac.When I open up vs code from the terminal using
code .
, everything works perfectly.However, when I open up vs code from the spotlight/dock, the test explorer doesn't work. I've checked and in vs code integrated terminal all the environment variables and ruby version are setup correctly. Somehow it seems though that the extension is looking in the wrong place for things. This is the error I get:
(It should be noted that the nokogiri gem is one that my project depends on, but the extension is looking in the wrong place for it.)
Here's the output of my
gem env
:So for some reason, the extension is looking in 2.6.3, even though in the terminal it confirms that it should be using 2.6.2 for this project.
I even tried setting my default rvm to use 2.6.2, but I still get the same error when launching from the UI/spotlight/dock (this time it is looking in the 2.6.2 section, but it still doesn't find what it needs).
I'm super new to Ruby and rvm, but it seems like the extension isn't getting the right info from the rvm magic before it starts loading.