BufferedProcess and $PATH


When trying to run a command I get a lot of issues with paths because BufferedProcess does not gram the users bash_profile thus none of the users $PATH settings. Is there any way to fix this? is it a bug?


You’re running into the same issue we’ve found when working on atom-script. Here’s some info on it https://github.com/rgbkrk/atom-script/issues/61


Is there any way to fix this? Is it a bug?

You’ll get reliable behavior if you open atom from the terminal instead. Atom launched from the Icon loads variables the launchctl/launchd way.

I’m not sure what sort of interesting side effects would happen by having launchctl somehow get all the environment variables from sourcing ~/.bash_profile. It’s short sighted though in that some people use fish or other shells.

The right way to do this is to launch atom from the terminal.

What happens when you have different versions of node that you’re working with? (think nvm)
What happens when you’re working in a virtualenv?


You probably already know this, but I would make sure to set these options for BufferedProcess:

    # Default to where the user opened atom
    # Use the environment variables the user has set up
    options =
      cwd: atom.project.getPath()
      env: process.env
    # Contrived example
    command = "ls"
    args = ["-la"]
    stdout = (output) -> console.log("stdout", output)
    stderr = (output) -> console.log("stderr", output)
    exit = (return_code) -> console.log("Return code", return_code)

    # Run process
    @bufferedProcess = new BufferedProcess({command, args, options, stdout, stderr, exit})

Not able to spawn npm modules from Electron Package in OS X [solved]

This is what worked:

module.exports = function(callback) {
var sh = require("child_process").spawn("sh", [
    "source ~/.bash_profile; env"
var result = "";
sh.stdout.on("data", function (data) {
    result += data.toString();
sh.on("close", function () {
    var env = {};
    var lines = result.split("\n");
    for (var i = 0; i < lines.length; i++) {
        var kv = lines[i].split("=", 2);
        env[kv[0]] = kv[1];



That will work for some use cases. I really hope they don’t jam that in as part of BufferedProcess though. I definitely want access to whatever envs I have available across separate terminals or projects.


Hi~ @mattapperson
I’m so glade to see you here. I am titanium developer. :smile:

I would like to solve same problem.
Which is the best way to run BufferedProcess with $PATH?
Any news?



There is a fix for this problem in v1.7-beta:


@leedohm You are a Github staff now, right? :tada: :tada: :tada: