Using WSL with Illuminated Cloud and SFDX

219 views
Skip to first unread message

Brooks Johnson

unread,
Jun 26, 2021, 11:34:58 AM6/26/21
to Illuminated Cloud General Discussion
Hi Scott,

I was wondering if you had a solution to this.  I have SFDX installed and like to use WSL2 on my machine with z-shell.  I don't seem to be able to get Illuminated cloud to work with the cli executable in WSL.  I get a not valid win32 error.  Below is an example of the file path. 

Best,

Brooks

Screenshot 2021-06-26 113348.png

Scott Wells

unread,
Jun 26, 2021, 11:42:33 AM6/26/21
to Illuminated Cloud General Discussion, brooksjo...@gmail.com
Brooks, the path specified to IC2 must be a Windows native executable or batch file. You're going to need to create a wrapper batch file that in turn executes something like "wsl sfdx ..." and properly propagates the exit code back to the caller so that stdout, stderr, and the process exit code are all conveyed properly via the intermediate batch file. I know a few folks have done this already, though I don't have the exact syntax handy.

Regards,
Scott Wells

Scott Wells

unread,
Jun 26, 2021, 1:11:46 PM6/26/21
to Illuminated Cloud General Discussion, Scott Wells, brooksjo...@gmail.com
Someone else just replied on this topic directly as also interested in this. I don't have WSL/2 installed in my current machine but could likely mock up a wrapper script against Cygwin which I do have installed, and the real difference should be the executable invoked by the wrapper script. What you'll fundamentally need in that wrapper script is:
  • Disable all script output via "@echo off" immediately so that only the invoked executable's output/error streams are reflected to the caller.
  • Pass all input arguments exactly to the invoked executable.
  • Capture the exit code of the invoked executable and use it as the exit code of the wrapper script.
Then you can register the wrapper script as IC2's Salesforce CLI executable path.

I will remind that Salesforce no longer claims support for the Salesforce CLI in WSL/2, though they also don't support it in Cygwin and that's how I use it.

I won't likely have time today--or likely this weekend--to put together an example wrapper script, but once I do I'll post it here for folks to try. If someone else puts together one that works well, feel free to share it here.

Oh, and if you're having performance issues with the Salesforce CLI under Windows, I strongly recommend that you look at their installation instructions for Windows and make sure that you've registered the recommended Windows Defender exceptions for the CLI. After doing so, it's not quite as fast on Windows as on Mac/Linux, but it's very close and MUCH faster than if you don't register those exceptions.

Regards,
Scott Wells

Scott Wells

unread,
Jun 29, 2021, 4:26:45 PM6/29/21
to Illuminated Cloud General Discussion, Scott Wells, brooksjo...@gmail.com
Okay, I have good news and I have bad news. The good news is that the following is an effective wrapper script, at least in terms of raw inputs and outputs:

@echo off
wsl.exe /usr/local/bin/sfdx %*
exit /B %ERRORLEVEL%

The bad news is that it doesn't really work all that well after all. I was able to authorize an OAuth org--specifically a dev hub--and then create a scratch org, and I was able to do some things against that org, but then other operations started to fail. In particular metadata retrieval failed because it tries to run the CLI using Windows-native paths that aren't recognized by the Linux-native CLI instance running in WSL. You could probably write a more complex wrapper script that translates Windows paths to Linux paths before passing the command-line args, but I'll leave that as an exercise to the reader, so to speak.

Again, if you're seeing poor performance with the Windows-native version of the Salesforce CLI, please let me know as I've had long discussions with some folks on the CLI team and actually have it running pretty nicely IMO these days. As I said previously, it's not quite as fast as the native versions on Mac or Linux, but it's perfectly acceptable.

Regards,
Scott

Brooks Johnson

unread,
Jul 1, 2021, 7:30:56 AM7/1/21
to Illuminated Cloud General Discussion, sc...@illuminatedcloud.com, Brooks Johnson
Hi Scott, thanks for checking on this, and sorry for the late response.  I have no issues with the Windows version of the CLI and agree that it runs fine. I just use WSL for all no SF development. And always end up having to switch over to Power Shell to do SFDX tasks. Maybe a symlink between directories would solve some issues.

Phieu Dinh

unread,
Mar 11, 2025, 12:20:57 PMMar 11
to Illuminated Cloud General Discussion, Brooks Johnson, sc...@illuminatedcloud.com

Sorry to revive an old thread, but I was wondering if there have been any improvements on this front

I just gave Illuminated Cloud with WSL a try, and it doesn't seem to recognize that I'm in an SFDX project. Initially, it did recognize it and gave me the usual 'Invalid configuration' prompt

However, halfway through, after generating the offline symbol table, it prompts again with the following error, and all the intellisense disappears:

'Failed to set the target org for module 'project1' to 'dev-sandbox': • This directory does not contain a valid Salesforce DX project.'

I wonder if it's IC2 failing to recognize something at a later stage, because everything works fine until that prompt appears

Scott Wells

unread,
Mar 11, 2025, 12:28:32 PMMar 11
to Illuminated Cloud General Discussion, Phieu Dinh, brooksjo...@gmail.com, Scott Wells

No, nothing has really changed in this area. The last time I checked, the same issues described in my last response here were still present, and things like sf org login web either didn’t work or required a significant amount of setup to allow them to work using a Linux-based browser.

I know it’s not likely the answer you’d like to hear, but if you’re planning to use WSL, I would recommend using the Linux-based JetBrains IDE with it. There’s just too much of a disconnect between an IDE running under Windows and a Salesforce CLI running under Linux/WSL, at least based on my own experience.

Regards,
Scott Wells

Reply all
Reply to author
Forward
0 new messages