Closed ecc11718 closed 9 years ago
Will when I'm back on that box. Headbanger.
# ...
'nvm' => {
'user_installs' => [
{
'user' => 'vagrant',
'nodes' => [ '0.8.5' ],
'default' => '0.8.5',
'npm' => [
{ 'name' => 'coffee-script', 'version' => '1.3.3' }
]
}
]
},
# ...
might have to add one more specifier around the npm install
cause each node can have it's own global
, right?
'nvm' => {
'user_installs' => [
{
'user' => 'vagrant',
'nodes' => [ '0.8.5' ],
'default' => '0.8.5',
'npm' => {
'0.8.5' => [
{ 'name' => 'coffee-script', 'version' => '1.3.3' }
]
}
}
]
},
more discussion for 'sourcing' the nvm.sh
file:
in the recipe, add our own nvm.sh
(or whatev name) to the /etc/profile.d
directory, which just basically does this pseudo code:
if exists ~/nvm/nvm.sh
then execute ~/nvm/nvm.sh
reference: http://www.linuxfromscratch.org/blfs/view/6.3/postlfs/profile.html (search for "It then calls small, single purpose scripts in the /etc/profile.d directory to provide most of the initialization.")
with this pattern:
@lukewpatterson: cause each node can have it's own global, right?
Hrm.. seems like that's baked in.
'npm' => {
'0.8.5' => [
{ 'name' => 'coffee-script', 'version' => '1.3.3' }
]
}
So, e.g., for 0.8.5, here are its globals. I'd add a, e.g., 0.6.12 and list its globals.
Are you seeing that, too?
I see I'd need to change the 'npm' to an [] vs {}.
So, e.g.
'npm' => [
{
'0.8.5' => [
{ 'name' => 'coffee-script', 'version' => '1.3.3' }
]
},
{
'0.6.12' => [
{ 'name' => 'coffee-script', 'version' => '1.0.3' }
]
}
]
Ha, just realized your snippet was newer than what I copy/pasted originally. Weird. I was thinking along the same lines.
yeah, I think your latest snippet looks correct
I've got nvm.sh
and bash_completion
sourced. nvm
works when I ssh in. Yet trying to run nvm
downstream in the recipe gives me the good ol'
$ nvm: command not found.
That's a problem. This could be related, in that, if you're not on physically on the terminal, nvm.sh
's got nothing.
Trying to get around not having to do the ~/.bashrc
or ~/.profile
bit he wants but it's looking like, somehow, that's intimately tied to his logic.
root problem http://tickets.opscode.com/browse/CHEF-2288
It's interesting because that issue is old and still unassigned and the conditional option :user has been working for me in all other instances. Looks like a hack incoming.
(down south with only the small keyboard) are you saying that the user's bash profile files were being sourced? i haven't seen it source the files ever. have you verified by adding an 'echo' to the sourced file(s) and watching for the spam during provisioning?
Echo says vagrant
is user during provisioning. Dunno if that answers your question.
if you add some echo to the bashrc, does it show up when you use chef's script resource? i think that would answer the question.
cause that is the main problem, when executing a chef script resource, the bashrc stuff isnt run for the specified user. (vs if that user logged in with ssh for example, their bashrc would run)
we need a back patch hack reusable way to call shell in "logged in" mode, i think @fnichol was working around the same nonsense when he wrote this: https://github.com/fnichol/chef-rbenv/blob/master/libraries/chef_rbenv_mixin.rb i think that is ruby way to override or monkey patch or somesuch (notice the wrapper pattern with delegation to super)
but we would have to extend that functionality to also source the bashrc file stuff
was reading about "bash -l" commands, something about running in login mode
Right. I'll take a look here when I settle in. Dislike having to add more local artifacts but a hack's a hack.
got 1st version of hack to work https://github.com/indoorsdog/development-machine/blob/e6df15a5b9b054e2457dd99b4a4939635a339ace/config/chef-repo/site-cookbooks/site/recipes/pythonbrew.rb#L36
(notice the 'environment' and 'flags')
seems to work for now
logging before I forget, I can fix this.
on a fresh install:
[Fri, 17 Aug 2012 04:08:17 +0000] ERROR: script[installing coffee-script@1.3.3...](/tmp/vagrant-chef-1/chef-solo-1/cookbooks/site/recipes/nvm.rb:59:in `block %284 levels%29 in from_file') had an error: script[installing coffee-script@1.3.3...](site::nvm line 59) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '127' ---- Begin output of "bash" -l "/tmp/chef-script20120817-3505-8eq6lp" ---- ... STDERR: /tmp/chef-script20120817-3505-8eq6lp: line 4: npm: command not found
just need to source an nvm activation script during login, i think https://github.com/indoorsdog/development-machine/issues/17#issuecomment-7626736
i could have sworn this was already implemented, but I didn't see it in the history
That's strange. I'll do a fresh install. I ran into that issue prior to your environment
script hook but not afterward. According to its README both the script and activation I've correctly sourced...
I'll definitely look into it later today.
Can you paste that json config we worked on?
I have a paranoid doubt about one part of it, need to double check something.