GithubHelp home page GithubHelp logo

Comments (10)

ryan-roemer avatar ryan-roemer commented on May 18, 2024

@exogen -- Can you please create a reproduction for this and point me to it?

For reference, requirepack is already using builder envs (Just with straight string, not --envs-paths at https://github.com/FormidableLabs/requirepack/blob/master/.travis.yml#L48-L69 And like your project, requirepack is not using archetypes.

from builder.

ryan-roemer avatar ryan-roemer commented on May 18, 2024

@exogen -- Also when running envs can you log out process.env.PATH and paste it in this ticket? Thanks!

from builder.

exogen avatar exogen commented on May 18, 2024

@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 }]'

npm run and builder run work, the last one fails.

EDIT: Made it echo $PATH now too. Here's what I get: /usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.

$PATH from each:

npm run test:

/Users/brianbeck/.nvm/versions/node/v4.2.3/lib/node_modules/npm/bin/node-gyp-bin:/Users/brianbeck/Projects/Tests/builder-test/node_modules/.bin:/Users/brianbeck/.nvm/versions/node/v4.2.3/bin:./node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/brianbeck/bin

builder run test:

/Users/brianbeck/Projects/Tests/builder-test/node_modules/.bin:/Users/brianbeck/.nvm/versions/node/v4.2.3/bin:./node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/brianbeck/bin

builder envs test:

/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.

from builder.

ryan-roemer avatar ryan-roemer commented on May 18, 2024

Does not error and successfully runs for me:

$ builder envs test '[{ "FOO": 1 }]'
[builder:config:environment] {"cwd":"/Users/rroemer/scm/fmd/builder-test","dir":"/Users/rroemer/scm/fmd/builder-test/node_modules/builder/lib"}
[builder:config] Unable to load config file: .builderrc
[builder:builder-core:start:2158] Started: envs test
[builder:envs] Starting with queue size: unlimited
[builder:envs] Starting environment {"FOO":1} run for command: mocha
[builder:proc:start] mocha


  0 passing (2ms)

[builder:proc:end:0] mocha
[builder:builder-core:end:2158] Ended normally: envs test

My PATH logged out right before the exec is: /Users/rroemer/scm/fmd/builder-test/node_modules/.bin:/Users/rroemer/.nvm/v0.10.40/bin:/usr/local/heroku/bin:/Users/rroemer/.rvm/gems/ruby-2.0.0-p247/bin:/Users/rroemer/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/rroemer/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/rroemer/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Developer/Tools:/Users/rroemer/bin:/Users/rroemer/.gem/ruby/1.8/bin:./node_modules/.bin:/bin:/Users/rroemer/.rvm/bin

from builder.

exogen avatar exogen commented on May 18, 2024

@ryan-roemer: Hmm, maybe a Node/npm version?

$ node -v
v4.2.3
$ npm -v
3.5.2

from builder.

exogen avatar exogen commented on May 18, 2024

@ryan-roemer Works for me with Node v0.12.7 and same npm (3.5.2), so the difference is with Node 4.

from builder.

ryan-roemer avatar ryan-roemer commented on May 18, 2024

Confirmed error:

 $ node -v; npm -v
v4.1.2
3.4.0

$ builder envs test '[{ "FOO": 1 }]'
[builder:config:environment] {"cwd":"/Users/rroemer/scm/fmd/builder-test","dir":"/Users/rroemer/scm/fmd/builder-test/node_modules/builder/lib"}
[builder:config] Unable to load config file: .builderrc
[builder:builder-core:start:2386] Started: envs test
[builder:envs] Starting with queue size: unlimited
[builder:envs] Starting environment {"FOO":1} run for command: mocha
[builder:proc:start] mocha
/bin/sh: mocha: command not found
[builder:proc:end:127] mocha
[builder:proc:error] Code: 127, Command: mocha
[builder:builder-core:end:2386] Ended with error: envs test - Command failed: /bin/sh -c mocha

Logged out PATH in builder before exec contains bin with mocha: " /Users/rroemer/scm/fmd/builder-test/node_modules/.bin:/Users/rroemer/.nvm/v4.1.2/bin:/usr/local/heroku/bin:/Users/rroemer/.rvm/gems/ruby-2.0.0-p247/bin:/Users/rroemer/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/rroemer/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/rroemer/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Developer/Tools:/Users/rroemer/bin:/Users/rroemer/.gem/ruby/1.8/bin:./node_modules/.bin:/bin:/Users/rroemer/.rvm/bin"

from builder.

ryan-roemer avatar ryan-roemer commented on May 18, 2024

Cuhrazy. _.merge() works differently for:

      var taskShOpts = _.merge({}, shOpts, { env: taskEnv });
      console.log("TODO HERE taskShOpts", taskShOpts.env);

in 0.10:

{ 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. 0.4:

{ FOO: 1 }

CULPRIT: Different _.merge() behavior.

from builder.

ryan-roemer avatar ryan-roemer commented on May 18, 2024

@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...

from builder.

exogen avatar exogen commented on May 18, 2024

That is nuts, and I think I figured out why. merge behaves differently based on the result of isPlainObject.

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 cloneDeep will turn env into a plain object. I can open a PR shortly.

from builder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.