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

Failed to activate rbenv environment #1560

Closed
kadru opened this issue Mar 29, 2023 · 8 comments · Fixed by Shopify/vscode-ruby-lsp#526
Closed

Failed to activate rbenv environment #1560

kadru opened this issue Mar 29, 2023 · 8 comments · Fixed by Shopify/vscode-ruby-lsp#526
Labels
help-wanted Extra attention is needed needs-more-info More information is needed to address this issue transferred This issue was transferred from vscode-ruby-lsp

Comments

@kadru
Copy link

kadru commented Mar 29, 2023

Hi, I just trying to use this extension but it fails to activate:

Failed to activate rbenv environment: Command failed: /bin/bash -lic 'rbenv exec ruby --disable-gems -rjson -e "printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, JSON.dump(ENV.to_h))"' bash: no se puede establecer el grupo de proceso de terminal (11835): Función ioctl no apropiada para el dispositivo bash: no hay control de trabajos en este intérprete de ordenes No se ha encontrado la orden «rbenv», pero se puede instalar con: sudo apt install rbenv

It seems the extension cannot find rbenv but I can run the command that the extension is trying to run and is running without errors inside the vscode terminal.

I'm using:
vscode 1.76.2
ruby lsp extension 0.2.3
ruby 2.7.7
rbenv 1.1.2-40-g62d7798
ubuntu 20.04

@vinistock
Copy link
Member

Hey. Is rbenv loaded in your ~/.bashrc?

@kadru
Copy link
Author

kadru commented Mar 29, 2023

Yes, is loaded with eval "$(rbenv init -)"

@vinistock
Copy link
Member

Do you have another configuration file such as ~/.profile? If you do, can you try activating rbenv there? I want to understand if maybe the interactive bash mode is not loading ~/.bashrc by default.

@vinistock vinistock added the needs-more-info More information is needed to address this issue label Mar 30, 2023
@wwahammy
Copy link

wwahammy commented Mar 30, 2023

Just wanted to add that I'm running on 22.04 and have the same issue.

I had eval "$(~/.rbenv/bin/rbenv init - bash)" in my ~/.bashrc.

I followed you suggestions in the previous reply and duplicated it in ~/.bash_profile. The extension does seem to start up and does not error in the same place in that case.

Generally, I don't believe .bash_profile is really all that used on Ubuntu and the recommendation is to avoid its use so that's not really ideal workaround.

@vinistock
Copy link
Member

I thought using the -i flag for an interactive bash shell would load ~/.bashrc. Is there a way to tell bash to load it?

@wwahammy
Copy link

So a bit of info: If I delete ~/.bash_profile, then the project install works perfectly. Having ~/.bash_profile on Ubuntu is not recommended but a tool (pipx) automatically added it last week.

I don't know whether the best way to handle this for the extension but at the very least, it would be nice if this issue could be detected so the user would know the problem.

@wwahammy
Copy link

I can't help on whether there's a better way to tell bash to load ~/.bashrc though, this is not my area of expertise 😄

@vinistock vinistock added the help-wanted Extra attention is needed label Apr 3, 2023
jayanth-kumar-morem referenced this issue in jayanth-kumar-morem/vscode-ruby-lsp Apr 26, 2023
Warn that the LSP is ready on initialized
@vinistock vinistock added the transferred This issue was transferred from vscode-ruby-lsp label Mar 12, 2024
@vinistock vinistock transferred this issue from Shopify/vscode-ruby-lsp Mar 12, 2024
@KapilSachdev
Copy link

KapilSachdev commented May 22, 2024

So a bit of info: If I delete ~/.bash_profile, then the project install works perfectly.

This worked for me as well.

Weirdly all was working fine until i removed previous ruby version and installed 3.3.1. After that it kept showing me

Automatic Ruby environment activation with rbenv failed: Command failed: rbenv exec ruby -W0 -rjson -e STDERR.printenv: ENV.toh,jeet:!!defined?(RubyVM::YJIT),version:RUBY VERSION}.to_json) /bin/sh: 1: rbenv: not found

My system has ~/.bash_profile and vscode ruby-lsp was working along with ~/.bash_profile until i updated ruby.
Deleting ~/.bash_profile is what made it worked.

Weird that it was working earlier and ruby version change caused issues.

vscode 1.89.1
vscode-ruby-lsp-v0.5.21
ruby 3.3.1
rbenv 1.2.0-89-gac02022
ubuntu 24.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Extra attention is needed needs-more-info More information is needed to address this issue transferred This issue was transferred from vscode-ruby-lsp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants