Scott Hanselman

Apt-Get for Windows - OneGet and Chocolatey on Windows 10

August 5, '15 Comments [49] Posted in Open Source | Tools | Win10
Sponsored By

In 2013 I asked the questions "Is the Windows user ready for apt-get?" As with nearly all my blog posts, the comments are better than the post itself. ;)

Now it's 2015 and many of us are upgrading to Windows 10. One of the little gems in Windows 10 that no one is talking about (yet) is OneGet. You can read about OneGet architecture here.

Installing applications in Windows 10 from the command line

It's easy (and wrong) to just say that One-Get is Apt-Get for Windows. But OneGet isn't actually a package manager. It's more clever and cooler than that.  It's a package manager manager.

OneGet is a Manager of Package Managers 

Go out to you Windows 10 PowerShell prompt now and type "Get-PackageProvider" and you'll see the package managers you have registered with OneGet today.

C:\> Get-PackageProvider

Name Version
---- -------
Programs 10.0.10240.16384
msu 10.0.10240.16384
msi 10.0.10240.16384
PSModule 1.0.0.0

Usually programs are installed with things like MSIs, for example, so there's a provider for that. You can type "Get-Package" and see the programs AND packages on your machine:

C:\> Get-Package

Name Version
---- -------
123D Design R1.6 1.6.41
Windows Driver Package - Ge... 06/04/2011 8....
Windows Driver Package - Ge... 06/19/2014 8....
Windows Driver Package - FT... 01/27/2014 2....
JRuby 1.7.19 1.7.19
Windows Driver Package - ST... 11/09/2009 3....
EPSON NX410 Series Printer ...
Intel Edison Device USB driver 1.2.1

Since it's PowerShell, you can sort and filter and what-not to your heart's delight.

OneGet isn't Microsoft's Chocolately

Chocolatey is an open source apt-get-like machine-wide package manager that you can use today, even if you don't have Windows 10.

OneGet isn't Microsoft's version of Chocolately. But there is a beta/preview Chocolatey provider that plugs into OneGet so you can use OneGet to get Chocolatey packages and install them.

Other things worth noting, even though OneGet is in the box for Windows 10, you can still run it on Windows 7 and Windows 2008 R2. Plus, OneGet isn't done and it's open source so there's lots of cool possibilities.

Oh, and an important naming point. Just like "Chromium" is the open source browser and "Chrome" is the Google packaged instance of that project, "OneGet" is the open source project and what ships with Windows 10 is just generically "PackageManagement." Just a good reminder of the relationship between open source projects and their shipping counterparts.

Installing VLC using OneGet and Chocolatey on Windows 10

Example time. You've got a new Windows 10 machine and you want to get VLC. You can (and should) totally get it from the Windows Store, but let's get it using Package Management.

Here I need to get the beta Chocotlatey provider first, and once, with "get-packageprovider -name chocolatey." Also, when I install a package for the first time it will prompt to download NuGet as well. I will answer Yes to both.

NOTE: You can also install Chocolatey explicitly with "install-package –provider bootstrap chocolatey"

Now I can just "install-package vlc" and it will get it from the Chocolatey repository.

C:\>  get-packageprovider -name chocolatey

The provider 'chocolatey v2.8.5.130' is not installed.
chocolatey may be manually downloaded from https://oneget.org/ChocolateyPr30.exe and installed.
Would you like PackageManagement to automatically download and install 'chocolatey'?

