How to allow Junie to execute terminal commands in your WSL 2 environment

Martijn | Developer

JetBrains recently released Junie, an AI-powered assistant for your IDE. While it works with WSL 2, it can have issues executing terminal commands. This causes it to get stuck in its workflow. In this article, we'll show you how to implement the workaround mentioned by andreas.hochhalter.

What is Junie?

Junie is an AI-powered assistant that you can install as a plugin in your JetBrains IDE. It integrates directly with your development environment, providing context-aware suggestions, code explanations, and the ability to execute terminal commands.

With Junie, you can:

  • Get intelligent code completions
  • Generate code based on natural language descriptions
  • Debug issues more efficiently
  • Give permission to execute required terminal commands
  • And much more

Allow Junie to execute terminal commands with PowerShell

If you're using WSL 2 as your development environment, you'll need to make a few adjustments to ensure Junie can properly execute terminal commands.

Step 1 - Create a Network Drive

The first step is to create a network drive that points to your WSL 2 distribution.

  1. Open File Explorer.
  2. Right-click on "This PC" and select "Map network drive".
  3. Choose a drive letter (e.g., X:).
  4. In the folder field, enter \\wsl.localhost\Ubuntu).
  5. Leave the "Reconnect at sign-in" and "Connect using different credentials" options as they are.
  6. Click "Finish".

This creates a network drive that provides direct access to your WSL 2 file system from Windows.

Step 2 - Configure PhpStorm Terminal Settings

Next, you need to configure PhpStorm to use PowerShell as the terminal:

  1. Open PhpStorm.
  2. Go to Settings (File > Settings or Ctrl + Alt + S).
  3. Navigate to Tools > Terminal.
  4. In the "Shell path" field, enter powershell.exe -NoLogo.
  5. Make sure option Run Commands using IDE is checked.
  6. Click "Apply" and "OK".

Step 3 - Open Your Project from the Network Drive

Now you need to open your project from the network drive you created.

  1. In PhpStorm, go to File > Open.
  2. Navigate to your network drive (e.g., X:).
  3. Find and open your project.

Or navigate to the folder and use the Windows context menu (option "Open Folder as PhpStorm Project").

Once you open the project from the network drive, Junie should be able to execute terminal commands.

Step 4 - Executing commands in WSL environment (optional)

If you want to execute commands directly in your WSL environment using PhpStorm's terminal, follow the steps below.

  1. Open the terminal window in PhpStorm.
  2. Click the chevron icon next to the plus icon in the terminal window.
  3. Select your WSL distribution (e.g., "Ubuntu").
  4. Navigate to your repository's folder with cd.
  5. Enter your command and press enter to execute it.

Troubleshooting

If you still encounter issues with Junie executing terminal commands in WSL 2, check the following:

  • Make sure your network drive is properly mapped and accessible
  • Verify that PhpStorm is configured to use PowerShell as the terminal
  • Ensure you've opened your project from the network drive
  • Restart PhpStorm after making configuration changes

Tip

For the best experience you should use the latest versions of PhpStorm, WSL 2 and Junie.

Conclusion

By following these steps you should be able to solve the problem of Junie not being able to execute terminal commands in your WSL 2 environment. I did not have any problems like PhpStorm slowing down due to the use of a network drive instead of the regular access.

If Junie still isn't able to execute terminal commands after following this guide, just copy the repository outside WSL 2 and run it locally. This should always work. Once finished, you can copy the changes back to the folder in your WSL 2 environment.

It's nice to get it working, but let's hope this workaround won't be needed in the future!

More articles

[DEV] - How to fix error "SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'"

Occasionally, a WSL 2 with Laravel Valet setup changes the MySQL plugin for user authentication. In this article we'll show you how to switch it back.

Read more

[IT] - Bluetooth stopped working and disappeared in Windows 11

Lost connection with all bluetooth devices on your Windows 11 machine? I recently did. There might be a very simple fix for this. All it takes is some patience.

Read more

Sign up without commitment and tell us about your project