Install snap on Ubuntu Precise - go

After a purchase of ARK-20-S8A11E, i find out that it only supports ubuntu 12.04 and that network manager uses snap which only availale on ubuntu 14 onward. I need Mobilemanager to collect information of an LTE module integrated in the PC.
For that, i tried to install snap from source.
I needed "go", and with apt-get install golang, the last version installed on precise is go1. and snap uses go1.6 onward version.
Therefore, i installed the latest version of go from sources. It is well installed, the output of go --version is : go version go1.11.4 linux/amd, and tested a basid hello.go.
I followed this link for snap installation: https://github.com/snapcore/snapd/blob/master/HACKING.mdsnap.
The build command " sudo -E go build -o /tmp/snap github.com/snapcore/snapd/cmd/snap" give an output as the "go command not found".
The GOPATH and PATH are well verified, the go env also.
Could you please help me sort this issue?
Thank you,

sudo is the troublemaker here. When sudoing the $PATH env var is replaced with the secure_path from /etc/sudoers (see this and this.)
Either do not run go as sudo, add the go path to the secure_path or include the full path to go in your command (sudo -E /usr/local/bin/go build -o /tmp/snap github.com/snapcore/snapd/cmd/snap)

Related

solana install on Ubuntu - where is it installed to?

I tried to follow steps both
a. https://docs.solana.com/cli/install-solana-cli-tools
(base) xxx#xxx:~/dev/nft/metaplex/metaplex/js/packages/cli$ sudo sh -c "$(curl -sSfL https://release.solana.com/v1.8.1/install)"
[sudo] password for xxx:
downloading v1.8.1 installer
Install is up to date.
1.8.1 is the latest compatible release
Please update your PATH environment variable to include the solana programs:
PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
I updated $PATH, but no joy. I got no installation error but command prompt can't find solana.
b. I then also tried steps here
https://snapcraft.io/install/solana/ubuntu#install
(base) xxx#xxx:~/.local/share$ sudo snap install solana --beta --devmode
solana (beta) 0+git.ca12fac from Michael Vines (mvines) installed
(base) xxx#xxx~/.local/share$ solana --version
solana: command not found
Where was solana installed to actually? I can't find it.
Typically, the setup script that you ran in the first step installs the solana CLI in $HOME/.local/share/solana/install/active_release/bin/ and then adds it to your PATH in $HOME/.profile.
As an easy fix, you can logout and log back in to pick up the change.
I think the issue comes from that you updated the $PATH variable in wrong location.
In many cases, we have two options /home/[username]/.bashrc and /home/[username]/.profile to update the $PATH variable.
When I was installing solana tool suite, I updated the /home/[username]/.profile.
In other word, I inserted export PATH="/home/[username]/.local/share/solana/install/active_release/bin:$PATH" at the end of .profile.
And it worked.
I think you should try this way if you didn't yet.
About the options of terminals(bash, etc) and $PATH variable, I recommend to take a look at Where is PATH variable set in Ubuntu?

Unable to install Go packages in Macbook with M1 chip

When I ran the command "go install github.com/go-delve/delve/cmd/dlv" in the delve folder, after downloading go-delve in my go path, the terminal showed the following result:
"go install github.com/go-delve/delve/cmd/dlv: mkdir /Desktop: read-only file system"
Terminal result put here
When I googled the same, I came across a website(https://www.dev2qa.com/how-to-fix-read-only-file-system-error-when-run-mkdir-command-on-macos/) which requires me to disable System Integrity Protection on my MacBook and it asks me to hold the option key or command + R immediately after Mac chimes in reboot after starting the MacBook, until I see a boot in a "console/terminal" mode.. But nothing happened when I tried doing that.
I am not knowing what to do. Please guide me through the right way to install dlv and other packages of go successfully on my Macbook.
make sure you use the right go version (1.16 or later, arm64)
$ go version
go version go1.17.1 darwin/arm64
make sure the env is right by this command
$ go env
check GOROOT GOPATH GOARCH GOBIN
try to install it directly
$ go install github.com/go-delve/delve/cmd/dlv#latest
your error occurs because you have no permission of /Desktop, and i'm sure install dlv don't need something like this, it will install to ~/go/bin

I'm trying to set up the emscripten SDK on Windows 10 but emcc can't be found

On linux there's no problem but I want to compile my code on windows. I follow the instructions exactly. Specifically, I open a command prompt and run the following in the same directory I cloned the emscripten git repo in to.
git pull
emsdk install latest
emsdk activate latest
emsdk_env.bat
There is suspiciously no output and emcc cannot be found. What could I be doing wrong here?
If you go to the command line and type python --version the version of python installed should come up.
If it doesn't, go to the directory in which python is installed and add this to your PATH.
Restart the command prompt and try python --version again. If you get the version of python, follow the steps you mentioned.
You should get some output.
Let me know if the problem still has not been resolved.
You need to install Python 2.7.12 or newer.
https://emscripten.org/docs/getting_started/downloads.html#windows

How to install libvirt-go? (pkg-config)

Libvirt was installed with "dnf install". For libvirt-go - $ go get github.com/libvirt/libvirt-go.
As a result:
enter image description here
How I can change PKG_CONFIG_PATH? Or how to install libvirt-go right?
You need to install the libvirt development package, eg libvirt-devel on Fedora/RHEL/Centos, or libvirt-dev on Debian/Ubuntu.
The libvirt-go build process will just query 'pkg-config' to find out where it is installed, so if you did have it installed in a non-standard location (eg /opt/libvirt), then you would do 'export PKG_CONFIG_PATH=/opt/libvirt/lib/pkgconfig' and then libvirt-go would find that.

exec: "gcc": executable file not found in %PATH% when trying go build

I am using Windows 10. When I tried to build Chaincode it reported this error
# github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11
exec: "gcc": executable file not found in %PATH%
My chaincode imports:
import (
"fmt"
"strconv"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
It's running fine in Docker.
gcc (the GNU Compiler Collection) provides a C compiler. On Windows, install TDM-GCC. The github.com/miekg/pkcs11 package uses cgo. Cgo enables the creation of Go packages that call C code.
If you are running Ubuntu do:
apt-get install build-essential
This solved the problem. It installs the gcc/g++ compilers and libraries.
I also encountered this message, but in my case, it was missing gcc.exe. I used choco and installed mingw, and then it worked.
details:
download choco
choco install mingw -y
check: gcc -v
1) Install .exe from > https://sourceforge.net/projects/mingw-w64/
1.2) ! use x86_64 architecture
2) Add C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin to PATH in User Variables and in System Variables. For me it works.
! To edit Path variable press Windows key, type 'path', choose 'Edit the system environment variables', click 'Environment Variables', find Path variable in System variables and in User variables then edit.
On Windows install http://tdm-gcc.tdragon.net/download, that is all.
If you are using an alpine based image with your Dockerfile
Install build-base which will be met with your requirements.
apk add build-base
$ go env
check CGO_ENABLED if its 1 change it to 0 by
$export CGO_ENABLED=0
For my case :
os: windows 10
command:
choco install mingw
install choco if not installed:
Link: https://www.liquidweb.com/kb/how-to-install-chocolatey-on-windows/
worked for me.
The proper explanations why go build does not work for hyperledger in Windows environment are given as other answers.
For your compilation purposes, just to make it work without installing anything extra, you can try the following
go build --tags nopkcs11
It worked for me. I hope same works for you too.
You can try - this is not a solution but a temp workaround
cgo_enabled=0 go build
Once you install gcc - and make sure %PATH has a way to find it (gcc.exe) - this should go away.
Also running this one will ensure the cgo_enabled variable will stay this way as long as terminal is open. That way you don't have to prefix it each time you do a build.
export cgo_enabled=0 go build
just followed instructions from following and it solve my issue
https://code.visualstudio.com/docs/cpp/config-mingw
it ask to install Mingw-w64 via MSYS2
important command is pacman -S --needed base-devel mingw-w64-x86_64-toolchain
then add C:\msys64\mingw64\bin to PATH
thanks
For Ubuntu, what worked for me was to simply run:
sudo apt install gcc
On Amazon Linux 2:
Install go
wget https://go.dev/dl/go1.18.1.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
Install gcc
sudo yum groupinstall "Development Tools"
I recommend using the package group, even though it can be done without it, because groupinstall gives you the necessary packages to compile software on Amazon Linux and Redhat, CentOS for that matter.
on Ubuntu its very easy but on windows need to do it:
download MinGW on http://www.mingw.org/
install on basic package Gcc-g++ (see this image)
add on environment Patch of windows variables.
restart and continue with "go get ..."
If you are running Ubuntu do:
sudo apt-get update
sudo apt-get install build-essential.
If the above commands do not work do:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe"
The main component contains applications that are free software, can be freely redistributed and are fully supported by the Ubuntu team. & The universe component is a snapshot of the free, open-source, and Linux world.
Then install package by following command in terminal:
sudo apt-get update
sudo apt-get install build-essential.
For more info click here: https://itectec.com/ubuntu/ubuntu-problem-installing-build-essential-on-14-04-1-lts-duplicate/
Just add this to your Dockerfile
RUN apk add alpine-sdk
gcc should not be necessary, unless you are cross compiling for a non-windows platform, or use cgo.
If you still need gcc, however, you should install MinGW, which provides a gcc port for Windows (Cygwin and msys should also work, although I have never actually tested this).
Edit: I see from your error message now, that it is a dependency that requires gcc. If you didn't already know this, gcc is a c/c++ compiler, and in this case it is probably needed to compile c source files included by a dependency or sub-dependency.
Instruction to fix the "exec: “gcc”: executable file not found in %PATH%" error with MSYS2:
Download MSYS2.
Put MSYS2 folder into your $PATH.
Start the MSYS2 command line program.
Run this command: pacman -S gcc.
Kindly install the MINGW after GUI will automatically take.
http://mingw.org/wiki/Getting_Started
On Windows, you can install gcc by Scoop:
scoop install gcc
you need to download MingGW64
put MingGW64 folder into your $PATH
run go build xxx.go (with cgo library)
Hi jaswanth the main problem is that you haven't register your %GO_HOME%\pkg\tool\windows_amd64 to yuour Environment Path.
%GO_HOME% is the repository where you install your go at the first time.
same as other, just install tdm-gcc, but you can use its terminal, "MinGW", you can access it from start menu folder tdm-gcc, after start, browse to your project, and run it again
I'm a Windows user and I downloaded tdm-gcc (MinGW-w64 based) from the link below:
https://jmeubank.github.io/tdm-gcc/
After installation, it made a folder named "TDM-GCC-64".
I added "C:\TDM-GCC-64\bin" to my PATH, And it fixed my problem.

Resources