-
Notifications
You must be signed in to change notification settings - Fork 26
BUG: builder envs does not get same base env ($PATH etc.) as builder run on Node 4+ #63
Comments
@exogen -- Can you please create a reproduction for this and point me to it? For reference, |
@exogen -- Also when running |
@ryan-roemer: Sure thing – try cloning this repo: https://github.com/exogen/builder-test git clone https://github.com/exogen/builder-test
cd builder-test then: npm install
npm run test
builder run test
builder envs test '[{ "FOO": 1 }]'
EDIT: Made it echo
npm run test:
builder run test:
builder envs test:
|
Does not error and successfully runs for me:
My |
@ryan-roemer: Hmm, maybe a Node/npm version? $ node -v
v4.2.3
$ npm -v
3.5.2 |
@ryan-roemer Works for me with Node v0.12.7 and same npm (3.5.2), so the difference is with Node 4. |
Confirmed error:
Logged out |
Cuhrazy. var taskShOpts = _.merge({}, shOpts, { env: taskEnv });
console.log("TODO HERE taskShOpts", taskShOpts.env); in { MANPATH: '/Users/rroemer/.nvm/v0.10.40/share/man:',
NOTEBOOK_URL: 'http://localhost:8000',
rvm_bin_path: '/Users/rroemer/.rvm/bin',
VIRTUALENVWRAPPER_PROJECT_FILENAME: '.project',
// ... TONS OF STUFF ...
NODE_PATH: '/Users/rroemer/scm/fmd/builder-test/node_modules',
FOO: 1 } vs. { FOO: 1 } CULPRIT: Different |
@exogen -- The following code: var taskShOpts = _.cloneDeep(shOpts);
taskShOpts.env = _.extend(taskShOpts.env, taskEnv); appears to work for https://github.com/FormidableLabs/builder/blob/master/lib/runner.js#L231 if you've got a moment to refine that and PR it up... |
That is nuts, and I think I figured out why. In node 0.12: > require("lodash").isPlainObject(process.env)
true In node 4: > require("lodash").isPlainObject(process.env)
false So I think your solution works because |
`builder envs` did not work on Node 4+ because `_.merge` was behaving differently due to `process.env` no longer being a plain object. This clones `shOpts` (which contains `env`) so that merge works as expected. I considered `_.toPlainObject(process.env)` in `environment.js` in place of this fix, to fix the problem at its source. That worked, but I was fearful of the implications as Environment explicitly says that `env` is "Environment object to mutate" - and using that fix we'd no longer be mutating `process.env` but a copy. Fixes #63 /cc @ryan-roemer
If my
test
command is something likemocha
orwdio
that comes fromnode_modules
,builder run test
works fine, butbuilder envs test --envs-path=envs.json
spits out:Builder should start out with whatever
$PATH
additions come standard withbuilder run
, then merge in stuff fromenvs
on top of that.(In case it matters: I'm using Builder just for its task running features, without an archetype.)
The text was updated successfully, but these errors were encountered: