-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Fix default install as non-root user, #305 #363
Conversation
Hmm, well travis fails because of: However if you set default to undef (
The obvious fix is to set $home_dir parameter without a type: |
This is now failing spec tests, which just completely baffle me:
|
OK that failing check makes an incorrect assumption, removed |
Ooh, a green tick from Travis :) |
Does this work? AFAIK |
@ekohl Yes, works fine. |
Hmm, can we go a bit further and add Perhaps something like:
|
@juniorsysadmin Not convinced that it's a good idea to encourage passing/using environment variables for npm config. Better to write manifests or use .npmrc?: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
here's some of my opinions…
@@ -8,7 +8,7 @@ | |||
String $package = $title, | |||
$source = 'registry', | |||
Array $uninstall_options = [], | |||
$home_dir = '/root', | |||
$home_dir = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while we're at it, we could just as well give home_dir an Optional[Stdlib::AbsPath]
type.
$_homedir = "HOME=${home_dir}" | ||
} else { | ||
$_homedir = undef | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think a selector is easier to read?
$_homedir = $home_dir? {
undef => undef,
default => "HOME=${home_dir}",
}
|
||
it 'the environment variable HOME should be /root' do | ||
is_expected.to contain_exec('npm_install_express').with('environment' => 'HOME=/root') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of removing the test, why not modify it ?
Hi @fnoop do need some help to move forward about this PR ? |
@@ -8,7 +8,7 @@ | |||
String $package = $title, | |||
$source = 'registry', | |||
Array $uninstall_options = [], | |||
$home_dir = '/root', | |||
$home_dir = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the default behavior of the module and would likely need a major version bump.
npm.pp currently sets /root as the environment HOMEDIR. This breaks using nodejs::npm as a non-root user, as per #305. nodejs::npm::home_dir parameter can be set to override this, but is not intuitive, documented or automatic.
Instead, unset $home_dir parameter by default and only use it to set HOMEDIR environment variable if populated. If not set, npm will use the default home directory for the specified user.