Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variable is undefined #24

Closed
jeromecovington opened this issue Mar 24, 2016 · 12 comments
Closed

Environment variable is undefined #24

jeromecovington opened this issue Mar 24, 2016 · 12 comments

Comments

@jeromecovington
Copy link

I can run this command with node, but when I run it with 0x it seems that process.env.BENCHMARK is undefined? Do environment variables not get picked up by 0x?

> env BENCHMARK='server/models/timeline' ./node_modules/.bin/0x node benchmark/single.js
module.js:339
    throw err;
    ^

Error: Cannot find module './undefined'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/home/jtkc/example/benchmark/single.js:3:14)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
Profiling
@davidmarkclements
Copy link
Owner

ooh interesting, we need to pass environment vars through to the sub process I think

@davidmarkclements
Copy link
Owner

you might be able to work around temporarily with

export BENCHMARK='server/models/timeline'
0x benchmark/single.js

@davidmarkclements
Copy link
Owner

@jeromecovington I'm not reproducing your problem here

test.js:

console.log(process.env.FOO)
$ env FOO='ok' 0x -d 0 test.js
ok

file:///Users/davidclements/z/0x/profile-8161/flamegraph.html

(using -d 0 set remove delay, has no effect on env recog.)

could you try the same isolated case?

@jeromecovington
Copy link
Author

I am getting undefined, but I am running the binary locally, is that the issue?
> env FOO='ok' ./node_modules/.bin/0x -d 0 test.js

@davidmarkclements
Copy link
Owner

no it's working for me - what version of 0x and what version of node are you running?

0x doesn't have a -v flag, but to get the version:

$ npm explore 0x 
bash-3.2$ grep version package.json

Going to add a -v flag

@jeromecovington
Copy link
Author

node 4.2.3
0x 2.2.4

@davidmarkclements
Copy link
Owner

what OS?

@davidmarkclements
Copy link
Owner

ah okay - you must be on linux - just tried on an ubuntu VM and able to reproduce

@jeromecovington
Copy link
Author

jeromecovington commented Mar 24, 2016 via email

@davidmarkclements
Copy link
Owner

yah okay - I know what it is - we have to run perf with sudo, which means the process runs with sudo which is a different environment and hence different env vars, fixing now

@davidmarkclements
Copy link
Owner

should be fixed: 88eae6f

caveat is if sudoers sec. policy disallows use of -E flag (I think this is (hopefully) a rare enough case to ignore)

2.2.5 released

@jeromecovington
Copy link
Author

Yep that sorted it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants