tag:help.appveyor.com,2012-11-13:/discussions/problems/2035-starting-new-powershell-for-choco-installAppVeyor: Discussion 2018-10-19T08:17:10Ztag:help.appveyor.com,2012-11-13:Comment/366929662015-04-28T03:12:54Z2015-04-28T03:12:54Zstarting new powershell for 'choco install'?<div><p>It depends on how chocolatey sets path after installing the
package. If it's changing it on machine/user level then yes those
changes will be available on a new PS session.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/366929662015-04-28T03:16:12Z2015-04-28T03:16:13Zstarting new powershell for 'choco install'?<div class="WordSection1">
<p>Ok, so the bit I’m missing is how to make appveyor’s
build process start a new powershell?</p>
<p> </p>
<p>Sorry, I’m new to windows CI so may be missing something
obvious…</p>
<p> </p>
<p>My appveyor.yml currently looks a bit like this (sorry for mail
formatting):</p>
<p> </p>
<p>Install:</p>
<p>
<span>-<span> </span></span>
ps: cinst packer</p>
<p>build_script:</p>
<p>
<span>-<span> </span></span>
ps: packer build aws.json</p>
<p> </p>
<p>Install adds c:\Hashicorp\packer with a binary and a module,
packer build then uses that, but it’s not in the path. How do
I make packer build run in a new powershell?</p>
<p> </p>
<p>Thanks for the prompt response <span>J</span></p>
<p> </p>
<p>Sent from Mail for Windows 10 [10061]</p>
<p> </p>
<p> </p>
<div>
<p><br>
<b>From:</b> Feodor Fitsner<br>
<b>Sent:</b> Tuesday, April 28, 2015 1:12 PM<br>
<b>To:</b> kevin@littlejohn.id.au;<br>
<b>Subject:</b> Re: starting new powershell for 'choco install'?
[Problems #2035]</p>
</div>
<p class="MsoNormal"></p>
<p><span> </span></p>
<p class="MsoNormal"></p>
<p> </p>
<p class="MsoNormal"></p>
<p><span> </span></p>
<div>
<table class="MsoNormalTable" width="100%">
<tr>
<td>
<p><span>// Please reply above this line<br>
==================================================</span></p>
<p><b><span>From</span></b><span>: Feodor Fitsner (Support
staff)</span></p>
<div>
<p><span>It depends on how chocolatey sets path after installing
the package. If it's changing it on machine/user level then yes
those changes will be available on a new PS session.</span></p>
</div>
<div>
<p><span>On Tue, Apr 28 at 02:50 AM, Kevin Littlejohn
wrote:</span></p>
<blockquote>
<div>
<p><span>Heya,</span></p>
<p><span>I've seen <a href=
"http://help.appveyor.com/discussions/problems/1227-use-the-powershell-community-extensions-in-after-build-script">
http://help.appveyor.com/discussions/problems/1227-use-the-powershell-community-extensions-in-after-build-script</a>
and it provides a partial answer to this, but basically I'm
wondering if there's a more elegant way to get appveyor to start a
new powershell during the process?</span></p>
<p><span>I'm doing a series of "choco install" commands during the
install step, then want to use the installed packages in the
build_script section. This is more cleanly done if a new powershell
is started for the build_script section, but that doesn't seem to
be what happens. I'd have to adjust the path and module path
manually for each thing I've installed, which is a bit
clunky.</span></p>
<p><span>Thanks,</span></p>
</div>
</blockquote>
</div>
</td>
</tr>
<tr>
<td>
<p><span>Having trouble reading this? View this discussion online:
<a href=
"http://help.appveyor.com/discussions/problems/2035-starting-new-powershell-for-choco-install">
<span>starting new powershell for 'choco
install'?</span></a>.</span></p>
<p><span>Reply with #ignore to stop receiving notifications for
this discussion.</span></p>
</td>
</tr>
</table>
</div>
<p class="MsoNormal"></p>
<p><span> </span></p>
<p class="MsoNormal"></p>
<p> </p>
<p class="MsoNormal"></p>
<p><span> </span></p>
<p class="MsoNormal"></p>
<p> </p>
<p class="MsoNormal"></p>
<p> </p>
</div>Kevin Littlejohntag:help.appveyor.com,2012-11-13:Comment/366929662015-04-28T03:46:33Z2015-04-28T03:46:33Zstarting new powershell for 'choco install'?<div><p>Well, it's supposed that session <code>PATH</code> should be
modified during package installation: <a href="https://github.com/chocolatey/chocolatey/blob/master/src/helpers/functions/Install-ChocolateyPath.ps1#L35-L37">
https://github.com/chocolatey/chocolatey/blob/master/src/helpers/fu...</a>
If you check install script for packer you'll see it calls that
function: <a href="https://chocolatey.org/packages/packer">https://chocolatey.org/packages/packer</a></p>
<p>Unfortunately, it looks like it doesn't work even locally. See
attached screenshot. There is an explanation to that - we call
<code>cinst</code> or <code>choco</code> to install a package which
are, essentially, an "exe" and start a new processes:</p>
<pre>
<code>c:\Projects\1>where cinst
C:\ProgramData\chocolatey\bin\cinst.exe
c:\Projects\1>where choco
C:\ProgramData\chocolatey\bin\choco.exe</code>
</pre>
<p>when you modify "process" variable through <code>SET PATH</code>
or <code>$env:PATH</code>, etc. it modifies the variable in the
current process only and then affects all child processes you run
after that. It doesn't affect parent process (command line session
or AppVeyor Build Agent service in our case). The rule is simple
all environment variables set in the process does not apply to its
parent processes. When you modify a variable on user/machine level
it will be applied to all new processes.</p>
<p>That's why AppVeyor provides a web service to set variables in
the parent process: <a href="http://www.appveyor.com/docs/build-worker-api#set-environment-variable">
http://www.appveyor.com/docs/build-worker-api#set-environment-variable</a></p>
<p>We need to tell about that to Chocolatey guys.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/366929662015-04-28T04:36:52Z2015-04-28T04:36:53Zstarting new powershell for 'choco install'?<div><p>// Please reply above this line
==================================================</p>
<pre>
<code> From: Feodor Fitsner (Support staff)
Well, it's supposed that session PATH should be</code>
</pre>
<p>modified during package installation:<br>
<a href="https://github.com/chocolatey/chocolatey/blob/master/src/helpers/fu">
https://github.com/chocolatey/chocolatey/blob/master/src/helpers/fu</a>...<br>
If you check install script for packer you'll see it calls that<br>
function: <a href="https://chocolatey.org/packages/packer">https://chocolatey.org/packages/packer</a><br>
Unfortunately, it looks like it doesn't work even locally. See<br>
attached screenshot. There is an explanation to that - we call<br>
cinst or choco to install a package which<br>
are, essentially, an "exe" and start a new processes:</p>
<p>c:\Projects\1where cinst<br>
C:\ProgramData\chocolatey\bin\cinst.exe<br>
c:\Projects\1where choco<br>
C:\ProgramData\chocolatey\bin\choco.exe</p>
<p>when you modify "process" variable through SET PATH<br>
or $env:PATH, etc. it modifies the variable in the<br>
current process only and then affects all child processes you
run<br>
after that. It doesn't affect parent process (command line
session<br>
or AppVeyor Build Agent service in our case). The rule is
simple<br>
all environment variables set in the process does not apply to
its<br>
parent processes. When you modify a variable on user/machine
level<br>
it will be applied to all new processes.<br>
That's why AppVeyor provides a web service to set variables in<br>
the parent process:<br>
<a href="http://www.appveyor.com/docs/build-worker-api#set-environment-variable">
http://www.appveyor.com/docs/build-worker-api#set-environment-variable</a><br>
We need to tell about that to Chocolatey guys.</p>
<pre>
<code> On Tue, Apr 28 at 03:16 AM, Kevin Littlejohn wrote:</code>
</pre>
<p>Ok, so the bit I’m missing is how to make
appveyor’s<br>
build process start a new powershell?<br>
<br>
Sorry, I’m new to windows CI so may be missing something<br>
obvious…<br>
<br>
My appveyor.yml currently looks a bit like this (sorry for mail<br>
formatting):<br>
<br>
Install:</p>
<p>- ps:
cinst packer<br>
build_script:</p>
<p>- ps:
packer build aws.json<br>
<br>
Install adds c:\Hashicorp\packer with a binary and a module,<br>
packer build then uses that, but it’s not in the path. How
do<br>
I make packer build run in a new powershell?<br>
<br>
Thanks for the prompt response J<br>
<br>
Sent from Mail for Windows 10 [10061]<br>
<br>
</p>
<p>From: Feodor Fitsner<br>
Sent: Tuesday, April 28, 2015 1:12 PM<br>
To: [email blocked];<br>
Subject: Re: starting new powershell for 'choco install'?<br>
[Problems #2035]</p>
<p> </p>
<p> </p>
<p> </p></div>Kevin Littlejohntag:help.appveyor.com,2012-11-13:Comment/366929662016-12-08T16:08:40Z2016-12-08T16:08:40Zstarting new powershell for 'choco install'?<div><p>@Kevin, you could try using the "refreshenv" command available
in newer versions of chocolatey which checks whether the registry
has been updated with new variables that aren't reflected in the
current session and temporarily sets them to the new values (like
PATH). This doesn't work 100% in my experience, but it works much
better for running another script that needs to utilize the output
of a prior Chocolatey script run.</p></div>dragon788