6

Steps followed as in the documentation

$ curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add -
$ echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/migrate.list
$ apt-get update
$ apt-get install -y migrate

The error i'm getting in the first step is

    sudo curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0E: This command can only be used by root.
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100  3954  100  3954    0     0   2244      0  0:00:01  0:00:01 --:--:-- 17651
(23) Failed writing body

Please help me with this?
sajir mohamed
  • 355
  • 1
  • 3
  • 9

6 Answers6

18

this is the easiest method to download a pre-built binary and move it to a location on your system path:

$ curl -L https://github.com/golang-migrate/migrate/releases/download/v4.14.1/migrate.linux-amd64.tar.gz | tar xvz

$ mv migrate.linux-amd64 $GOPATH/bin/migrate
8

For quickinstall;

$ curl -s https://packagecloud.io/install/repositories/golang-migrate/migrate/script.deb.sh | sudo bash
$ apt-get update
$ apt-get install -y migrate
sajir mohamed
  • 355
  • 1
  • 3
  • 9
3

You need to download the source code of the package from GitHub (https://github.com/golang-migrate/migrate), build it and place the built utility at the directory with binary files.

 git clone https://github.com/golang-migrate/migrate.git
 cd migrate
 make build
 mv ./migrate ./usr/bin
sigma1510
  • 1,165
  • 1
  • 11
  • 26
Brotiger
  • 31
  • 3
1

It's strange that there is no installation text.

  1. run either of these command
$ go get -u -d github.com/golang-migrate/migrate/cmd/migrate

or 

$ go get -u -d github.com/golang-migrate/migrate

this would download golang-migrate to your GO_PATH, e.g. /home/ubuntu/go/pkg

  1. cd to this folder: ( the v4@4.14.1 may change on your actual situation)
$ cd ~/go/pkg/mod/github.com/golang-migrate/migrate/v4@v4.14.1/cmd/migrate
  1. go install .

wait seconds and then you will see migrate command available in your GO_PATH:

$which migrate     // ->   /home/siwei/go/bin/migrate

But I love Rails' migration. It's more advanced.

Siwei
  • 19,858
  • 7
  • 75
  • 95
0

Here there is an assumption that you are a root user or user with privileges to modify repositories in apt. On a local machine, try appending sudo before commands, log in as a root user, and then run your commands.

curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | sudo apt-key add -
-1

One may also use asdf (which I did) to easily switch between different versions of migrate for testing:

$ asdf plugin-list-all| grep migrate
gomigrate                     https://github.com/joschi/asdf-gomigrate.git
$ asdf plugin-add gomigrate
$ asdf install gomigrate latest
Downloading migrate from https://github.com/golang-migrate/migrate/releases/download/v4.16.2/migrate.linux-amd64.tar.gz
$ asdf global gomigrate latest
# and voila
$ migrate --version
4.16.2

How to install asdf itself in any OS is documented here: https://asdf-vm.com/guide/getting-started.html