Issue using node installed version of sf CLI

Issue #2642 open
Christopher Matos created an issue

I’m no longer able to use the npm installed executable of the sf CLI. Due to restrictions in my company installing from the SF website, we install sf CLI in our MacOS machines using npm. Using the commands on the command line work but in IC settings I’m not able to select the node sf executable file. It used to auto select it for me and now even when I open the finder and select the file it doesn’t properly set it

Comments (3)

  1. Scott Wells repo owner
    • changed status to open

    Hi, Christopher. What is the exact nature of the issue? I'm currently using an NPM-based install on both my Windows/ARM64 machine and on one of my Mac test machines without issue.

    Perhaps the most relevant question is how sf is being added to $PATH as that's how IC2 derives its location. I'd start by investigating that and making sure that the IDE process is properly picking up the $PATH environment variable with sf in the execution path.

  2. Christopher Matos reporter

    When I click Reset the executable path in the Salesforce DX tab it is empty. I can see the node path in my $PATH environment variable, I’m not sure how to confirm the IDE process is picking it up though

  3. Scott Wells repo owner

    Things are a bit more complicated on Mac when the IDE is launched from the GUI. Here’s JetBrains' information on the topic:

    On macOS, things are complicated. An app launched by a GUI launcher (Finder, Dock, Spotlight etc.) receives a pretty empty and useless environment, since standard Unix ways of setting variables via e. g. ~/.profile do not work. What's more important, there are no sane alternatives. This causes a lot of user complaints about tools working in a terminal not working when launched from the IDE. To ease their pain, the IDE loads a shell environment (see getShellEnv for gory details) and returns it as the result. And one more thing (c): locale variables on macOS are usually set by a terminal app - meaning they are missing even from a shell environment above. This again causes user complaints about tools being unable to output anything outside ASCII range when launched from the IDE. Resolved by adding LC_CTYPE variable to the map if it doesn't contain explicitly set locale variables (LANG/ LC_ALL/ LC_CTYPE). See setCharsetVar for details.

    The referenced getShellEnv method actually runs a shell and uses printenv to get the environment from the perspective of the shell itself, then tries to merge that into its environment.

    One easy way to know whether it’s environment inheritance or not is to start the IDE from the shell using its startup script instead of from the GUI. If IC2 finds sf when started from the shell but not when started from the GUI, it means that the GUI-launched IDE process isn’t currently getting access to the correct $PATH. You might try moving where you set it to another location, e.g., from .profile to .bash_profile, .zshrc, or similar (not knowing which shell you use or how you configure it).

  4. Log in to comment