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 asdf environment #1999

Closed
davijonm opened this issue May 1, 2024 · 15 comments · Fixed by #2006
Closed

Failed to activate asdf environment #1999

davijonm opened this issue May 1, 2024 · 15 comments · Fixed by #2006
Assignees
Labels
bug Something isn't working

Comments

@davijonm
Copy link

davijonm commented May 1, 2024

Vscode, asdf and Ruby LSP are all in the latest versions

  1. Start the Ruby LSP using vs code
  2. Open a Ruby file
  3. Try to Ruby LSP: Start
  4. Shows the error ailed to activate asdf environment: Unexpected token '/', "/bin/sh: 2"... is not valid JSON
    Screenshot from 2024-05-01 13-17-02
    Screenshot from 2024-05-01 13-19-16

Code snippet or error message
VS code message: Failed to activate asdf environment: Unexpected token '/', "/bin/sh: 2"... is not valid JSON

@davijonm davijonm added the bug Something isn't working label May 1, 2024
@andyw8
Copy link
Contributor

andyw8 commented May 1, 2024

👋 This seems like the same issue as #1990 which was solved by updating asdf. What version of asdf is in use?

@davijonm
Copy link
Author

davijonm commented May 1, 2024

Latest version

Captura de tela 2024-05-01 141209

@andyw8
Copy link
Contributor

andyw8 commented May 1, 2024

Thanks. And how was asdf installed?

@vinistock
Copy link
Member

In the latest release, we start printing invalid JSON environments to the output tab to make this type of problem easier to diagnose. Could you please give it a try and report what the extension tried to parse as the environment?

@davijonm
Copy link
Author

davijonm commented May 2, 2024

here it is:

Screenshot from 2024-05-02 12-26-21

and the file is there:

Screenshot from 2024-05-02 12-28-21

@vinistock
Copy link
Member

Based on what I could gather, it seems that /bin/sh (the default shell used when calling exec) doesn't support the [[ ]] syntax on all operating systems. I assume you're using some other shell in your terminal and not /bin/sh, otherwise you'd see the problem there as well.

I think we can try to run exec with the shell identified by VS Code, which I'm exploring on this PR #2006.

@davijonm it would be extremely helpful if you could confirm that this fixes the issue. You can do so by following these steps:

  1. Clone the project
  2. Switch to the branch in the PR or apply the changes manually (since it's only a few changes)
  3. Install dependencies (cd vscode && yarn install)
  4. Open our custom workspace by clicking on the workspace file and then click the button open workspace
  5. In the Run and debug panel, select the task Run extension and click start. This will open a second VS Code window where the development version of the extension is running
  6. In the second window, did the Ruby LSP launch properly with the changes in the branch?

@davijonm
Copy link
Author

davijonm commented May 2, 2024

Ok, did all the steps. In the step 5, it opened a second window with this error bellow:
Screenshot from 2024-05-02 20-26-25

@davijonm
Copy link
Author

davijonm commented May 2, 2024

I use zsh but asdf is set in both .zshrc and .bashrc files

@vinistock
Copy link
Member

Not sure why it still used /bin/sh. I pushed #2006 to fallback to process.env.SHELL and added a print so that we can inspect the values. If you don't mind giving it another try, I'd like to understand if vscode.env.shell is not set for you.

@davijonm
Copy link
Author

davijonm commented May 3, 2024

Here is the result
Screenshot from 2024-05-03 17-43-50

@davijonm
Copy link
Author

Hey guys, any updates?

@andyw8
Copy link
Contributor

andyw8 commented May 10, 2024

@davijonm we're still investigating. For now, you can downgrade to v0.5.19 of the extension to switch to the older activation approach.

@vinistock
Copy link
Member

I just realized I made a mistake in the previous iteration of #2006. I set the shell inside env, which isn't what I meant to do. I updated the branch to set the actual shell to vscode.env.shell.

Could you please try again and report if that fixes it?

@davijonm
Copy link
Author

Based on what I could gather, it seems that /bin/sh (the default shell used when calling exec) doesn't support the [[ ]] syntax on all operating systems. I assume you're using some other shell in your terminal and not /bin/sh, otherwise you'd see the problem there as well.

I think we can try to run exec with the shell identified by VS Code, which I'm exploring on this PR #2006.

@davijonm it would be extremely helpful if you could confirm that this fixes the issue. You can do so by following these steps:

  1. Clone the project
  2. Switch to the branch in the PR or apply the changes manually (since it's only a few changes)
  3. Install dependencies (cd vscode && yarn install)
  4. Open our custom workspace by clicking on the workspace file and then click the button open workspace
  5. In the Run and debug panel, select the task Run extension and click start. This will open a second VS Code window where the development version of the extension is running
  6. In the second window, did the Ruby LSP launch properly with the changes in the branch?

Ok, I tried again. After step 5, a new window opened and apparently there was no error, but I can't tell if it worked because the main window still shows this error: /home/davi/.asdf/asdf.sh: [[: not found

Screenshot from 2024-05-28 09-04-25

@davijonm
Copy link
Author

Never mind, I was using an unsupported Ruby version (2.5.1). I think it works correctly now after your PR.

Screenshot from 2024-05-28 09-27-34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants