Skip to content

add info about using nvm to package-manaager.md #1129

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

Merged
merged 4 commits into from
Feb 13, 2017

Conversation

danbev
Copy link
Contributor

@danbev danbev commented Feb 5, 2017

Adding information about a way of using nvm to use version of
Node.js built from source.

Adding information about a way of using nvm to use version of
Node.js built from source.
[nvm](https://github.com/creationix/nvm) by installing into the location that nvm expects:

```bash
$ make install DESTDIR='$(NVM_DIR)/versions/node/' PREFIX='$(FULLVERSION)-pre'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use nvm_version_path "$VERSION" so as to not hardcode the path - i'm much more likely to break the path than I am to break that internal nvm function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb Sorry about this, I was not ignoring you suggestion but failed to get it to work for me. I'm not exactly sure about the cause for this not working yet but from within the Makefile the nvm_version_path function cannot be found. I'm not sure if this is because it is a function. I'll take another look tomorrow, but let me know if you have any ideas or suggestions on this. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will only be found if nvm.sh is sourced, and NVM_DIR should only be set if the profile file is sourced (which sources nvm.sh for you). If necessary, you'll want to source nvm.sh in the Makefile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we would want to source nvm.sh from the Makefile. I think the Makefile should stay unchanged and not have anything nvm specific.

I've looked into exporting the function but this looks like it would not be supported by all shells.

I'm suggesting that we change this to be DESTDIR=~/.nvm/versions/node/ and then document that if nvm has been installed into a different location then the path must be updated to reflect that.

What do you think about that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function itself is POSIX-compliant, so it should work in any POSIX-compliant shell.

I think that it depends on if your goal is correctness/robustness or convenience. Correctness requires using the same NVM_DIR env var that the user will use, and robustness requires not hardcoding the nvm dir's structure. Could you run a separate bash script that sources nvm.sh, and output the version path, and run that from the Makefile?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you run a separate bash script that sources nvm.sh, and output the version path, and run that from the Makefile?

Would be enough just to pass a dummy version to nvm_version_path and use the path, without the dummy version, and then send that path to make?

Something along the lines of :

$ make install DESTDIR=`nvm_version_path 999|sed s/999$//` PREFIX='$(FULLVERSION)-pre'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because nvm_version_path does different things depending on the version number.

Copy link
Contributor Author

@danbev danbev Feb 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because nvm_version_path does different things depending on the version number.

After running declare -f nvm_version_path I see what you mean. Thanks

So another attempt:

$ env VERSION=`python tools/getnodeversion.py` make install DESTDIR=`nvm_version_path v$VERSION` PREFIX=""

Perhaps not pretty but might an acceptable solution until support for this lands in nvm like you mentioned before?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems much better, thanks!

I've tried to use the nvm_version_path function but have failed to get
it to work from within the Makefile. I don't think sourceing nvm.sh from
the Makefile is good as I don't think it should be aware of any package
mangers. The idea of using Make install was that it is just using what
is already there and does not have to modify anything.
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@danbev
Copy link
Contributor Author

danbev commented Feb 12, 2017

Would someone will commit rights to this repo be willing to merge and push this or grant me commit rights so I can push it?

@sotayamashita
Copy link
Contributor

sotayamashita commented Feb 13, 2017

@fhemberger Could you review and merge it, if no problem.
cc: @nodejs/website

@@ -289,6 +290,28 @@ Or install a binary package (if available for your platform) using pkgin:
pkgin -y install nodejs
```

## nvm
On Unix / OS X systems Node.js built from source can be installed using
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a sentence or two about installing nvm in general and using it to install Node.js, not just how to add builds from source to it? Thx.

Otherwise LGTM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please strongly stress using the sole supported installation method - the curl command in the readme - over alternative unsupported methods of installation :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fhemberger @ljharb I've added some information in general (very short) about nvm and install instructions. Let me know what you think. Thanks

@fhemberger
Copy link
Contributor

LGTM!

@fhemberger fhemberger merged commit d6f82f0 into nodejs:master Feb 13, 2017
@fhemberger
Copy link
Contributor

Thanks again!

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

Successfully merging this pull request may close these issues.

4 participants