<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lucas Luan de Melo</title>
    <description>The latest articles on DEV Community by Lucas Luan de Melo (@lucasldemello).</description>
    <link>https://dev.to/lucasldemello</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1406911%2F4cdb4af8-8ea9-4aff-b444-39fcd8b3638d.jpeg</url>
      <title>DEV Community: Lucas Luan de Melo</title>
      <link>https://dev.to/lucasldemello</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lucasldemello"/>
    <language>en</language>
    <item>
      <title>How to Set Up Solargraph in VS Code with WSL2</title>
      <dc:creator>Lucas Luan de Melo</dc:creator>
      <pubDate>Fri, 21 Jun 2024 12:49:32 +0000</pubDate>
      <link>https://dev.to/lucasldemello/how-to-set-up-solargraph-in-vs-code-with-wsl2-283b</link>
      <guid>https://dev.to/lucasldemello/how-to-set-up-solargraph-in-vs-code-with-wsl2-283b</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Recently, I faced an issue while trying to set up Solargraph in VS Code using WSL2 and ASDF for managing Ruby versions. The legacy projects I was working on used Docker, causing conflicts with Ruby versions and resulting in errors when initializing the server. After much research and trial and error, I managed to solve the problem. Here is a step-by-step guide to help other developers who might be facing the same issue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;The easiest way to resolve Ruby version issues would be to modify the project's &lt;code&gt;.tool-versions&lt;/code&gt; file to use a Ruby version compatible with Solargraph. However, in legacy environments, this modification may not be possible due to specific project dependencies or restrictions imposed by the development team. Therefore, this guide provides an alternative solution that does not require changes to the &lt;code&gt;.tool-versions&lt;/code&gt; file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step Solution
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;WSL2 installed&lt;/strong&gt;: Follow the &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/install"&gt;official Microsoft instructions&lt;/a&gt; to set up WSL2.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;VS Code installed&lt;/strong&gt;: Download and install &lt;a href="https://code.visualstudio.com/"&gt;VS Code&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Linux distribution on WSL2&lt;/strong&gt;: For example, Ubuntu.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 1: Set Up Ruby on WSL2 with ASDF
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install ASDF&lt;/strong&gt;: In the WSL2 terminal, run the following commands:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0&lt;br&gt;
echo '. $HOME/.asdf/asdf.sh' &amp;gt;&amp;gt; ~/.bashrc&lt;br&gt;
echo '. $HOME/.asdf/completions/asdf.bash' &amp;gt;&amp;gt; ~/.bashrc&lt;br&gt;
source ~/.bashrc&lt;/code&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add the Ruby plugin and install a Ruby version&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;asdf plugin-add ruby https://github.com/asdf-vm/asdf-ruby.git&lt;br&gt;
asdf install ruby 3.3.2  # Replace with the necessary version&lt;br&gt;
asdf global ruby 3.3.2&lt;/code&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Verify the Ruby installation&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ruby -v&lt;/code&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Install Solargraph
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install Solargraph&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gem install solargraph&lt;/code&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Verify the Solargraph installation&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;which solargraph&lt;/code&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 3: Configure VS Code to Use WSL2
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Install the "Remote - WSL" Extension&lt;/strong&gt;: In VS Code, open the Extensions Marketplace and install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl"&gt;Remote - WSL&lt;/a&gt; extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Open VS Code in WSL2&lt;/strong&gt;: In the WSL2 terminal, navigate to your project directory and open VS Code:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;code .&lt;/code&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 4: Configure Solargraph in VS Code
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add the configuration in &lt;code&gt;settings.json&lt;/code&gt;&lt;/strong&gt;: In VS Code opened in the WSL2 environment, open the Command Palette (&lt;code&gt;Ctrl+Shift+P&lt;/code&gt; or &lt;code&gt;Cmd+Shift+P&lt;/code&gt;), search for "Preferences: Open Settings (JSON)" and add the following configuration:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"solargraph.commandPath"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/home/your_user/.asdf/shims/solargraph"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"solargraph.useBundler"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"solargraph.diagnostics"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"solargraph.formatting"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Replace &lt;code&gt;/home/your_user/.asdf/shims/solargraph&lt;/code&gt; with the path returned by the &lt;code&gt;which solargraph&lt;/code&gt; command.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Restart VS Code&lt;/strong&gt;: Restart VS Code to apply the new settings.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Troubleshooting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Check permissions and paths&lt;/strong&gt;: Ensure that the path specified for Solargraph in &lt;code&gt;settings.json&lt;/code&gt; is correct and accessible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;VS Code Logs&lt;/strong&gt;: Check the VS Code logs for more details on the error. Access the logs through the Command Palette (&lt;code&gt;Ctrl+Shift+P&lt;/code&gt; -&amp;gt; "Output") and select "Solargraph" from the output menu.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With these steps, you should be able to set up Solargraph in VS Code using the Ruby version managed by ASDF in the WSL2 environment, without the need to modify the project's &lt;code&gt;.tool-versions&lt;/code&gt; file. I hope this guide helps solve similar issues you might encounter in your Ruby development environment.&lt;/p&gt;




