Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode error: typeprof running on wrong ruby #93

Open
HoneyryderChuck opened this issue Dec 17, 2021 · 4 comments
Open

vscode error: typeprof running on wrong ruby #93

HoneyryderChuck opened this issue Dec 17, 2021 · 4 comments

Comments

@HoneyryderChuck
Copy link

Hi, I have a local setup using chruby (shouldn't be much different from other setups). I usually switch to the right ruby then open the project on VSCode via code ., in order to make sure that the extensions use the right ruby and deps versions. This works well for the steep plugin. However, the typeprof plugin picks up the wrong ruby, i.e. the system ruby. So, I switch to ruby 3, but I get the following error output from within vscode:

[vscode] Try to start TypeProf for IDE
[vscode] stderr: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.2.15) required by your /Users/tiago.cardoso/dev/jwt-token-kms/Gemfile.lock. (Gem::GemNotFoundException)
[vscode] stderr: To update to the latest version installed on your system, run `bundle update --bundler`.
[vscode] stderr: To install the missing version, run `gem install bundler:2.2.15`
[vscode] stderr: 	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
[vscode] stderr: 	from /usr/bin/bundle:23:in `<main>'
[vscode] failed to invoke typeprof: error code 1
# that's the location from system ruby, not ruby 3

I suspect I'm entering this path, where the extensions recognizes the existence of a Gemfile, and runs typeprof via bundler, but picks up the wrong bundler. And this might be so because typeprof's not picking up the ruby defined by the VSCode ruby plugin, which I set to ruby (should have been ruby 3). steep does this a bit differently, but can't figure out what's the correct way to patch typeprof's command.

@mame
Copy link
Member

mame commented Dec 20, 2021

Thank you for your report!

Currently, vscode-typeprof runs commands in a login shell. So, the environment of shell where code . is invoked is not respected. I wrote this mechanism based on solargraph. However, solargraph seems to have the same issue.

I'll later consider what I can do against this issue. I'm sorry to keep you waiting.

@mame
Copy link
Member

mame commented Dec 20, 2021

BTW, vscode-typeprof invokes ./bin/typeprof command if any. You may want to create the file and write your setup to invoke typeprof command.

@HoneyryderChuck
Copy link
Author

Standard binstub will yield the same error, as it still picks up the wrong ruby/bundler

@Kunado
Copy link

Kunado commented Jul 31, 2022

I got the same error the first time I tried to run TypeProf on VSCode.
I changed path of typeprof executable for VSCode to use (You can open the setting file from Preferences>Settings>Extensions>Ruby TypeProf>Edit in settings.json) and the extension worked fine.

I wonder if I can pass an executable file that exists on the PATH to VSCode without any configuration.

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

No branches or pull requests

3 participants