Skip to content

Blog

Install Git on Windows via Chocolatey

This post shows how to use Chocolatey to install Git.

Chocolatey

If you do not have Chocolatey, you can install it by following the instructions on chocolatey.org. You may also see this post for instructions on how to set the Chocolatey cache location.

Git

Install Git

In PowerShell as Administrator:

choco install git --params "/GitAndUnixToolsOnPath /NoAutoCrlf"

Close and open PowerShell, so it can pick the updated PATH environment.

Verify

Verify you have git:

git --version
git version 2.6.4.windows.1

Verify you have ssh:

ssh
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port]
           [-Q cipher | cipher-auth | mac | kex | key]
           [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] [user@]hostname [command]

How to use a different cache directory for Chocolatey packages

About Chocolatey

In short, Chocolatey is a package manager for Windows which saves time by automating otherwise manual installation tasks. You can install Chocolatey by following the instructions on chocolatey.org.

Configure Chocolatey's Cache Folder

For security reasons, Chocolatey installs in C:\ProgramData\chocolatey by default. See Why does Chocolatey install where it does? for more information.

Also by default, Chocolatey will download packages in C:\Users\USERNAME\AppData\Local\Temp\chocolatey which might work or not for you. If you need to use a different folder, you can set the cacheLocation key in C:\ProgramData\chocolatey\config\chocolatey.config to a folder of your choice.

For example, to use C:\ChocolateyCache as a cache folder, add <add key="cacheLocation" value="C:\ChocolateyCache" description="Cache location if not TEMP folder." /> to the chocolatey.config file like this:

<?xml version="1.0" encoding="utf-8"?>
<chocolatey xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <containsLegacyPackageInstalls>false</containsLegacyPackageInstalls>
  <commandExecutionTimeoutSeconds>0</commandExecutionTimeoutSeconds>
  <config>
    <add key="cacheLocation" value="C:/ChocolateyCache" description="Cache location if not TEMP folder." />
    <add key="containsLegacyPackageInstalls" value="true" description="Install has packages installed prior to 0.9.9 series." />
    <add key="commandExecutionTimeoutSeconds" value="2700" description="Default timeout for command execution." />
    <add key="proxy" value="" description="Explicit proxy location." />
    <add key="proxyUser" value="" description="Optional proxy user." />
    <add key="proxyPassword" value="" description="Optional proxy password. Encrypted." />
  </config>
  <sources>
    <source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="false" priority="0" />
  </sources>
  <features>
    <feature name="checksumFiles" enabled="true" setExplicitly="false" description="Checksum files when pulled in from internet (based on package)." />
    <feature name="autoUninstaller" enabled="false" setExplicitly="false" description="Uninstall from programs and features without requiring an explicit uninstall script." />
    <feature name="allowGlobalConfirmation" enabled="false" setExplicitly="false" description="Prompt for confirmation in scripts or bypass." />
    <feature name="failOnAutoUninstaller" enabled="false" setExplicitly="false" description="Fail if automatic uninstaller fails." />
  </features>
  <apiKeys />
</chocolatey>

Unable to generate an explicit migration because the following explicit migrations are pending

After renaming the namespace of some POCO classes from Primo.LicenseManager.Models to Primo.Licensing.DataModel, the Entity Framework scaffolding no longer recognizes the applied migrations:

Add-Migration -Name AddInvoiceEntity -Verbose -StartUpProjectName LicensingDataModel -ProjectName LicensingDataModel

Unable to generate an explicit migration because the following explicit migrations are pending: [201310191546582_CreateTables]. 
Apply the pending explicit migrations before attempting to generate a new explicit migration.

In SQL Server Management Studio:

select * 
from __MigrationHistory 
where MigrationId = '201310191546582_CreateTables'

MigrationId: 201310191546582_CreateTables
ContextKey: Primo.LicenseManager.Models.Migrations.Configuration
Model: 0x1F8B08000000....
ProductVersion: 5.0.0.net45

The problem

In the database, the ContextKey in the __MigrationHistory table is still the old namespace: Primo.LicenseManager.Models.Migrations.Configuration.

The solution

Update the ContextKey to the new namespace Primo.Licensing.DataModel.Migrations.Configuration

update __MigrationHistory 
set ContextKey = 'Primo.Licensing.DataModel.Migrations.Configuration'
where MigrationId = '201310191546582_CreateTables'

Now this works:

Add-Migration -Name AddInvoiceEntity -Verbose -StartUpProjectName LicensingDataModel -ProjectName LicensingDataModel

How to upgrade the Linux kernel to 3.11 on Ubuntu 12.04.4 LTS

I have two Ubuntu 12.04.4 virtual machines that I use for building and testing AVBlocks - one 32 bit (i386) and one 64 bit (x86_64). Normally I keep them in sync and regularly updated via the Update Manager.

I noticed today that for some reason, the 32-bit machine upgraded to Linux kernel 3.11, but the 64-bit machine is stuck with Linux kernel 3.8. The Update Manager reports that both systems are up-to-date, yet the kernel versions are different on both systems.

Ubuntu 12.04.4 LTS x86_64

uname -a
Linux ubuntu-12-04-x64 3.8.0-39-generic #58~precise1-Ubuntu SMP Fri May 2 21:33:40 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:    12.04
Codename:   precise

Ubuntu 12.04.4 LTS i386

uname -a
Linux ubuntu-12-04-i386 3.11.0-20-generic #35~precise1-Ubuntu SMP Fri May 2 21:35:48 UTC 2014 i686 i686 i386 GNU/Linux
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:    12.04
Codename:   precise

The solution

After some reading on internet, I found that, only installations made from Ubuntu 12.04.2 ISO images and above will receive the 3.11 Linux kernel update automatically. For all other installations you will have to update it manually per this Ubuntu wiki article.

So, for Ubuntu 12.04.4, you have to install the Saucy (13.10) Hardware Enablement Stack:

sudo apt-get install --install-recommends linux-generic-lts-saucy xserver-xorg-lts-saucy libgl1-mesa-glx-lts-saucy
sudo reboot

Executable shell scripts open in Gedit on Ubuntu

This started happening after an upgrade to Ubuntu 13.04. We have shell scripts here and there saved as .run files, e.g. Build.linux.auto.run, to automate AVBlocks builds on Linux. Normally Nautilus will ask you whether you want to run the script when you double click a .run file, but on Ubuntu 13.04, Nautilus suddenly started opening .run files in Gedit. It turns out there is a setting in Gnome for that. Here is how to fix it:

  1. Run dconf-editor and navigate to org.gnome.nautilus.preferences
  2. Change the value of the executable-text-activation setting from display to ask.

If you do not have dconf-editor you can install these packages:

sudo apt-get install dconf-tools
sudo apt-get install gconf-editor

And just in case, this is how you run it:

dconf-editor