&lt;p&gt;I hope this guide has been helpful! If you have any questions or suggestions, leave a comment below. 🚀&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>ruby</category>
      <category>productivity</category>
      <category>solargraph</category>
    </item>
    <item>
      <title>Como Configurar o Solargraph no VS Code com WSL2 para projetos legados</title>
      <dc:creator>Lucas Luan de Melo</dc:creator>
      <pubDate>Fri, 21 Jun 2024 12:38:56 +0000</pubDate>
      <link>https://dev.to/lucasldemello/como-configurar-o-solargraph-no-vs-code-com-wsl2-para-projetos-legados-2eg8</link>
      <guid>https://dev.to/lucasldemello/como-configurar-o-solargraph-no-vs-code-com-wsl2-para-projetos-legados-2eg8</guid>
      <description>&lt;h2&gt;
  
  
  Introdução
&lt;/h2&gt;

&lt;p&gt;Recentemente, enfrentei um problema ao tentar configurar o Solargraph no VS Code enquanto utilizava o WSL2 e o ASDF para gerenciar versões do Ruby. Os projetos legados que eu estava trabalhando usavam Docker, o que causava conflitos com as versões do Ruby e resultava em erros ao inicializar o servidor. Após muita pesquisa e tentativa e erro, consegui resolver o problema. Aqui está um guia passo a passo para ajudar outros desenvolvedores que possam estar enfrentando a mesma situação.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;O caminho mais fácil para resolver problemas de versão de Ruby seria modificar o arquivo &lt;code&gt;.tool-versions&lt;/code&gt; do projeto para usar uma versão do Ruby compatível com o Solargraph. No entanto, em ambientes legados, essa modificação pode não ser possível devido a dependências específicas do projeto ou restrições impostas pela equipe de desenvolvimento. Portanto, este guia fornece uma solução alternativa que não requer mudanças no arquivo &lt;code&gt;.tool-versions&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Passo a Passo para Resolver o Problema
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pré-requisitos
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;WSL2 instalado&lt;/strong&gt;: Siga as &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/install"&gt;instruções oficiais da Microsoft&lt;/a&gt; para configurar o WSL2.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;VS Code instalado&lt;/strong&gt;: Baixe e instale o &lt;a href="https://code.visualstudio.com/"&gt;VS Code&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Distribuição Linux no WSL2&lt;/strong&gt;: Por exemplo, Ubuntu.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Passo 1: Configure o Ruby no WSL2 com ASDF
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instale o ASDF&lt;/strong&gt;: 
No terminal do WSL2, execute os seguintes comandos:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    git clone https://github.com/asdf-vm/asdf.git ~/.asdf &lt;span class="nt"&gt;--branch&lt;/span&gt; v0.10.0
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'. $HOME/.asdf/asdf.sh'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'. $HOME/.asdf/completions/asdf.bash'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
    &lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Adicione o plugin Ruby e instale uma versão do Ruby&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    asdf plugin-add ruby https://github.com/asdf-vm/asdf-ruby.git
    asdf &lt;span class="nb"&gt;install &lt;/span&gt;ruby 3.3.2  &lt;span class="c"&gt;# Substitua pela versão necessária&lt;/span&gt;
    asdf global ruby 3.3.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Verifique a instalação do Ruby&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    ruby &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Passo 2: Instale o Solargraph
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instale o Solargraph&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   gem &lt;span class="nb"&gt;install &lt;/span&gt;solargraph 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Verifique a instalação do Solargraph&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    which solargraph
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Passo 3: Configure o VS Code para Usar o WSL2
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instale a Extensão "Remote - WSL"&lt;/strong&gt;: No VS Code, abra o Marketplace de Extensões e instale a extensão &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl"&gt;Remote - WSL&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Abra o VS Code no WSL2&lt;/strong&gt;: No terminal do WSL2, navegue até o diretório do seu projeto e abra o VS Code:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    code &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Passo 4: Configure o Solargraph no VS Code
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Adicione a configuração no &lt;code&gt;settings.json&lt;/code&gt;&lt;/strong&gt;: No VS Code aberto no ambiente WSL2, abra o Command Palette (&lt;code&gt;Ctrl+Shift+P&lt;/code&gt; ou &lt;code&gt;Cmd+Shift+P&lt;/code&gt;), procure por "Preferences: Open Settings (JSON)" e adicione a seguinte configuração:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"solargraph.commandPath"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/home/seu_usuario/.asdf/shims/solargraph"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"solargraph.useBundler"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"solargraph.diagnostics"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"solargraph.formatting"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Substitua &lt;code&gt;/home/seu_usuario/.asdf/shims/solargraph&lt;/code&gt; pelo caminho retornado pelo comando &lt;code&gt;which solargraph&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reinicie o VS Code&lt;/strong&gt;: Reinicie o VS Code para aplicar as novas configurações.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Solução de Problemas
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Verifique as permissões e caminhos&lt;/strong&gt;: Certifique-se de que o caminho especificado para o Solargraph no &lt;code&gt;settings.json&lt;/code&gt; está correto e acessível.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logs do VS Code&lt;/strong&gt;: Verifique os logs do VS Code para mais detalhes sobre o erro. Acesse os logs através do Command Palette (&lt;code&gt;Ctrl+Shift+P&lt;/code&gt; -&amp;gt; "Output") e selecione "Solargraph" no menu de saída.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusão
&lt;/h3&gt;

&lt;p&gt;Com esses passos, você deve conseguir configurar o Solargraph no VS Code utilizando a versão do Ruby gerenciada pelo ASDF no ambiente WSL2, sem a necessidade de modificar o arquivo &lt;code&gt;.tool-versions&lt;/code&gt; do projeto. Espero que este guia seja útil para resolver problemas semelhantes que você possa encontrar no seu ambiente de desenvolvimento Ruby.&lt;/p&gt;

</description>
      <category>solargraph</category>
      <category>vscode</category>
      <category>ruby</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
