question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

avn fails when .nvmrc contains additional lines

See original GitHub issue

When .nvmrc contains more than 1 line, e.g. with comments, then avn fails.

This is a problem because a code base I have to work with at work has extended .nvmrc with some additional lines for specifying the yarn version, which is used by a different tool. These extra lines are ignored by nvm, but cause an error in avn.

The simplest fix would be to only read the first line of the file and ignore everything else that follows.

i.e. In lib/hooks.js, change this line:

.then(function(version) { this.version = version.trim(); })

to this:

.then(function(version) { this.version = version.split('\n')[0].trim(); })

Details

  • avn 0.2.3
  • node 6.9.4
  • nvm 0.33.1
  • bash 4.4.12

The output of __avn_debug in the directory with a .node-version file is:

avn could not activate node 6.9.4
# test
error: no plugin passed predicate
  avn-nvm: no version matching 6.9.4
# test
  avn-n: no version matching 6.9.4
# test

avn is loaded in my ~/.{bash|zsh}{_profile|rc} file with:

[[ -s "$HOME/.avn/bin/avn.sh" ]] && source "$HOME/.avn/bin/avn.sh" # load avn

nvm specific

  • As an nvm user I am confirming that I did not install with Homebrew

Yes.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wbyoungcommented, Apr 28, 2017

@ljharb thanks. So avn should be able to use that to read the file rather than making any assumptions. @lachlanhunt if you want to take a stab at that a PR would be more than welcome!

1reaction
lachlanhuntcommented, Apr 27, 2017

I agree it shouldn’t be abused for things unrelated to node versions. Unfortunately, that code is maintained by a different team and I’m not entirely sure why they’re doing it. I’ll follow up with them though to see if they’ll agree to change it.

But at the very least, ignoring lines beginning with # and treating them as comments would help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

run `nvm use` automatically every time there's a .nvmrc file on ...
Put this into your $HOME/.zshrc to call nvm use automatically whenever you enter a directory that contains an .nvmrc file with a string...
Read more >
third_party/nvm - Git at Google
Since OS X 10.9, /usr/bin/git has been preset by Xcode command line tools, which means we can't properly detect if Git is installed...
Read more >
How To Write A .Nvmrc File Which Automatically Change ...
Create a.nvmrc file containing a node version number in your project. use nvm use command to set default node version found in.nvmrc. If...
Read more >
where can dubnium be found - Philadelphia Mixing Solutions
[179][180][181], Kerrdown has the ability to determine if the compromised host ... ~/.bashrc (or other shell resource config) and remove the lines below:...
Read more >
Configuring Node Version Manager (NVM) for OS X
The Xcode command line tools (which you may already have for other reasons) are required. The easiest way to install them is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found