install go compiler without sudo right

1,413 views
Skip to first unread message

tungche...@gmail.com

unread,
Dec 20, 2016, 6:24:22 PM12/20/16
to golang-nuts
I am trying to install go on my school server (without sudo right)

I tried to install go1.4 then use it to install latest go.
However, it failed when running all.bash for go1.4
Seems the system doesn't support (or no permission) hard link.

I also tried to copy the files from my personal computer to the server. It will say missing 'sigtable' when compiling my source code.

Is it possible to install go compiler without sudo right?
Seems compiling elsewhere then deploy the executable is the only working solution for me so far.

tungche...@gmail.com

unread,
Dec 20, 2016, 6:29:47 PM12/20/16
to golang-nuts, tungche...@gmail.com
The server is running CENTOS 7.1.15 , Xeon(R)

lscpu result
```
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 37
Model name:            Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz
Stepping:              1
CPU MHz:               2099.999
BogoMIPS:              4199.99
Hypervisor vendor:     VMware
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              15360K
NUMA node0 CPU(s):     0-3
```
It is VMWare instant if that matter

Dave Cheney

unread,
Dec 20, 2016, 6:31:42 PM12/20/16
to golang-nuts, tungche...@gmail.com
Yes, it is possible to install Go without sudo, here is the procedure

% cd go1.4/src
% git checkout release-branch.go1.4
% ./make.bash
% cd ~
% cd go/src
% git checkout release-branch.go1.7
% ./make.bash
Message has been deleted

bill.h...@gmail.com

unread,
Dec 22, 2016, 12:57:40 PM12/22/16
to golang-nuts, tungche...@gmail.com
Do you want to use Go version 1.4 specifically for some reason?  

If not, I'd recommend going with the most recent stable release (1.7.4).

Besides the git clone/build process Dave Cheney mentioned, you can download a binary build of the compiler/tools for Linux at:


If you want a different version/architecture, you can see the list at https://golang.org/dl/

peterGo

unread,
Dec 23, 2016, 9:29:59 AM12/23/16
to golang-nuts, tungche...@gmail.com, bill.h...@gmail.com
Bill,

The OP said: "I tried to install go1.4 then use it to install latest go."

Then you asked the OP: "Do you want to use Go version 1.4 specifically for some reason?"

Peter

tungche...@gmail.com

unread,
Dec 26, 2016, 12:29:03 AM12/26/16
to golang-nuts, tungche...@gmail.com
I was using all.bash, just tried make.bash. It failed for the same reason:
```
<parent>/go/src/runtime/os_linux.go:310: undefined: sigtable
<parent>/go/src/runtime/os_linux.go:311: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:43: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:44: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:68: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:101: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:116: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:120: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:134: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:138: undefined: sigtable
<parent>/go/src/runtime/signal1_unix.go:138: too many errors
```

Dave Cheney

unread,
Dec 26, 2016, 12:56:12 AM12/26/16
to golang-nuts
If it is is possible can you always post the complete failure log, including the commands you entered.

My guess is one or more of these things have happened

1. You have one or more existing go installations on your system already
2. You have set GOROOT, you should not set GOROOT when compiling from source.
3. You have checked out one version of Go over another.

peterGo

unread,
Dec 26, 2016, 5:50:04 PM12/26/16
to golang-nuts, tungche...@gmail.com
You tell us that you tried some stuff and it didn't work. The first step in debugging is to provide a simple, reproducible example. For example, here's a statement of a problem, a recipe for the Go boostrap compiler step, and a log of the output and the results. It's reproducible. Sudo is only required if the prerequisite packages need to be installed.

To help you, we need a simple, reproducible example.

Peter


The problem:

The only way to learn a new programming language is by writing programs in it. The first program to write is the
same for all languages:

    Print the words
        hello, world

This is a big hurdle; to leap over it you have to be able to create the program text somewhere, compile it
successfully, load it, run it, and find out where your output went. With these mechanical details mastered,
everything else is comparatively easy.

The C programming Language
By Brian W. Kernighan and Dennis M. Ritchie.


The program in Go:

    package main

    import "fmt"

    func main() {
        fmt.Println("Hello, 世界")
    }



A recipe, with diagnostics, for the Go bootstrap compiler step:

# Recipe for Go bootstrap compiler:

# Install CentOS: CentOS-7-x86_64-LiveCD-1503.iso
$ uname -a

# If necessary, install prerequisites
$ sudo yum install -y -q git
$ git --version
$ sudo yum install -y -q gcc libc6-dev
$ gcc --version

# Install minimal Go bootstrap compiler
$ cd $HOME
$ git clone -b release-branch.go1.4 --depth 1 https://go.googlesource.com/go go1.4
$ cd go1.4/src
$ git branch
$ CGO_ENABLED=0 ./make.bash
# The expected results:
# Installed Go for linux/amd64 in /home/peter/go1.4
# Installed commands in /home/peter/go1.4/bin
$ cd $HOME
$ cd go1.4/bin
$ ./go version
$ ./go env
$



Output Log:

