Skip to content
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

Use $HOME variable in NVM_DIR #1381

Merged
merged 1 commit into from
Jan 13, 2017
Merged

Conversation

DesignByOnyx
Copy link
Contributor

Closes #1346

INSTALL_DIR="$(nvm_install_dir)"
INSTALL_DIR="$(
nvm_install_dir |
command sed s:^$HOME:\$HOME:
Copy link
Member

Choose a reason for hiding this comment

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

could this be done inside nvm_install_dir? that would also make it more testable.

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 didn't want to affect other functions which use nvm_install_dir - I was intentionally trying to isolate this change to the place that needed it. I'm testing it now.

Copy link
Member

Choose a reason for hiding this comment

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

That's a fair point. I'd prefer to have this change covered by automated tests, if possible.

@DesignByOnyx DesignByOnyx force-pushed the 1346-nvm_dir branch 2 times, most recently from 845903a to 2f7f301 Compare January 12, 2017 20:32
@DesignByOnyx
Copy link
Contributor Author

I had to use printf because the tests didn't like echo:

echo "${NVM_DIR:-"$HOME/.nvm"}" | sed "s:^$HOME:\$HOME:"

It wanted me to use ${expansion/search/replace} instead and I couldn't figure out an elegant way to do it - it was hard to read. printf essentially allowed me to say "shh, I'm doing it this way".

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, this looks great

@ljharb ljharb merged commit 1b23052 into nvm-sh:master Jan 13, 2017
@ljharb ljharb added the installing nvm Problems installing nvm itself label Jan 13, 2017
@DesignByOnyx DesignByOnyx deleted the 1346-nvm_dir branch January 13, 2017 08:24
@lkysow
Copy link

lkysow commented Jan 13, 2017

Hey Guys, I think this has introduced a bug:
nvm_install_dir is using the actual string $HOME instead of the environment variable now. This means NVM is being installed into a directory called $HOME.

Example:

# old way
echo "${NVM_DIR:-"$HOME/.nvm"}"
/ubuntu/.nvm

# new way
printf %s "${NVM_DIR:-"$HOME/.nvm"}" | sed "s:^$HOME:\$HOME:"
$HOME/.nvm

@ndcampbell
Copy link

ndcampbell commented Jan 13, 2017

We are having the same issue as @lkysow. Looks like this introduced a bug.

Specifically at https://github.com/DesignByOnyx/nvm/blob/1b2305232f878db80ded5450a5accc881d4e8752/install.sh#L81 where it creates the directory

@ljharb
Copy link
Member

ljharb commented Jan 13, 2017

Thanks. Nobody should be using nvm off of master, only off of tagged releases, so this isn't urgent, but I'll take a look.

@ndcampbell
Copy link

@ljharb
Copy link
Member

ljharb commented Jan 13, 2017

Thanks, I'll file a bug. They shouldn't be doing that.

@ljharb
Copy link
Member

ljharb commented Jan 13, 2017

Filed jenkinsci/nvm-wrapper-plugin#3 to try to fix that they're depending on an unstable version.

@DesignByOnyx
Copy link
Contributor Author

@ljharb - my original PR isolated this change to the code which writes to the profile file. I can revert back to that if you like. Still need to fix the Jenkins thing, but the only place we really need literal $HOME is when writing to the profile. Let me know.

@ljharb
Copy link
Member

ljharb commented Jan 16, 2017

@DesignByOnyx if you'd be willing to open a PR that fixes the issue without reverting the feature, that'd be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installing nvm Problems installing nvm itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants