Connections not available in SFDX

Issue #1332 resolved
Justin Julicher created an issue

Would be good to be able to refresh SFDX connection list.

Currently I have to restart Webstorm to make a SFDX connection appear once I have initialised it via the CLI. Would be good to have an option to manually refresh the list rather than having to restart Webstorm.

Comments (9)

  1. Scott Wells repo owner

    IC should be managing this for you by monitoring changes to files under ~/.sfdx, in particular alias.json and the various <username>.json for the configured connections. When these files change you should see an entry in the log like The following files have been modified since <timestamp>: { <file1>.json, ... }. If there's something you're doing that should lead to a connection list refresh but isn't, do you mind sharing the steps to reproduce so I can see why this cache management strategy isn't working? In the interim, the workaround would be touch ~/.sfdx/alias.json, but of course under normal conditions that shouldn't ever be necessary (unless you're testing this functionality).

  2. Justin Julicher reporter

    arghhh sorry I’ve switched to windows use WSL and of course my alias file is not linked to the directory under my windows profile. (I just got a new Dell XPS laptop and ubuntu /displaylink can’t recognise the new USB3 dock)

    I can’t symlink the directory because the key.json files requires a mod of 600 and WSL gets full rights to any windows files ie. 666.

    Hmm now the question is can you run the SFDX runtime under WSL? ?

    thanks

  3. Scott Wells repo owner

    Ah, okay. That's a good question. I know that you can run Windows binaries from a WSL runtime/shell, but I'm not sure if the same is true vice-versa...at least not directly.

    Slight pause while I tinker...

    Well I'll be...I actually have a script called wsl_sfdx.bat in my execution path that I wrote some time back:

    @echo off
    wsl /usr/local/bin/sfdx %*
    exit /b %errorlevel%
    

    I have no idea if that works or not anymore, but I imagine you'd need something like that registered with IC, and you'd also need to make sure that WSDL's sfdx binary is using %USERHOME%\.sfdx for its config files for IC to know when things have changed.

    I can't guarantee compatibility--at least not without some bug fixing--but I confess that I'm quite curious as to your findings.

  4. Justin Julicher reporter

    Ok, so there’s a bit of fiddling to do but it can be used with WSL.

    As I used NVM to install node in wsl, when you run wsl from the command line it doesn’t run your .bashrc or .zshrc so your path variable won’t include the nvm install bin dir.

    so in wsl you need to locate your node or sfdx cli and ensure that is added to this registry key:

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\DefaultEnvironment (under this REG_MULTI_SZ there is a PATH variable) and add the path variable to this.

    I should also note that I disabled interop options to append the Windows path to the linux path.

    Once that was done I symlinked the alias.json file from my windows .sfdx dir to my wsl .sfdx so that detection could work.

    now if I touch the alias.json file webstorm will redect the credentials and I can use the oh-my-zsh sfdx plugin for command completion!!

    happy days.

  5. Justin Julicher reporter

    about to install WSL 2 and see how that works.

    edit:

    Doesn’t look like wsl 2 works - Webstorm just freezes for some reason log only outputs that it’s loading sfdx connections and then nothing else - have to kill it via task manager.

  6. Justin Julicher reporter

    Yeah - would be good to get it working in WSL 2 but WSL 1 works for now.

    thanks for your helpl

  7. Scott Wells repo owner

    I'm going to resolve this given the nature of the discussion and success getting it working under WSL.

  8. Justin Julicher

    Hi Scott,

    I know this is a bit old but as Jetbrains has upgraded their WSL support would you be able to add first class support for WSL as well?

    In Webstorm/IntelliJ you can open a project on a WSL Path (Using WSL 2). It would be good if you could link to a SFDX command on the WSL path e.g.

    \wsl$\Ubuntu-18.04\home\justin.nvm\versions\node\v14.11.0\bin\sfdx

    If you find that command you then execute that under the WSL.

    As I use WSL2 for sfdx command line completion and oh-my-zsh this would come in handy.

    I currently have a sfdx.cmd file that works for windows directories but not WSL loaded projects. Which is good enough for me at the moment.

    sfdx2.cmd:

    @echo off
    cd c:\
    set v_params=%*
    set v_params=%v_params:\=/%
    set v_params=%v_params:c:=/mnt/c%
    set v_params=%v_params:"=\"%
    bash.exe -ic "sfdx %v_params%"
    

    Anyway I’ll leave it with you to contemplate.

    thanks

  9. Log in to comment