[peter@localhost ~]$ uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[peter@localhost ~]$
[peter@localhost ~]$ sudo yum install -y -q git
[sudo] password for peter:
[peter@localhost ~]$ git --version
git version 1.8.3.1
[peter@localhost ~]$ sudo yum install -y -q gcc libc6-dev
[peter@localhost ~]$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)
[peter@localhost ~]$
[peter@localhost ~]$ cd $HOME
[peter@localhost ~]$ git clone -b release-branch.go1.4 --depth 1 https://go.googlesource.com/go go1.4
Cloning into 'go1.4'...
remote: Counting objects: 4753, done
remote: Finding sources: 100% (4753/4753)
remote: Total 4753 (delta 569), reused 2706 (delta 569)
Receiving objects: 100% (4753/4753), 11.64 MiB | 627.00 KiB/s, done.
Resolving deltas: 100% (569/569), done.
Checking out files: 100% (4392/4392), done.
[peter@localhost ~]$ cd go1.4/src
[peter@localhost src]$ git branch
* release-branch.go1.4
[peter@localhost src]$ CGO_ENABLED=0 ./make.bash
# Building C bootstrap tool.
cmd/dist

# Building compilers and Go bootstrap tool for host, linux/amd64.
lib9
libbio
liblink
cmd/cc
cmd/gc
cmd/6l
cmd/6a
cmd/6c
cmd/6g
runtime
errors
sync/atomic
sync
io
unicode
unicode/utf8
unicode/utf16
bytes
math
strings
strconv
bufio
sort
container/heap
encoding/base64
syscall
time
os
reflect
fmt
encoding
encoding/json
flag
path/filepath
path
io/ioutil
log
regexp/syntax
regexp
go/token
go/scanner
go/ast
go/parser
os/exec
os/signal
net/url
text/template/parse
text/template
go/doc
go/build
cmd/go

# Building packages and commands for linux/amd64.
runtime
errors
sync/atomic
unicode
sync
io
unicode/utf8
math
bytes
bufio
syscall
time
strconv
reflect
os
strings
sort
fmt
encoding/binary
regexp/syntax
cmd/internal/goobj
cmd/internal/rsc.io/arm/armasm
cmd/internal/rsc.io/x86/x86asm
debug/dwarf
debug/elf
debug/gosym
debug/macho
debug/pe
debug/plan9obj
regexp
text/tabwriter
flag
log
cmd/internal/objfile
hash
crypto
crypto/md5
go/token
path/filepath
cmd/addr2line
go/scanner
go/ast
io/ioutil
go/printer
go/parser
os/exec
go/format
cmd/cgo
path
cmd/fix
container/heap
encoding
encoding/base64
unicode/utf16
encoding/json
encoding/xml
net/url
text/template/parse
compress/flate
text/template
hash/crc32
compress/gzip
container/list
crypto/subtle
crypto/cipher
crypto/aes
go/doc
crypto/des
math/rand
math/big
go/build
crypto/elliptic
encoding/asn1
crypto/hmac
internal/syscall
crypto/rand
crypto/rc4
crypto/rsa
crypto/ecdsa
crypto/sha1
crypto/sha256
crypto/dsa
crypto/sha512
crypto/x509/pkix
encoding/hex
encoding/pem
net
mime
net/http/internal
os/signal
runtime/pprof
cmd/gofmt
cmd/nm
crypto/x509
crypto/tls
net/textproto
mime/multipart
cmd/objdump
net/http
cmd/pack
cmd/pprof/internal/profile
cmd/go
cmd/pprof/internal/plugin
html
html/template
cmd/pprof/internal/report
cmd/pprof/internal/svg
cmd/pprof/internal/tempfile
cmd/pprof/internal/commands
cmd/pprof/internal/driver
cmd/pprof/internal/fetch
cmd/pprof/internal/symbolizer
cmd/pprof/internal/symbolz
cmd/pprof
cmd/yacc
archive/tar
archive/zip
compress/bzip2
compress/lzw
hash/adler32
compress/zlib
container/ring
database/sql/driver
encoding/ascii85
encoding/base32
database/sql
encoding/csv
encoding/gob
expvar
hash/crc64
hash/fnv
image/color
image
image/color/palette
image/draw
image/jpeg
image/gif
image/png
index/suffixarray
log/syslog
math/cmplx
net/http/cgi
net/http/cookiejar
net/http/httptest
net/http/fcgi
net/http/httputil
net/http/pprof
net/mail
net/rpc
net/smtp
os/user
runtime/debug
net/rpc/jsonrpc
runtime/race
testing
testing/iotest
testing/quick
text/scanner


---
Installed Go for linux/amd64 in /home/peter/go1.4
Installed commands in /home/peter/go1.4/bin
[peter@localhost src]$ cd $HOME
[peter@localhost ~]$ cd go1.4/bin
[peter@localhost bin]$ ./go version
go version go1.4-bootstrap-20161024 linux/amd64
[peter@localhost bin]$ ./go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/home/peter/go1.4"
GOTOOLDIR="/home/peter/go1.4/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
[peter@localhost bin]$
Reply all
Reply to author
Forward
0 new messages