Skip to content

Implement .nrc / .node-version #150

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

Closed
denysonique opened this issue Oct 1, 2013 · 11 comments
Closed

Implement .nrc / .node-version #150

denysonique opened this issue Oct 1, 2013 · 11 comments

Comments

@denysonique
Copy link

A tool called RVM for managing Rubies has a feature called .rvmrc. A .rvmrc file specifying which Ruby version to use placed in a project directory will trigger automagic switching of the Ruby version when cd'ing into that directory. This make life easier by eliminating the need to manually switch the Ruby version.

It would be nice to have a similar functionality.

More info about .rvmrc / rvm workflow: http://rvm.io/workflow/projects

@wbyoung
Copy link

wbyoung commented May 1, 2014

I'd love to see this as well. It's a pretty big project, though. nvm has indicated they won't do it. Supporting .node-version support would be great, and perhaps there's a way to make a spinoff project that supports both n and nvm through .node-version files.

@tj
Copy link
Owner

tj commented May 1, 2014

hmm kinda neat, it could just check package.json, but at the same time it's not uncommon to have multiple apps running at the same time. I'd just add make run or sth and n use 0.11.10 node --harmony myapp.js etc

@tj tj closed this as completed May 1, 2014
@wbyoung
Copy link

wbyoung commented May 1, 2014

@visionmedia I could be mistaken, but I think RVM switched to using .ruby-version and .ruby-gemset for security reasons. The execution of arbitrary commands by simply running .rvmrc can be used maliciously (especially when we're sharing via version control systems).

They may not have added that for that reason, but it still seems like a good reason to support something more specific like .node-version, which would only work with your installed node versioning tool, and would only allow the switching of versions. There'd be little chance of any malicious use.

@wbyoung
Copy link

wbyoung commented May 2, 2014

@wayneeseguin @mpapis @cxreg If one were going to build another tool that hooked into cd functionality, what would be the most basic bit of code that would allow it to be compatible with both rvm and smartcd?

An quick example along the lines of this, but making it so this doesn't override your tools would be great:

cd() {
  echo "before";
  builtin cd "$@";
  echo "after";
}

@mpapis
Copy link

mpapis commented May 2, 2014

more like:

function cd()
{
  typeset __result=0
  run_before "$@" || true
  builtin cd "$@" || __result=$?
  run_after  "$@" || true
  return $__result
}

@mpapis
Copy link

mpapis commented May 2, 2014

as for compatibility with other tools - let me know when you have your code - I can add support for it in RVM and help you make it work with RVM.

@wbyoung
Copy link

wbyoung commented May 2, 2014

@mpapis is there a way that we could standardize the compatibility between tools so that each tool doesn't need to know about another?

What's the point of using || true in your example?

I understand the basic premise of what's happening here — overriding cd, but I'm not a shell scripting ninja (as you rvm folks seem to be), so I appreciate you taking the time to answer. :)

@mpapis
Copy link

mpapis commented May 2, 2014

|| true is needed so that any command returning non 0 status would not break execution when set -e is in effect

as for standardization, I was thinking on implementing an array with hooks like ZSH does ... it's possible, but will require some time(maybe not long, but I have other task earlier on the list), open a ticket for RVM if you would like me to implement it.

@wbyoung
Copy link

wbyoung commented May 4, 2014

Hi all, I started a project to try to tackle this issue. Pull requests welcome!

@mpapis
Copy link

mpapis commented May 4, 2014

@wbyoung as much as I would liked to see it happen in current state environment switchers, it's quite complicated problem - I do not see it, but maybe @postmodern has some experience with minimizing efforts just for ruby?

@wbyoung
Copy link

wbyoung commented May 4, 2014

@mpapis sorry, either I miss-communicated or maybe got you mixed up while commenting on multiple issues. I was referring just to trying to solve the issue of node not having a version manager that supports automatically switching on cd, not the part about abstracting that and having the various version switchers work together better.

For others reading this issue, though, I did open a ticket to discuss how to best get integration to happen with RVM as @mpapis suggested earlier.

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

4 participants