Open duckpuppy opened 5 years ago
There are other bugs involving interactive shells that I wasn't able to resolve, and login shells appeared to be more reliable. I've been trying to make solargraph-utils processes as platform-independent as possible, but I suspect there will always be exceptions, especially when Ruby version managers are involved.
This comment might help you adjust your zsh to use rbenv in non-interactive shells: https://github.com/castwide/vscode-solargraph/issues/108#issuecomment-487359460
Alternatively, you can try setting the solargraph.commandPath
configuration to the Solargraph executable's absolute path. If you can run Solargraph from the command line, you can determine its path by running which solargraph
.
The information in that comment might work OK, but the problem is that rbenv isn't being used unless the shell is interactive. The errors I'm getting reference the macOS system ruby paths, despite using rbenv and having a .ruby-version
file in the directory I launch code from, so even if I specified the path to the solargraph command that I wanted to run it would be running a version of solargraph (installed by bundler using a newer ruby installed by rbenv) that might not actually run when running under the older system ruby (which is 2.3.0). I'm assuming that's because I'm setting up rbenv in .zshrc
... maybe that could be moved to .zprofile
so that it's available in a simple login shell?
Is there a guide on configuring and using rbenv with vscode-solargraph? Everything I've read says that simply having the .ruby-version
file in the workspace directory (and launching vscode from that directory) should be enough. Even the terminal in vscode shows the proper ruby when running ruby --version
(since it's an interactive shell), it's just the solargraph plugin that's not using it.
I'm renaming the issue a little bit to indicate that I'm using rbenv as well.
From what I understand, yes, moving rbenv to .zprofile
should fix the issue. I remember a similar issue with older versions of rvm.
Unfortunately, I'm not able to test it myself at the moment. I have access to a MacBook, but it's configured to use rvm and bash. At some point I might be able to set up a MacOS VM to test other environments.
hey @duckpuppy did adding rbenv to your .zprofile
fix this for you? I tried it and it didnt seem to work for me.
still getting some "gem not installed" and "failed to install gem" errors so it makes me think it is not using the correct shell still.
I found this issue while trying to get Solargraph working with Nix and direnv on macOS, so I wanted to add my experience.
Login shells on macOS call /usr/libexec/path_helper
, which moves all paths not in /etc/paths
or /etc/paths.d
to the end of the paths list. Consequently, the system Ruby gets picked up instead of the one in my Nix expression. I tried specifying the absolute path, but that didn’t really work very well.
It appears this logic is only applied to Bash and ZSH, so if one sets SHELL to another shell (such as /bin/dash
or Fish), then the path gets picked up as expected. I actually normally use Fish, so I’m not sure why SHELL wasn’t reflecting that….
I recently had to set up a new Macbook, and in doing so installed vscode and the solargraph extension. Solargraph failed to load (it refused to use the ruby version specified in
.ruby-version
), and after some searching found reference to a change to how zsh shells are handled.This commit changed the ZSH shell from an interactive shell to a login shell. If I change the
-l
back to-i
in the extension's code, solargraph works again.What issue prompted the change to a login shell for zsh? If it matters, my shell is the Homebrew version of zsh, not the version in macOS at
/bin/zsh
.