Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#53038 closed submission (fixed)

nvm @0.32.1: New port submission

Reported by: coditect (Nicholas Rawlings) Owned by: Franklin Yu <franklinyu@…>
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: ci42
Port: nvm

Description

I have created a Portfile for NVM, a version manager for Node. It differs from a normal install of NVM in the following ways:

  • NVM and NVM-managed version of Node are stored in $prefix/lib/nvm instead of ~/.nvm
  • NVM does not need to be initialized in ~/.profile. Instead, a script stored at $prefix/bin/nvm intercepts calls to nvm, and runs nvm.sh before passing control to the nvm() shell function. This process is less efficient, but greatly simplifies the use of NVM with sudo and multiple user accounts.

Suggestions and criticisms are greatly appreciated!

Attachments (2)

Portfile (1.3 KB) - added by coditect (Nicholas Rawlings) 8 years ago.
nvm_bin.sh (78 bytes) - added by coditect (Nicholas Rawlings) 8 years ago.
files/nvm_bin.sh

Download all attachments as: .zip

Change History (9)

comment:1 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ci42 added

"openmaintainer" is not valid as the only maintainer. If nobody maintains the port, the correct value is "nomaintainer".

Is there a specific reason why you wrote code to write a file? Usually, we put such files in the files directory and just copy them.

It would be easier to follow if you put the code relating to the bash_completion variant into the bash_completion variant.

I'll leave it to Christoph to decide whether it is a good idea to provide a port for nvm. (The way its use will cause unregistered files to be installed in $prefix/lib/nvm is for example undesirable, but I realize npm already does something similar.)

comment:2 in reply to:  1 ; Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to ryandesign:

Is there a specific reason why you wrote code to write a file? Usually, we put such files in the files directory and just copy them.

I see you use some variables in the script. Typically, we handle that by putting a @PLACEHOLDER@ in the file in the files directory, and then after you copy it to the right place, you can use reinplace to replace the placeholder with the real value.

I also see the script runs nvm using nvm $@. That won't work for arguments containing spaces. You need nvm "$@".

Changed 8 years ago by coditect (Nicholas Rawlings)

Attachment: Portfile added

Changed 8 years ago by coditect (Nicholas Rawlings)

Attachment: nvm_bin.sh added

files/nvm_bin.sh

comment:3 in reply to:  2 Changed 8 years ago by coditect (Nicholas Rawlings)

Replying to ryandesign: Thanks for the feedback, Ryan. I uploaded a new version of the Portfile that incorporates your suggestions.

I agree that leaving behind the contents of $prefix/lib/nvm/alias, $prefix/lib/nvm/.cache, and $prefix/lib/nvm/versions after uninstalling the port is undesirable. Is there any way to instruct MacPorts that those folders should be expunged during a port uninstall?

comment:4 in reply to:  1 Changed 8 years ago by coditect (Nicholas Rawlings)

Replying to ryandesign: Regarding the appropriateness of providing a port for nvm: I think a cleaner solution would be to allow multiple nodejs* ports to be installed side-by-side (they currently conflict) and choosing the active version of node through port select. I think the biggest difficulty with this approach would be switching between different versions of of npm and the node_modules folder in tandem with node itself.

comment:5 Changed 8 years ago by coditect (Nicholas Rawlings)

I have discovered several issues with the way that I set up this nvm port. Perhaps most problematic is the inconsistencies between $prefix/lib/nvm and a user's $PATH caused by running nvm with sudo. I am abandoning work on this project for now and would like to retract my Portfile submission.

comment:6 Changed 8 years ago by mf2k (Frank Schima)

Resolution: wontfix
Status: newclosed

comment:7 Changed 5 years ago by Franklin Yu <franklinyu@…>

Owner: set to Franklin Yu <franklinyu@…>
Resolution: wontfixfixed

In 8eda571c640f6ab0185cf4d8384fcc1f03a4616e/macports-ports (master):

nvm: new Portfile

Fixes: #53038

Note: See TracTickets for help on using tickets.