Does it work if you quit Sublime and then launch Sublime from a terminal rather than starting Sublime from your window manager (e.g. the dock, etc)? If so, then you may be able to get it working by logging out and in again (or in extreme cases, rebooting).
Basically the idea here is that programs inherit the environment of the task that launches them. If you modify your .profile
while youâre logged in, then your window manager doesnât see the change to the environment until it restarts, so it launches programs with the old environment and they donât see the path. Lauching a terminal executes bash
which sets up a new environment based on its own profile files.
It may also help to use shell_cmd
in place of cmd
, which makes Sublime tell bash
to execute the command instead of trying to find and launch it directly. Or alternatively add "shell": true
if youâre using cmd
so that the underlying Python library knows that it should ask bash
to do the same thing.
If all else fails you can add a line to the build to get the build system to modify the path directly.
If youâre using cmd
, then you can add this:
"path": "/flutterpath:$PATH"
That tells Sublime to modify the $PATH
before it launches the program, and adjust it back once the build is done. That would make sure that the environment that Sublime has definitely includes the correct item.
If instead youâre using shell_cmd
, then you can do something like this instead:
"env": {
"PATH": "/flutterpath:$PATH"
},
This tells Sublime to adjust the $PATH
of the program while itâs running. So you canât use it to find the item in cmd
because until itâs actually running, the path isnât modified, and it canât be found because the path hasnât been modified yet.
All else being equal I personally think itâs a better idea to use the env
route (and shell_cmd
) because currently the exec
command will not fix the path if the build fails in various ways, which can potentially lead to clobbering the $PATH
and requiring you to restart Sublime.
Possibly adding the item to your .bashrc
may help as well; bash
only loads the .profile
file (or the other named variants) for a login shell. Iâm not sure what Python is doing internally when you use cmd
to launch a task though.