-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Fix support for installing node on SmartOS #854
Conversation
I'm not sure how to write unit tests for Also, currently without these changes and as of commit 8aebf86, when running I tested these changes on SmartOS with bash, and on OSX with sh, ksh and zsh. |
@@ -1485,7 +1502,7 @@ nvm() { | |||
if [ "_$NVM_OS" = "_freebsd" ]; then | |||
# node.js and io.js do not have a FreeBSD binary | |||
nobinary=1 | |||
elif [ "_$NVM_OS" = "_sunos" ] && ([ "$NVM_IOJS" = true ] || [ "$NVM_NODE_MERGED" = true ]); then | |||
elif [ "_$NVM_OS" = "_sunos" ] && [ "$NVM_IOJS" = true ]; then |
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.
It looks like https://iojs.org/dist/v3.3.1/ is the only io.js
version that has a sunos
binary - could we change this to only set nobinary to 1 if the version is less than v3.3.1
?
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.
Sure, no problem.
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.
Updated the PR according to this comment.
f4a69e6
to
8241fcb
Compare
This seems like a great change - thank you! The things I'll need to think about before being confident enough to merge it:
I'll test this out myself tonight/tomorrow, and ask a few others to do so as well, to help with this. |
I'm still thinking about how to write a test that would not be the exact copy of the implementation itself :)
Do you mean to manually check if this change works on sunOS? |
no, i mean, add something to travis that would ensure this doesn't break in the future |
@ljharb Actually, I can probably just mock Sounds good? I'll update that PR soon, although maybe not tonight. |
For Are |
|
8241fcb
to
b9c13c4
Compare
Updated this PR with a first shot at writing tests for EDIT: obviously, tests for other archs/OSes then {SmartOS,OSX}/{x64/i386} are missing, I'll add more if we validate this approach. |
e449b03
to
b3050ee
Compare
# isainfo to get the instruction set supported by the | ||
# kernel. | ||
if [ "_$NVM_OS" = "_sunos" ]; then | ||
HOST_ARCH=$(pkg_info -Q MACHINE_ARCH pkg_install) |
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.
should this check nvm_has pkg_info
? currently if it fails, it'll fall through to echoing the empty string, which isn't likely what nvm_get_arch
should do.
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.
Right, good catch 👍 The original intent was to catch this case with:
if [ $EXIT_CODE -ne 0 ]; then
HOST_ARCH=$(isainfo -n)
fi
but the local
command before the test for $?
would overwrite $?
. So I moved the local
declaration at the top of the function and left it as is. I also added tests to catch that problem.
I think having a nvm_has_pkg_info
function is a bit overkill for this use case, but If you'd still prefer to handle it that way I'm fine with it too.
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.
We already have nvm_has
- i don't mean a new function, i mean calling nvm_has
with the argument pkg_info
Thanks, I think this is almost there! I'll test it out myself today, since my comments are mostly about tests. |
@ljharb Updated this PR according to your feedback. I've been adding commits to make changes related to code reviews easier to separate from the rest, but obviously once this is ready to land I'll squash them into one commit. |
b419a03
to
94b93e4
Compare
if [ "_$1" = "_-n" ]; then | ||
echo "amd64" | ||
else | ||
echo "amd64 i386" |
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.
s/\t/ /
I've tested this out, and it looks good - some tab characters to replace with spaces, but otherwise please rebase as you see fit, and I'll merge! |
@ljharb That's great, thank you for the thoughtful and kind reviews, I really appreciate it. Will update and squash soon. |
uname on SmartOS cannot be used to guess if 32 and/or 64 bits binaries are supported, and its output is different than other uname commands on other operating systems. This change uses pkg_info to determine what types of binaries pkgsrc would install. If pkg_info fails to run or is not present, this change falls back to using isainfo -n, which determines what the kernel supports. It allows users to install node binaries on Solaris derivatives. io.js can also be installed on Solaris derivatives starting with version v3.3.1.
94b93e4
to
2d692d9
Compare
Fixed the two formatting issues, and squashed all commits into one. |
Fix support for installing node on SmartOS
Thanks for being so thorough with this PR! |
@ljharb Thank you for merging it! Do you know when that will make it into a release? I know significant users of node and SmartOS who are looking forward to being able to use nvm on SmartOS :) |
Released in |
@ljharb That's great, thank you very much once again for your help! |
uname
on SmartOS cannot be used to guess if 32 and/or 64 bits binariesare supported, and its output is different than other
uname
commands onother operating systems.
This change uses
pkg_info
to determine what types of binariespkgsrc
wouldinstall. If
pkg_info
fails to run or is not present, this change fallsback to using
isainfo -n
, which determines what the kernel supports.This change also allows users to install node binaries from Solaris
derivatives. It doesn't remove the limitation that prevents them from
installing io.js binaries because not all io.js versions have binaries
for Solaris derivatives.