-
Notifications
You must be signed in to change notification settings - Fork 23
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
Question: setup with multi Ruby install #12
Comments
It looks like you're pointing at a Ruby 2.2.4 version of the Solargraph gem. Are you also running in VS Code on the Ruby 2.2.4 executable, or are you using the Ruby 2.0.0 on the system path? Version 0.12.2 of Solargraph expects Ruby 2.2.2 minimum. Earlier versions might work, but I would expect anything less than Ruby 2.1 minimum to have bugs. If you're using RVM or something similar, you might need to make sure you're pointing to the right version of Ruby in your workspace, e.g., whatever version is listed in .ruby-version in the project's root folder. If you're using Bundler, we'll also need to make sure that's configured correctly. If all else fails, go to Help -> Toggle Developer Tools in the VS Code menu and report any error messages you receive in the console. |
Hi,
|
The error indicates that either the Solargraph gem is not installed or it couldn't be found in your Ruby environment. Can you confirm that solargraph.commandPath is correct? If you run If that doesn't work, based on your debug setting, the correct path might be If neither path works but |
I just discovered something else that might be causing your issue. Did you set solargraph.commandPath in the user settings or the workspace settings? When I tried to set it in the workspace settings, it got ignored, but when I set the same value in the user settings, it worked as expected. This apparently happens because the solargraph.commandPath property has the isExecutable flag set to true (see microsoft/vscode#33439). |
Are you able to install it from the command line with |
Yes, just now tried it again but the same issue. Each time I open VSCode, it displays the same error message as in the above screenshot. |
I notice you're using rvm. Can you confirm that the gem is installed on the same installation of Ruby that you're using from VS Code? If you open a folder (i.e., a workspace) in VS Code, Solargraph will use it as the current working directory for running its executables, which means it should use whatever Ruby version is specified by rvm, e.g., with a .ruby-version file. If you only open a single file in VS Code without a workspace, it will probably use the system-level Ruby installation. You also might want to check Help -> Toggle Developer Tools for error messages. |
If all else fails, you can try setting your |
Wow. I'm not sure what to make of this one, especially since it works in Atom. I haven't tested it on Arch Linux, but I know it works in CentOS. One more possibility. Are you opening a folder that contains a Gemfile? There might be an issue if solargraph isn't bundled, but I wouldn't expect it to be a problem unless you set the |
Yes, I am using a rails project. I tested it with/without bundler, created a new project without gemfile, it didn't help. I even switched to login shell on VSCode as described here: No luck. |
Okay. Rails support is still in development, but you should still be able to use Solargraph with it. The method suggestions it gives would just be incomplete. I'll see if I can spin up an Arch Linux VM and reproduce the problem. |
I think I've found the problem. When you start VS Code, it runs in a shell that doesn't load your profile, so rvm doesn't get included in the environment. I was able to make it work from a terminal window like so:
Since vscode gets called from a login shell, it's able to use rvm to find ruby and run solargraph. I'm not sure what a more permanent solution should be. I tried adding the rvm scripts to .xinitrc, but it didn't seem to have any effect. |
Same issue here on v0.10.3 on Mac: I am using rvm, I tried:
I couldn't make it work :( |
I ran some tests on a MacBook. It appears that VS Code on MacOS always uses your default Ruby installation. Detailed results:
@loicginoux Please let me know if setting the rvm default to the desired Ruby version works (e.g.: |
Ok thanks it works by installing the gem on the default rvm environment.
Thank you for the response, that solves my issue 👍 |
Good to know, thanks. I noticed a potential for disparity between the version of Ruby that runs in VS Code's integrated terminal and the version it uses for background processes. Most likely it's because the terminal uses |
It turns out there's a terminal workaround on Mac as well. First you have to add the
Open a terminal, |
Today when I enabled this extension, it magically started working on its own. The only change, I've made to my environment is moving all paths from .zshrc to .zprofile I am not using any special workaround. Let me know if you've any questions. Edit: Forgot to notice, that the vscode extension is now: 0.10.3. Earlier in this thread it was 0.9.1, so that explains it. |
Thanks, @zero-master. How are you opening VS Code? I just tested 1.19.0 on Arch Linux with Ruby 2.4.1 installed via rvm and no Ruby system install. When I open VS Code from the menu, it doesn't find Ruby. When I open it with the |
I am opening vscode using the icon launcher. I've this in my vscode user settings: `"terminal.integrated.shell.linux": "/usr/bin/zsh", "terminal.integrated.shellArgs.linux": [ The second line in the config. uses login shell in the terminal. (rvm requires it) In .zprofile:
In .zlogin:
This setup works very well for me. |
Version 0.11.3 of the extension uses an explicit bash shell to run Ruby processes. This should fix the issues people have been having with multi Ruby installs. It was able to find the Ruby installation configured by RVM in my tests on OSX and Arch Linux. |
I was actually debugging why my current setup was not working: Maybe it would make sense to use |
@bergmannf That could work. I'll look into it. |
vscode-solargraph v0.12.0 will use the current shell if available. In my tests, it was able to detect the Ruby installation from either bash or zsh on Arch Linux. |
@nscmnto What OS are you using? |
macOS Sierra 10.13.4
— Bruno Nascimento
On Sun, Apr 29, 2018 at 20:53, Fred Snyder <notifications@github.com> wrote:
@nscmnto [https://github.com/nscmnto] What OS are you using?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub [#12 (comment)] , or mute the thread [https://github.com/notifications/unsubscribe-auth/AHwzphZXiK6e1ZkdhpYeJfHUYw33TDcXks5tthomgaJpZM4PiGuW] .
|
Version 0.18.0 might fix this issue. It changes how the extension starts Ruby processes under zsh. |
I had this issue running VS Code on Windows using WSL with rvm for Rails development. It kept telling me the solargraph gem is not installed even though it was in WSL. So, I noticed the error message is showing Windows paths. Then it dawned on me that it is trying to run solargraph from the Windows command line, not WSL bash. I installed Ruby in Windows via RubyInstaller, then installed solargraph using the Windows command line. Works like a charm now, hope this helps! |
Awesome this looks to be working for me on Mac running {
"solargraph.commandPath": "/Users/codyswartz/.rvm/gems/ruby-2.5.1/bin/solargraph",
"solargraph.bundlerPath": "/Users/codyswartz/.rvm/gems/ruby-2.5.1/bin/bundle"
} |
Extension 0.20.0 should finally resolve a longtime issue with rvm/rbenv. If you open a folder with a You can check which version of Ruby you're using by running "Solargraph: Get environment info" from the command palette. |
thanks for the effort! |
@bsarrazin You might get that error if you try to run the command before the server is finished initializing. The status bar at the bottom left should give you a message that changes from "Starting the Solargraph language server" to "Solargraph is ready." Time to initialize can vary depending on the size of the workspace. Extensions are activated on demand, so the server might not start until you open a Ruby file. |
@castwide is there a way to see progress/logs while the server is starting? I see "Starging the Solargraph language server ..." in the status bar, but it never completes. |
One thing you can try is going to your workspace's root folder in a terminal and running Some additional tips that might help you improve performance: https://solargraph.org/guides/performance |
hmm I don't have a workspace, I'm using it for scripts in an iOS project. |
No. If you don't have a workspace, it should still work with individual Ruby files. Is it possible you're opening a folder in VS Code, e.g., your home directory or Documents folder, and Solargraph is treating it as a workspace? |
I normally open the root of the repo by running
how can I tell? EDIT: |
Solargraph will try to treat nearly any open folder as a workspace. I might tweak this behavior in a future version, to avoid problems with the precise use case of opening a folder that doesn't represent a discrete app or library. At any rate, it doesn't sound like the workspace is the problem here. I just tested on a MacBook using RVM. The first time I opened VS Code, the server hung while initializing, but now I'm not able to reproduce it. No idea what the root cause is. |
@castwide is there anything I can do to provide debug info? logs? |
You've been looking in all the right places, especially the developer console. You can try setting the One other thing you can do is check Activity Monitor to see if there are zombie server processes. |
checking for processes: $ ps -ef | grep solar
501 1089 1 0 9:34AM ?? 0:32.95 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 1300 1 0 9:35AM ?? 0:31.89 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 2704 1 0 9:44AM ?? 0:29.47 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 3357 1 0 9:47AM ?? 0:28.50 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 3739 1 0 9:49AM ?? 0:27.56 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 4444 1 0 9:53AM ?? 0:26.94 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 9324 1 0 10:29AM ?? 0:16.49 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 17914 1 0 10:58AM ?? 0:09.85 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 18441 1 0 10:59AM ?? 0:09.77 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 18664 1 0 11:02AM ?? 0:08.45 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 19124 1 0 11:02AM ?? 0:08.19 /Users/ben/.rbenv/versions/2.6.3/bin/ruby /Users/ben/.rbenv/versions/2.6.3/bin/solargraph socket --port 0
501 25894 57489 0 11:32AM ttys001 0:00.00 grep --color solar after killing all of them, tried restarting VS Code and am getting the same issue, with a single process this time |
I still haven't been able to reproduce this issue consistently. I updated to Ruby 2.6.3 and it still worked. The server hasn't hung since the first attempt. Another long shot: you could try setting the |
I tried both |
Sorry, I'm stumped. One last possibility, if you haven't tried it, is uninstalling and reinstalling both the gem and the extension. I'd much prefer to know what the root cause is, but a couple other users have reported solving unexplained problems that way, so it's worth a shot. |
Thanks for your help/patience @castwide. I tried to uninstall the extension (worked fine) and tried to remove the gem, but it gave me weird error, something about permissions. I'll save you the back and forth, but basically, something was really off/weird with my Ruby installation. I couldn't uninstall 2.6.3 without All is working now. So there's definitely something weird that happened with permissions recently. haha, anyway, thanks for you help! Really appreciate it! |
Glad you got it working! I don't know if that kind of problem can be detected from the extension, but at least I can muck around with permissions to see if I can reproduce it. |
Hi @castwide. I'm having issues with solargraph playing with vscode-insiders. I've looked up everything on the internet about this issue including this thread but nothing matches my exact issue. VScode refuses to look at rbenv version of ruby and it's gem's. It keeps defaulting to the system versions. Hopefully that image helps. I discovered this because I would always get a popup on startup of vscode to update solargraph, but it fails since it tries to update the /var/lib/gems/2.5.0 directory which returns a file permission error. I already have the latest gem installed via rbenv in my home directory, so it's a bit puzzling. I've tried the commandpath option and even installing this in full on windows 10 side, but none of that worked. Running ruby -v and solargraph -v in vscode in bash returns the right stuff, but doesn't in SH. I'm kind of new to all this, so I'm a bit in over my head at this point. The language server runs (although a bit slow) so everything technically works. I'd just like to get it running on the latest versions of ruby and solar. Thank you! |
I just ran into a problem where the integrated terminal did not find the correct Ruby version, even though Solargraph did:
Apparently VS Code does not set your workspace as the cwd. Explicitly moving to the directory fixed it:
A more permanent workaround is to to customize the integrated shell settings:
The last setting tells the terminal not to inherit environment variables from VS Code. |
@kaymach It looks like you're using WSL? The extension update released this week might give you better results with remote workspaces. More information: https://code.visualstudio.com/docs/remote/wsl |
@castwide Thank you for the reply. I updated WSL remote and vscode and now everything works 100%. Good thing I went on vacation at the right time instead of poking at it for 2 weeks to no avail. |
I can not get solargraph works with VS code
What operating system are you using? Window 10 Edu
What version of Ruby? 2.0.0 as system path, 2.2.4 (solargraph gem installed).
What version of the vscode-solargraph extension? 0.8.0
Do you have any other extensions installed?
"solargraph.commandPath":"D:/SIM/script/ruby/setup/ruby22/lib/ruby/gems/2.2.0/gems/solargraph-0.12.2/bin/solargraph"
The text was updated successfully, but these errors were encountered: