1

I am trying to setup the 'best' environment for using DX for all my development work, specifically the 'best' Command Line tool. I am running Windows 10 and use Illuminated Cloud + Webstorm as my main IDE. I was able to get the regular windows cmd.exe to work just fine as my Terminal, but many, if not all the examples of extending the CLI are using some form of Bash (I think all SFDC engineers use Macs now). For instance, I was hoping to get something like this auto completion to work in my command line tool.

So I decided to give the Windows Subsystem for Linux (WSL) a try since that feels like it would be the best option for getting BASH scripts to work in a Windows environment, and unlike Git Bash and other tools, it is supposed to be supported if I understand the docs correctly.

I was able to get the command tool installed in the WSL running Ubuntu, but I cannot get the force:auth:web:login to work. After some digging around, it looked the issue might that it needs the PATH set for the browser to work. So I did that, and I am able to execute chrome.exe and sensible-browser as commands and they launch Chrome in an empty window. I was able to get the command to launch a browser window at some point, but the URL just had

'https/'

in the URL bar. When I installed the CLI in a virtual Linux box, I was able to get it to work, so seems to be something to do with how the WSL interacts with the host windows environment ( at a core level I realize it isn't designed to work with the GUI)

So has anyone made this setup work? Or I am just wasting my time? Is the WSL just designed for CI type interactions that don't require any browser interactions? And if so, what terminal tools are folks using with Windows 10? Pretty much every demo and doc I read is assuming the user is on a Mac, so is there a good way I can setup DX on Windows but still take advantage of the other tools folks are building for the CLI?

3
  • 1
    I've had great luck with GitHub's bash, FYI.
    – sfdcfox
    May 4, 2018 at 15:16
  • 1
    DX works fine for me on both Windows 10 and Windows 7 using Git Bash + VSC (no WSL). I also can't get Wegner's auto complete to work correctly, but core functionality is fine.
    – David Reed
    May 4, 2018 at 15:22
  • Thanks - I think I need to embrace the windows options - I am going to try out some tools that seem to mimic the auto-completion/text snippet stuff May 4, 2018 at 21:20

2 Answers 2

2

I have not tried this personally, but a Salesforce engineer gave me this info. Install google chrome into the ubuntu WSL. Also run xming, which is an X-Window server for Windows. I don't currently have access to my windows machine, so that is all the detail that I have just now.

2
  • Thanks- I'll give that a go just to see if I can get the thing to work now! May 4, 2018 at 21:18
  • So the solution offered by @dave-carroll does work, but I would caution it is not a great user experience. Based on his answer, I found this article which was the missing link for me (ethanvanderbuilt.com/…) - if you follow that you'll get the browser to open. But - it is the browser from Ubuntu - not your Windows browser so lacks any plugins etc. So if you need the WSL to run stuff like CI and just need to auth the DevHub, this at least lets that work, but I would avoid WSL as your regular terminal May 5, 2018 at 0:28
6

You should be able to get the web auth working without installing Chrome in Ubuntu or an X-Window server in Windows. This is courtesy of Mike Bordon in the Salesforce DX community. I had to install xdg-utils to get it working on my side, so I have added that step.

  1. Install xdg-utils

    apt-get install xdg-utils
    
  2. Create a script referencing your browser path in windows with the following:

    "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe" $1:$2
    
  3. Make the script executable

    chmod +x <path_to_your_script>
    
  4. Add the BROWSER environment variable to your profile referencing your script, I'm using zsh so my profile is ~/.zprofile, but you could be using ~/.profile or ~/.bash_profile if it exists

    export BROWSER="<path_to_your_script>"
    
  5. Reload your profile

    source <path_to_your_profile>
    
  6. Ensure your environment variable is set

    printenv
    
  7. Verify the open command is working

    xdg-open https://www.salesforce.com
    
  8. Add a connection using the sfdx web auth commands
3
  • 1
    Thanks - if that opens the Windows version of the browser that would be a big improvement May 5, 2018 at 13:49
  • Can confirm that this option works well. If only sfdx for WSL and sfdx.exe were in sync somehow with the org lists etc. Then everything would be perfect!
    – Matt Lacey
    Jul 20, 2018 at 5:37
  • @MattLacey I was able to get them in sync by using a symlink so they both referenced the same SFDX configuration, however that broke down quickly when the files had to be modified. Ultimately I ended up using Git Bash because it was becoming too much of a time suck. Aug 21, 2018 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .