-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
os: add homedir() #1791
os: add homedir() #1791
Conversation
char buf[MAX_PATH]; | ||
#else | ||
char buf[PATH_MAX]; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node.h defines PATH_MAX on Windows so the #ifdef is probably not necessary here.
} else if (!common.isWindows && process.env.HOME) { | ||
assert.equal(home, process.env.HOME); | ||
delete process.env.HOME; | ||
assert.equal(home, os.homedir()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is a good assumption. I'd just check that it still returns something, possibly something that looks like a path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Updated.
LGTM. You should probably run the CI before landing this. |
I will once libuv is updated and I can remove the floating patch. |
lgtm, the duplication in test-os.js seems unnecessary but I guess it's consistent with what's in there |
Libuv 1.6.0 has landed. 👍 |
return -EIO; | ||
|
||
uid = getuid(); | ||
buf = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, buf
would be NULL
only.
Floating patch removed. CI: https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/766/ |
@rvagg the CI is still running, but I'm seeing some strange failures. Unable to compile on SmartOS, out of memory errors on FreeBSD, and too many files open on CentOS. Anything odd going on with the build? |
@cjihrig eeek, not that I'm aware of, @jbergstroem has been tinkering on CentOS5 but not the others. |
I'll have a look. |
Affected os:es seems to hit file-max
Jenkins has <100 file descriptors open which leads me to believe that ccache might try to. I can't say I've seen it previously, but I'll keep digging. |
Looking at |
(for reference, the run I'm measuring is here: https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/767/) |
So yeah, I'm unable to reproduce what happened at that specific run. Jenkins. |
Added Updated CI run: https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/769/ |
I speculate it's because of this. :-) (IIRC, I pointed that out in the review, that sysconf() can return < 0, but I'm not 100% sure. At any rate, (EDIT: That may have been another PR, come to think of it.) |
@bnoordhuis you did mention that. The data type for EDIT: this has a good example that calls |
@bnoordhuis you were right, so I added a37072b as a floating patch on libuv, and the CI is much happier now. Let me know how you want this handled in libuv. |
@cjihrig Left a comment. Can you file that as a libuv PR? We'll do a patch release for that. |
Ah, should've tested the branch while searching for issues; I just assumed it was lingering processes or similar. |
@bnoordhuis if I update the floating patch here, is this OK to land? EDIT: Removed the floating patch since the libuv update PR was opened. |
PR-URL: #1905 Refs: #1791 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Thanks @saghul. Hopefully one last CI run: https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/774/ |
Hmmm.. freebsd isn't so happy. https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/774/nodes=freebsd101-64/tapTestReport/ |
os.homedir() calls libuv's uv_os_homedir() to retrieve the current user's home directory. PR-URL: #1791 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
It would help if I rebased the branch to include the libuv 1.6.1 update. https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/775/ is all green. Landed in 6e78e5f. |
Notable Changes: * libuv: Upgraded to 1.6.0 and 1.6.1, see full ChangeLog for details. (Saúl Ibarra Corretgé) #1905 #1889. Highlights include: - Fix TTY becoming blocked on OS X - Fix UDP send callbacks to not to be synchronous - Add uv_os_homedir() (exposed as os.homedir(), see below) * npm: See full release notes for details. (Kat Marchán) #1899. Highlight: - Use GIT_SSH_COMMAND (available as of Git 2.3) * openssl: - Upgrade to 1.0.2b and 1.0.2c, introduces DHE man-in-the-middle protection (Logjam) and fixes malformed ECParameters causing infinite loop (CVE-2015-1788). See the security advisory for full details. (Shigeki Ohtsu) #1950 #1958 - Support FIPS mode of OpenSSL, see README for instructions. (Fedor Indutny) #1890 * os: Add os.homedir() method. (Colin Ihrig) #1791 * smalloc: Deprecate whole module. (Vladimir Kurchatkin) #1822 * Add new collaborators: - Alex Kocharin (@rlidwka) - Christopher Monsanto (@monsanto) - Ali Ijaz Sheikh (@ofrobots) - Oleg Elifantiev (@Olegas) - Domenic Denicola (@domenic) - Rich Trott (@Trott)
I made a polyfill for anyone wanting to use this while still supporting older node/io versions: |
Do not land this yet.
This PR adds
os.homedir()
, which calls libuv'suv_os_homedir()
to retrieve the current user's home directory. This is an alternative to #1670. This PR currently consists of two commits. 6887116 is the libuv update, which has not landed in io.js yet. This commit should be removed once a proper update is in place. e7e5992 is the io.js update.