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

RefreshEnv (Refresh Environment Variables) Should also work in PowerShell #664

Closed
ferventcoder opened this issue Mar 20, 2016 · 11 comments
Closed
Assignees
Milestone

Comments

@ferventcoder
Copy link
Member

cmd.exe has long had a nice command to run to update environment variables without needing to close the shell: refreshenv. Bring that functionality to PowerShell.exe as well.

@ferventcoder ferventcoder self-assigned this Mar 20, 2016
@ferventcoder ferventcoder added this to the 0.9.10 milestone Mar 20, 2016
ferventcoder added a commit that referenced this issue Mar 20, 2016
cmd.exe has long had a nice command to run to update environment
variables without needing to close the shell: `refreshenv`. Bring that
functionality to PowerShell.exe as well.
ferventcoder added a commit that referenced this issue Mar 20, 2016
Provide PowerShell tab completion for Chocolatey commands including

- searching for installed packages for upgrade/uninstall
- searching for packages to install  - only return the top 5 results
   from a search and only search by id

Also set refreshenv as part of the profile additions.
ferventcoder added a commit that referenced this issue Mar 20, 2016
* stable:
  (GH-412)(GH-664) PoSh tab completion / refreshenv
  (GH-295) Do not replace PSModulePath
  (GH-664) RefreshEnv Should also work in PowerShell
  (GH-412) update parameter name for skip scripts
  (GH-663) Search just by id
  (doc) update how to pass args
@masaeedu
Copy link

masaeedu commented Jul 12, 2016

@ferventcoder How do we use this? I've installed 0.9.10.3 and I can still only see Refreshenv.cmd, no Refreshenv.ps1. Reason I'm fooling around with Refreshenv is that I just installed puppet-agent and puppet doesn't appear to be on the PATH. Opening cmd and running Refreshenv makes it work again, no joy with powershell however.

@ferventcoder
Copy link
Member Author

It's not the name of the file. You are running a function alias that has been added to PowerShell through your profile.

@ferventcoder
Copy link
Member Author

Have you tried running the function?

@ferventcoder
Copy link
Member Author

Sorry, was responding from the email and didn't see that you added more here. From the install of choco, it would have added to the profile of the installing user. Then you need to run . $profile as the instructions state during the install of choco or close and reopen powershell.

@ferventcoder
Copy link
Member Author

ferventcoder commented Jul 12, 2016

If it isn't in your profile, you will need to add the module to it. We are working on a troubleshooting doc for this

@masaeedu
Copy link

@ferventcoder Ah, yes, I noticed that message but I didn't have a chance to react because it was part of a script. It works if I add a line to source my profile, thanks!

@ihor-drachuk
Copy link

Currently it doesn't work in PS

@TheCakeIsNaOH
Copy link
Member

@ihor-drachuk refreshenv does work in powershell, but it requires the chocolateyProfile module (which also has tab completion) to be enabled.
Here is a guide with more information: https://www.youtube.com/watch?v=jdZrigvxwws

@ihor-drachuk
Copy link

In common, it would be fine if it could work without such unobvious dependencies. Or if dependencies are installed with the tool, which is installed, but currently doesn't work without them. Or if tool failed to do it's work, then let it notify somehow about failure and suggest that there are some missing component and there are some solution.

@TheCakeIsNaOH Thank you for information, I'll try.

@corbob
Copy link
Member

corbob commented Dec 23, 2021

@ihor-drachuk generally if you have a PowerShell Profile it will add the code to import the chocolateyProfile, however there are a number of reasons the chocolateyProfile isn't added automatically:

  1. If there is no PowerShell profile, we will not create one as there are a number of scenarios where this would result in further issues. By default on Windows the Execution Policy is undefined and in many cases will be treated as AllSigned which means us adding a PowerShell profile will result in an error every time someone loads PowerShell.
  2. If there is a PowerShell profile, but it is signed, we will not update the profile because we didn't sign it and doing so would break the profile script.

As for being unobvious, Chocolatey does alert you to this during the install process (to be fair this just says tab completion, and not a word about refreshenv):
image

@ihor-drachuk
Copy link

@corbob Thanks for the answer. Exactly! I'm expecting working just refreshenv in PS. Especially if it finishes with zero status code. And it's not obvious that it's somehow connected with tab completion or profiles or that it could be broken because of them or smth similar.

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

No branches or pull requests

6 participants