Hi
Is there a way to force reload of the PATH variable on windows?
We install git & nodejs and then tries to install some npm packages from a
git repo.
But in the initial run, npm cannot find git because the current process’
PATH is not updated.
Starting a new shell and running chef-client solves the issue, but this is
of course less than ideal.
Any ideas?
/Jeppe
How are you updating the path – using the env resource? On Windows, env
sends a broadcast system message message that should cause new processes to
get the latest environment.
-Adam
From: Jeppe Nejsum Madsen [mailto:jeppe@ingolfs.dk ]
Sent: Monday, May 19, 2014 10:46 AM
To: chef@lists.opscode.com
Subject: [chef] Updating PATH on windows for use in subsequent recipes
Hi
Is there a way to force reload of the PATH variable on windows?
We install git & nodejs and then tries to install some npm packages from a
git repo.
But in the initial run, npm cannot find git because the current process’
PATH is not updated.
Starting a new shell and running chef-client solves the issue, but this is
of course less than ideal.
Any ideas?
/Jeppe
jdunn
May 20, 2014, 6:19am
3
We do it in the 'php' cookbook like this:
#
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Author:: Lucas Hansen (<lucash@chef.io>)
# Cookbook:: php
# Recipe:: package
#
# Copyright:: 2013-2021, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
This file has been truncated. show original
On Mon, May 19, 2014 at 1:46 PM, Jeppe Nejsum Madsen jeppe@ingolfs.dk wrote:
Hi
Is there a way to force reload of the PATH variable on windows?
We install git & nodejs and then tries to install some npm packages from a
git repo.
But in the initial run, npm cannot find git because the current process'
PATH is not updated.
Starting a new shell and running chef-client solves the issue, but this is
of course less than ideal.
Any ideas?
/Jeppe
--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]
This is how we do it. its in our base recipe for windows
powershell_script "Add path to appcmd to Environment PATH" do
code <<-EOB
$PathToAdd = "%windir%\system32\inetsrv"
$VerifiedPathsToAdd = $null
Foreach($Path in $PathToAdd) {
if($env:Path -like "$Path ") {
}
else {
$VerifiedPathsToAdd += ";$Path"
}
if($VerifiedPathsToAdd -ne $null) {
[Environment]::SetEnvironmentVariable("Path",$env:Path +
$VerifiedPathsToAdd,"Machine")
}
}
EOB
end
On Mon, May 19, 2014 at 11:19 PM, Julian C. Dunn jdunn@aquezada.com wrote:
We do it in the 'php' cookbook like this:
https://github.com/opscode-cookbooks/php/blob/master/recipes/package.rb#L54-L55
On Mon, May 19, 2014 at 1:46 PM, Jeppe Nejsum Madsen jeppe@ingolfs.dk
wrote:
Hi
Is there a way to force reload of the PATH variable on windows?
We install git & nodejs and then tries to install some npm packages from
a
git repo.
But in the initial run, npm cannot find git because the current process'
PATH is not updated.
Starting a new shell and running chef-client solves the issue, but this
is
of course less than ideal.
Any ideas?
/Jeppe
--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]