[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y

Name Version
---- -------
Chocolatey 2.8.5.130

C:\> install-package vlc

The provider 'nuget v2.8.5.127' is not installed.
nuget may be manually downloaded from https://oneget.org/nuget-anycpu-2.8.5.127.exe and installed.
Would you like PackageManagement to automatically download and install 'nuget' now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y

The package(s) come from a package source that is not marked as trusted.
Are you sure you want to install software from 'chocolatey'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y

Name Version Source Summary
---- ------- ------ -------
vlc 2.2.1.20150630 chocolatey VLC Media Player

Boom. Now VLC is installed. It's early days but it's interesting stuff!

You can read about the available OneGet cmdlets at https://github.com/OneGet/oneget/wiki/cmdlets.

For example here I can find the latest version of zoomit.

C:\> find-package -name zoomit

Name Version Source
---- ------- ------
zoomit 4.50 chocolate

Just to be clear, with regards to OneGet and Chocolatey.

  1. It's an unsupported version of Chocolatey provider in a GitHub repo
  2. Folks can download it using OneGet cmdlets and then using the unsupported provider, you can download Chocolatey packages.
  3. Microsoft is working with the community to take ownership of Chocolatey provider.

And again, you can use Chocolatey TODAY on your Windows 7 and up machines as it is.

Managing MSI-installed Programs with OneGet and PackageManagement

OneGet and PackageManagement in Windows 10 lets you manage package managers of all kinds to control what's installed one your machines. For example, I can uninstall an MSI installed program like this. This is just like visiting Add/Remove Programs (ARP) and uninstalling, except I did it from the command line!

C:\> Uninstall-Package join.me.launcher

Name Version
---- -------
join.me.launcher 1.0.368.0

MSI and Chocolately are just the start for OneGet. What if one package management API could also get Python or PHP packages? Windows Store apps?

OneGet Architecture Diagram - The End user calls PackageManagement APIs that delgate to installed provders that install packages from the original location

Donate to help Chocolatey

Last, but definitely not least, it's important to remember that Chocolatey and the Chocolatey Repository of Packages can use your help and sponsorship. Head over to https://chocolatey.org/ and scroll to the bottom and click Donate and you can Paypal or use your Credit Card to help them out.

SOCIAL: Hey folks, please do follow me on Facebook https://fb.me/scott.hanselman or Twitter! https://twitter.com/shanselman


Sponsor: Big thanks to our friends at Infragistics for sponsoring the feed this week! Responsive web design on any browser, any platform and any device with Infragistics jQuery/HTML5 Controls.  Get super-charged performance with the world’s fastest HTML5 Grid -Download for free now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Wednesday, 05 August 2015 03:00:57 UTC
So it looks like it's not available for Windows 8 by implication, but I haven't been able to find why this is. Any insight, Scott?
Wednesday, 05 August 2015 03:26:11 UTC
It requires Windows Management Framework 5.0, which shipped a preview version with Windows 10 but is also available to install on earlier OS versions.
Ryan
Wednesday, 05 August 2015 04:27:03 UTC
I would have preferred an actual, working package manger over a manager of package managers. Chocolatey is ok, but really not very robust. MSI is a crux beyond belief. Why can't there be a simple, declarative way to install packages on windows? With updates via internet etc.? For apps the Store now provides that, but for anything else there still isn't any acceptable solution. It is just bizarre that it is the year 2015, and if you want to write a setup with an auto update for a windows software, you have to code all of that yourself...
davidacoder
Wednesday, 05 August 2015 04:32:12 UTC
Hey Scott
Do any of these package managers allow you to specify an iso that's already been downloaded to prevent having to get that 4GB iso every time the package is installed? I've started using Boxstarter for small developer tools and Windows features, but it's not feasible for large applications like visual studio since I don't know yet how to say "I've already got the iso".
Thanks
Eti
Wednesday, 05 August 2015 07:51:23 UTC
Just as a comment all this cmdlets must be executed with a powershell console with administrative rights, if not Install-Package fails silently :(
Wednesday, 05 August 2015 09:48:56 UTC
This looks pretty badass actually. We (*nix nerds) have been used to this for such a long time and I know personally I wondered how long it would be before we get something similar or at least something that paves the way for future interpretations of a package manager architecture.
Wednesday, 05 August 2015 10:07:54 UTC
An actual package manager would have been nicer from my point of view, hopefully this is just the first step to that. I would really like it to get to a point where we can script an install/update of classic and modern apps from a trusted source. Chocolatey is great but with package trust and other issues its not quite there.
Pete
Wednesday, 05 August 2015 11:36:34 UTC
Actually this is not installing any package. I don't see any executable regarding zoomit or vlc. How do you actually run these programs after the installation ?
Onur
Wednesday, 05 August 2015 12:19:34 UTC
@Onur, just type in
Get-Package -Name {packageName}
to get the installation location.
Matt
Wednesday, 05 August 2015 13:37:14 UTC
Very neat. I keep pushing for feedback to make powershell handle elevation of permissions in a way similar to that of terminals in *nix. Explicitly opening a powershell windows as administrator (UAC) makes some of this kind of difficult.

This does not take away from the awesomeness that is OneGet, but it still hinders the usability.
Brandon
Wednesday, 05 August 2015 13:56:13 UTC
Thanks for the article. My new T450s is going to be here Monday, and I'm scrambling to find out what I need and don't need for it in Windows 10. Hoping an update to the Tools list is coming soon...
John Dunagan
Wednesday, 05 August 2015 14:00:26 UTC
So... why does oneget-chocolatey install packages to C:\Chocolatey? And why doesn't it integrate with an existing choco installation? I'm seeing a "ChocolateyPrototype.exe" which is just NuGet in disguise. Too bad, looks quite unfinished right now.
Jabe
Wednesday, 05 August 2015 14:39:47 UTC
@Brandon, there are several ways to do "sudo"-like operation in a PowerShell to elevate permissions only for a specific process. Here's one of the first that came up when I googled for it on the bing: http://www.exitthefastlane.com/2009/08/sudo-for-powershell.html

@Jabe, "C:\Chocolatey" was the original Chocolatey install path, so it just seems that the oneget-chocolatey provider is currently a couple releases behind Chocolatey upstream. Hopefully the provider will be updated soon to use the latest and greatest Chocolatey.
Wednesday, 05 August 2015 15:13:00 UTC
For anyone who wants to try a proper package manager I can recommend MSYS2.
Wednesday, 05 August 2015 15:18:18 UTC
This doesn't actually work yet, though-- it grabs the package files but never actually installs them. Supposedly the chcolatey package provider is from early 2014, and MS is trying to update it. When that happens this might actually be useful. Until then, just use chocolatey straight-up.
Sean Jon
Wednesday, 05 August 2015 17:30:41 UTC
@Max That "pseudo" sudo doesn't work for many reasons. One is that it doesn't pass quoted strings correctly. E.g., running sudo ls "C:\Program Files" gives the error "C:\Program: No such file or directory."

Another issue is that it assumes the first argument is an executable, which means you can't pass in cmdlets.

This is a better approximation of Linux's su rather than sudo.
Kris
Wednesday, 05 August 2015 18:03:28 UTC
Eager to try out oneget. I've had issues with chocolatey recently loading malware/bloatware as part of installer packages, which underscores an issue in their package review process. Since that happened about a month ago I've preflighted all packages in a VM, which is kind of inefficient but helps establish a baseline for trust.
Kitty
Wednesday, 05 August 2015 20:49:52 UTC
And now 2015, what's new ? I'm very newbie-silly, I'm confused about all that. Not DEFINITIVE GUIDE about it, IMHO.


NuGet, MyGet, Chocolatey, OneGet… what?! People ask questions and occasionally can’t see the forest for the trees. Here’s a quick recap:

NuGet: a solution-level package management tool, used to manage software dependencies within the scope of a solution. It is accompanied by the NuGet Gallery, the home of many if not all .NET open source components.

Chocolatey: a system-level package management tool, used to manage software installations on a Windows system. It (currently) leverages PowerShell and NuGet, supports the Web Platform Installer (WebPI), MSI, RubyGems and many more, and is accompanied by the Chocolatey Gallery where you can find many popular software packages. Rob describes Chocolatey as somewhat like “apt-get”, but with Windows in mind.

MyGet: a hosted NuGet package server where you can create and secure your own feeds. In essence, MyGet is able to host vanilla NuGet feeds, as well as Chocolatey feeds.

OneGet: a a unified interface to package management systems (see above)

http://www.xavierdecoster.com/using-myget-as-a-oneget-package-source

And more, and more:

PSGet and PSReadLine https://github.com/lzybkr/PSReadLine
pregunton
Wednesday, 05 August 2015 22:44:11 UTC
@Jabe You're complaining that an something unfinished is unfinished.

From the blog post:

Plus, OneGet isn't done and it's open source so there's lots of cool possibilities.

and

It's an unsupported version of Chocolatey provider in a GitHub repo
Brendan
Wednesday, 05 August 2015 23:02:35 UTC
@davidacoder OneGet came out of the CoApp project, which was an attempt to do exactly that. It didn't work because they couldn't get enough people on board with one system with one set of design choices/tradeoffs, which also happened to require repackaging everything in the world. So instead, we have a system that doesn't dictate how packages are discovered or installed, and can take advantage of existing packaging work.

Hopefully, this system can still provide things like automatic updates.

@David Sounds like a bug in the Chocolatey provider to me. OneGet does not assume you need to be an administrator to do anything (that would not be true of all packaging systems, for example if you install Python as a non-admin user, a Python provider would be able to install packages for it as that user), so it's up to individual providers to figure this out and elevate when necessary.
Vincent Povirk
Thursday, 06 August 2015 00:04:55 UTC
I still prefer ninite.com for new PCs.
PRMan
Thursday, 06 August 2015 00:35:01 UTC
@Sean Jon this didn't actually install the apps for me either until I changed the PowerShell Execution policy. The Default policy on my Windows 10 install was set to "Restricted" which does not allow .ps1 files to execute (even when I tried it in an Admin shell). Changing the policy to "Bypass" inside of a PowerShell console allowed Scott's example to actually install the software.

Set-ExecutionPolicy Bypass
Kerry
Thursday, 06 August 2015 02:12:24 UTC
@Kerry, I was wondering if I needed to do that; too busy at work and I didn't have time to confirm. Thanks!
Matt
Thursday, 06 August 2015 04:07:23 UTC
Chocolatey was fully funded on Kickstarter. Why are thy still asking for donations?
Marshall Grant
Thursday, 06 August 2015 04:37:33 UTC
@Marshall: Because the more, the merrier!
Onur
Thursday, 06 August 2015 07:52:53 UTC
I applaud the decision to provide the platform and abstractions to build an eco system but to bootstrap this I fail to see why Microsoft has not supported early implementations with funding, either through donations, developers like libgit2, or direct employment like with Glimpse.

The dedication that patently goes into choco is inspiring. However it pains me to see package management for windows run on a part time, extreme hobbiest, donation basis.

Am looking forward to Hashicorp and other players in this field getting involved too.

I think I'd just like to see a real apt-get on windows, whether that means Microsoft writing their own implementation for one-get or them backing something else like choco.

It's a long road but Windows is so far behind linux in some aspects - like apt-get - and as a Windows user I wish Microsoft would get there a bit quicker. 2016 (Windows Server) is too far away.

Embryonic yes, but a good start none-the-less. Fingers crossed this will iterate fast.
Thursday, 06 August 2015 08:23:03 UTC
Well, my Version Numbers are totally different. (yes, i'm on Windows 10 Build 10240 SR1). Any Ideas why?


Name                     Version          DynamicOptions
---- ------- --------------
Programs 10.0.10122.0 {IncludeWindowsInstaller, IncludeSystemComponent}
msu 10.0.10122.0 {}
msi 10.0.10122.0 {AdditionalArguments}
PSModule 10.0.10122.0 {PackageManagementProvider, Location, InstallUpdate, InstallationPolicy...}
Chocolatey 2.8.5.101 {SkipDependencies, ContinueOnFailure, ExcludeVersion, ForceX86...}
NuGet 2.8.5.101 {Destination, SkipDependencies, ContinueOnFailure, ExcludeVersion...}
Albert Weinert
Thursday, 06 August 2015 11:10:13 UTC
Nice! Might go update my BootstrapForPCs repo to use this approach or at least give it a go.
Thursday, 06 August 2015 14:58:31 UTC
@Kerry: Great call! Running that command made it install packages properly.

So, next problem-- uninstall-package doesn't work! It removes the package from the package-management directory, so powershell/oneget/whatever you call it _thinks_ the package was removed, but I can still run it and was forced to use the graphical uninstaller.

Another major missing feature with powershell windows package-management is that there's no "upgrade" command. In my ubuntu box, I simply run "apt-get update" to refresh all the repositories followed by "apt-get upgrade" to upgrade all my packages. As far as I can tell, there is no equivalent to either command in windows package-management-- it works on individual packages only and does not maintain a local repository cache.

So... baby steps. It's pretty far from feature-parity with yum or apt, and it's not ready to actually be used, but it's encouraging.
Sean Jon
Thursday, 06 August 2015 15:34:56 UTC
The problem with Chocolately and by extension OneGet is that package verification is hard. Currently anyone can upload any package, even if they are not the author/owner. They are doing a review of all uploads but that's neither fool-proof nor scalable. They need a solution where either the vendors themselves are participating or all the packages can be verified/matched to the releases that are provided by the vendors on their own sites.


It makes me nervous when I see that Firefox (for example) is uploaded/maintained by someone other than Mozilla.
Aemon
Friday, 07 August 2015 11:46:21 UTC
Cool post, Scott. Appreciate this sort of info!
MichaelD!
Saturday, 08 August 2015 21:04:40 UTC
Love this! Thanks for the post. Works great on my upgraded Win 10 boxes, but on my clean install with Windows 10 Enterprise, just get a warning that it can't find Chocolatey (regardless of what various ways I try to get Chocolatey installed).

Likely something not supported by Win 10 Enterprise, or else restricted by policy, so nothing to worry about. Plus, I can just install Chocolatey directly and use it as before.
Steven Borg
Sunday, 09 August 2015 07:55:04 UTC
get-packageprovider -name chocolatey
WARNING: Unable to find package provider 'chocolatey'.

Any ideas?
Sunday, 09 August 2015 16:15:04 UTC
https://xkcd.com/927/
Sigh
Sunday, 09 August 2015 22:31:19 UTC
Thanks bhaiya for this post. I love you for this.
From radhamohan singh techie
Wednesday, 12 August 2015 13:10:24 UTC
Zero Install (cross-platform package manager) also comes with a OneGet provider. Hopefully it'll be added to the OneGet bootstrapping list soon. You can track the progress in this GitHub issue.

One of the nice features of Zero Install is side-by-side installation allowing multiple versions of apps, clean uninstalls and no DLL hell. Full disclosure: I'm the main Windows dev on the project.
Wednesday, 12 August 2015 14:30:33 UTC
Am I the only one thinking on this as an abstract factory? :P
Nice article!
Thursday, 13 August 2015 09:31:31 UTC
Is there a way to remove a package provider again?
phil
Thursday, 13 August 2015 22:30:08 UTC
Where are the Exe's? I am having a hard find finding the installed programms like Notepad2? Every Install-Package/Get-Package/Find-Package runs fine but there a no exes in C:\Chocolatey or anywhere else:(

I am using Win10 Build 10240 - 32 Bit.

Regards,
Peter
Peter
Friday, 14 August 2015 07:18:55 UTC
Ok, I found it (thanks to Kerry who mentioned it already). Without setting Execution Policy to something other than restricted nothing gets actually downloaded because the install script won't run. But at least a warning message would have been helpful.

Regards,
Peter
Peter
Friday, 14 August 2015 15:13:20 UTC
FYI, Get-PackageProvider fails with "The term 'New-Feature is not recognized..." in a PowerShell with admin rights until you run Update-Help.

Martin
Friday, 14 August 2015 20:35:29 UTC
OneGet and Chocolatey both have terrible documentation. It's all 5 month old blog posts leading to confusingly named websites and GitHub repositories, abandoned Twitter accounts, and the strangely non-commitant release notes of Chocolatey ("may break something in some cases, but it's better, we hope")

This blog post is the clearest yet since the Windows 10 release, so Scott, if you know any of them, be sure to tell them when you meet them that Windows 10 has been released, and they need to get their act together. Start blogging, update those websites, remove those beta/preview feeds, edit those GitHub wiki's and readmes, and start tweeting!
Mike
Friday, 14 August 2015 20:44:55 UTC
Also, none of this actually works, as is clear from the comments here, so at best we are all talking about a proof of concept that shipped in Windows 10.

I think it can be great for pro users and developers, but not with Chocolatey. As someone else said, Chocolatey is just wrapping .exe in .ps1, usually to add --silent switches. One should never just download and run installers, yet this is what Chocolatey will end up encouraging.

The only way forward is installations that are purely based on declarative syntax, not executable code. The trusted installer will simply copy files, nothing more. And apps will remain sandboxed, not registry access, just file in their own install dir, in temp, and in their own dir in user data.
Mike
Friday, 14 August 2015 20:59:24 UTC
@Mike: I hope this isn't coming across as too blatant advertising, but that is pretty much what Zero Install (http://0install.de/) does: Purely declarative syntax, installer simply extracts archives and any system changes (e.g. file type associations) are triggered and controlled by the user, not the package. There is no sandboxing of the actual installed application (yet).
Saturday, 15 August 2015 23:49:07 UTC
OK I had a lot of trouble getting these steps running on a clean Windows 10 installation, if anyone else is encountering the same issues, you might want to read on:

1. First, run PowerShell as Administrator, otherwise nothing will work and it will silently fail (yes, it's annoying).
2. Run Set-ExecutionPolicy RemoteSigned in the console.
3. Run the commands in Scott's blog post to enable Chocolatey provider and install packages (such as vlc).
4. Chocolatey, for now, does not add its bin directory to %PATH% environment variable, therefore command-line packages (those without an installer) might not work when you type their name. Therefore add C:\Chocolatey\bin (not sure about the exact path) to your PATH environment variable and relaunch your console.
Thursday, 20 August 2015 08:12:36 UTC
Excellent post. Here a lab with examples and OneGet and Chocolatey:

http://www.sysadmit.com/2015/08/windows-oneget-y-chocolatey.html

Manuel
Tuesday, 25 August 2015 15:12:31 UTC
Once I've used Linux I became sick of all that 'yum' and 'apt-get' stuff forever.

Until all you need is 'apt-get install mc' on a newly created VM it's all great. But when you need some particular version of some particular software, you are googling for all that repositories, which are maintained by god knows who, and you don't really know if it will be available next time you need it.
yaapelsinko
Wednesday, 02 September 2015 20:17:31 UTC
This is another fail by Microsoft making something that should be fairly simple way too complicated. Think about how many wrappers there are that can break between the code. There is the MSI which MS took out for a few years. Then introduced a buggy addon that has gotten bad feedback. Then you wrap that MSI in Chocolatey then you use Oneget to manage the Chocolatey and other repos... Seriously guys?

All this just to package code and install apps. I think you can do better so much better than this over there.
Z
Saturday, 19 September 2015 02:44:41 UTC
A particularly impressive provider would be Steam, though I doubt I'll see it.
Brianary
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.