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

Support the Pixi Package Manager for Ruby Installation #2768

Open
1 task done
iandol opened this issue Oct 24, 2024 · 4 comments
Open
1 task done

Support the Pixi Package Manager for Ruby Installation #2768

iandol opened this issue Oct 24, 2024 · 4 comments
Labels
enhancement New feature or request help-wanted Extra attention is needed

Comments

@iandol
Copy link

iandol commented Oct 24, 2024

I have checked that this feature is not already implemented

  • This feature does not exist

Use case

Pixi is a new cross-platform package manager that uses conda-forge but offers global as well as directory specific tool installation.

https://pixi.sh

I want to be able to use pixi to manage my ruby and have ruby-lsp in VSCode support this increasingly popular install method.

Description

To install ruby and then a gem:

curl -fsSL https://pixi.sh/install.sh | bash
pixi global install ruby
ruby -v
gem install ruby-lsp

The global path is found at ~/.pixi/bin, and gems will be found at ~/.pixi/envs/ruby/share/rubygems. Currently the VSCode ruby-lsp cannot find ruby automatically. Adding it manually via rubyExecutablePath and ruby-lsp still cannot start. Probably I need to set rubyVersionManager but this is not working per-se.

2024-10-24 08:18:44.833 [info] (.dotfiles) Running command: `ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM:: YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in /Users/ian/.dotfiles using shell: /usr/local/bin/elvish
2024-10-24 08:18:53.735 [info] (.dotfiles) /Users/ian/.pixi/envs/ruby/share/rubygems/bin/ruby-lsp: line 6: /Users/ian/.pixi/envs/ruby/share/rubygems/bin/ruby: No such file or directory
/Users/ian/.pixi/envs/ruby/share/rubygems/bin/ruby-lsp: line 6: exec: /Users/ian/.pixi/envs/ruby/share/rubygems/bin/ruby: cannot execute: No such file or directory

2024-10-24 08:18:53.735 [info] (.dotfiles) [Error - 08:18:53] Server process exited with code 126.
2024-10-24 08:18:53.736 [info] (.dotfiles) [Error - 08:18:53] Server initialization failed.
2024-10-24 08:18:53.736 [info] (.dotfiles)   Message: Pending response rejected since connection got disposed
  Code: -32097 

It claims it can't find ruby at /Users/ian/.pixi/envs/ruby/share/rubygems/bin/ruby but the ruby-lsp shows /Users/ian/.pixi/envs/ruby/bin/ruby:

...
   8 #!/Users/ian/.pixi/envs/ruby/bin/ruby
   9 #
  10 # This file was generated by RubyGems.
  11 #
  12 # The application 'ruby-lsp' is installed as part of a gem, and
  13 # this file is here to facilitate running it.
  14 #
  15 
  16 require 'rubygems'
  17 
  18 Gem.use_gemdeps
...
### Ruby LSP Information

#### VS Code Version

1.94.2

#### Ruby LSP Extension Version

0.8.8

#### Ruby LSP Server Version

Unknown

#### Ruby LSP Addons



#### Ruby Version

3.3.3

#### Ruby Version Manager

none

#### Installed Extensions

<details>
<summary>Click to expand</summary>

- elvish (0.3.5)
- applescript (0.26.1)
- latex-workshop (10.5.5)
- vscode-rdbg (0.2.2)
- language-matlab (1.2.6)
- code-point (1.11.0)
- render-crlf (1.8.1)
- debugpy (2024.12.0)
- python (2024.16.1)
- vscode-pylance (2024.10.1)
- typst-lsp (0.13.0)
- penumbra (0.4.0)
- material-icon-theme (5.11.1)
- quarto (1.116.0)
- vscode-xml (0.27.1)
- vscode-yaml (1.15.0)
- r (2.8.4)
- markdown-preview-enhanced (0.8.14)
- ruby-lsp (0.8.8)
- shader (1.1.5)
- rewrap (1.16.3)
- lua (3.11.1)
- even-better-toml (0.19.2)
- ayu (1.0.5)
- shellcheck (0.37.1)
</details>

#### Ruby LSP Settings

<details>
<summary>Click to expand</summary>

##### Workspace

```json
{}
User
{
  "enableExperimentalFeatures": true,
  "enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": true,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "auto"
  },
  "customRubyCommand": "",
  "formatter": "rubocop",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "~/.pixi/bin/ruby",
  "indexing": {},
  "erbSupport": true
}
```

Implementation

No response

@iandol iandol added the enhancement New feature or request label Oct 24, 2024
@andyw8 andyw8 added the help-wanted Extra attention is needed label Oct 24, 2024
@vinistock
Copy link
Member

vinistock commented Oct 28, 2024

Thank you for the feature suggestion! Since this version manager is quite new, I'd like to first understand what level of traction and adoption it will receive in the Ruby community, before we commit to maintaining yet another version manager integration.

For the time being, you should be able to use our custom integration mode to get it working. Please let us know if that's not the case.

@iandol
Copy link
Author

iandol commented Oct 29, 2024

Thank you for the consideration!

@iandol
Copy link
Author

iandol commented Oct 30, 2024

Just to update for anyone using pixi: pixi installed ruby[1] works well to manage ruby-lsp in VSCode except for a bug in the ruby install recipe where there is no symlinked ruby in the rubygems/bin folder, to fix this follow the symlink instructions from conda-forge/ruby-feedstock#116 then set:

"rubyLsp.rubyExecutablePath": "${HOME}/.pixi/bin/ruby",
"rubyLsp.rubyVersionManager": {
  "identifier": "custom"
},

[1] I install ruby and compilers needed for building gems with: pixi global install ruby && pixi global install compilers -e ruby

@vinistock
Copy link
Member

The version manager being set to custom doesn't do anything if you don't define "rubyLsp.customRubyCommand" as well, so I suppose it's just having the "rubyLsp.rubyExecutablePath" global fallback that's doing the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help-wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants