Vagrant adding file to PATH in provisioning not working - bash

I'm trying to provision a Vagrant machine to run liquibase. I'm able to install java, get liquibase through wget but I'm having trouble adding the liquibase executable to PATH. My current provisioning script looks like the following:
apt-get update
apt-get install -y unzip
apt-get install -y openjdk-8-jre-headless
mkdir liquibase
cd liquibase
wget https://github.com/liquibase/liquibase/releases/download/v3.8.5/liquibase-3.8.5.tar.gz
tar -zxvf liquibase-3.8.5.tar.gz
rm liquibase-3.8.5.tar.gz
export PATH=$PATH:/home/vagrant/liquibase
source ~/.profile
source ~/.bashrc
If I run export PATH=$PATH:/home/vagrant/liquibase inside the machine it works. But during provision it doesn't work. I ssh into the machine and it's not in the PATH. I added the last two lines to see if I could make it persistent by adding it to .profile and .bashrc but it's still not working.
Any idea on how to solve this issue?

New PATH is not avaliable in your interacive shells.
Include your new PATH into the .bashrc file to have it avaliable when you login the machine.
echo 'export PATH="${PATH}:/home/vagrant/liquibase"' >> /home/vagrant/.bashrc
source /home/vagrant/.bashrc

Related

Raspberry Pi 3 Miniconda install aarch64 error

I am entering
sudo bin/bash Miniconda3-latest-Linux-aarch64.sh
I enter the correct directory, but when it comes to "Unpacking the payload ..."
it gives me an error
"Miniconda3-latest-Linux-aarch64.sh: line 417: 2300 Illegal instruction "$CONDA_EXEC" constructor --prefix "$PREFIX" --extract-conda-pkgs"
Follow these steps to install a smooth Conda Package Manager on your Raspberry Pi 3 or 4.
Forget about the Miniconda---------aarch64.sh route because it is really challenging to fix it and make it work after installation. Mambaforge is the key and has worked very smoothly for me.
Make sure your Raspbian OS is 64 bit.
Get the latest version of aarch64.sh from https://github.com/conda-forge/miniforge/releases. When I did the install the latest was Mambaforge-22.9.0-2-Linux-aarch64.sh
Install it and make sure the path is added to your .bashrc file.
Reboot your Raspberrypi or spin up your .bashrc file to activate conda.
Test your conda installation.
Now, let's do it.
Go to your downloads directory and download what you need.
cd /home/username/Downloads
sudo wget https://github.com/conda-forge/miniforge/releases/download/22.9.0-2/Mambaforge-22.9.0-2-Linux-aarch64.sh
Start the installation
sudo /bin/bash Mambaforge-22.9.0-2-Linux-aarch64.sh
Now during the installation put the installation path as given below. You can name it something else, but to save your time you can just follow me.
/home/username/miniconda3
Open your .bashrc file sitting at the location /home/username/.bashrc and the the following line in the end of it. And you can skip this step if your installation process already edited your .bashrc file with something similar.
export PATH="/home/username/miniconda3/bin:$PATH"
Considering that your .bashrc is edited, so it need to be reloaded.
source ~/.bashrc
Now, let's test your conda installation
conda init
conda env list
Happy? Are we? Now? Cheers!!!

Haxe installation from binaries

Someone can help me to install Haxe 4.0.0-rc.5 from the binaries on Ubuntu 19.4. The repository pointed out by the page does not have the new versions and on the official page there are no instructions on how to do it.
Thanks!
Here's a script I use on CI servers running Ubuntu. It installs Haxe and Neko in /opt/, but you could put them anywhere (replace /opt/ with whatever location you want, like /usr/local/ or $HOME/tools/):
# Install neko and Haxe
cd /opt/
curl -sL http://nekovm.org/media/neko-2.1.0-linux64.tar.gz | tar -xz
curl -sL https://github.com/HaxeFoundation/haxe/releases/download/4.0.0-rc.5/haxe-4.0.0-rc.5-linux64.tar.gz | tar -xz
mv haxe_* haxe-4.0.0-rc5
ln -s haxe-4.0.0-rc5 haxe # symlink makes it easy to switch versions
Then you'll want these environment variables defined in your ~/.bashrc or equivalent:
export NEKOPATH=/opt/neko-2.1.0-linux64/
export HAXE_STD_PATH=/opt/haxe/std
export PATH=/opt/haxe/:/opt/neko-2.1.0-linux64/:$PATH
export LD_LIBRARY_PATH=/opt/neko-2.1.0-linux64/:$LD_LIBRARY_PATH
And to finish the install (after the exports are setup), you need to run once:
haxelib setup ~/haxelib
I've also written up how I manage multiple versions of Haxe on Ubuntu on the Haxe forums: https://community.haxe.org/t/quick-write-up-of-how-i-manage-haxe-versions-under-linux/1694
To uninstall:
remove the exports from .bashrc
rm -rf /opt/haxe* /opt/neko* ~/haxelib

Golang installation

I just followed the installation guide for golang (ubuntu 16).
I extracted the archive at /etc/usr
I added env variable in /home/user/.profile
I just tested a basic go build on the hello world code.
I get the following error:
The program 'go' is currently not installed. You can install it by typing: sudo apt install golang-go
Why does it ask me to install it (again?)?
open the go documentation download
https://go.dev/dl/
choice your os and go version
download then extract the file
extract the file
open the file and open the terminal
6.Add /usr/local/go/bin to the PATH environment variable.
export PATH=$PATH:/usr/local/go/bin
then check the go version
go version
The location of the binary go is not in your path. Ubuntu does not find it and suggests to install it. Add this line to your file /etc/profile, or better $HOME/.profile:
export PATH=$PATH:/usr/local/go/bin
This is documented in the docs: https://golang.org/doc/install#install
If you want to try this solution before editing any files, you can just execute the above command and try to execute the go command in the shell.
There are paths which needs to be set correctly for you go installation to work
GOROOT points to directory where go is installed
export GOROOT=/usr/lib/go
GOPATH points to you workspace directory
export GOPATH=$HOME/go
These paths need to be added in global path variable.
export PATH=$PATH:$GOROOT/bin
You need to put the go executable in your system path. which you can do by
export PATH=$PATH:/etc/usr/go/bin
You can put the same in /home/user/.profile
just use asdf for installation. You can have several version also :D
Docs: https://asdf-vm.com/#/core-manage-asdf
downlaod the installer form enter link description here, choose intaller for linux that suit your device and then you go to your CLI and use wget or curl :
$ wget https://storage.googleapis.com/golang/go1...
and then extract the file to /usr/local :
$ tar -C /usr/local -xzf go1...
add path binary Go to PATH environment variable :
$ echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc
$ source ~/.bashrc
and then use go version to check if the Go already installed
If You are using linux then open your terminal and run this command.
sudo apt install golang-go
This command will Install Go lang. in your system. ThankYou
Steps for Go installation:
sudo apt-get update && sudo apt-get -y upgrade    
wget https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz
sudo tar -xvf go1.17.5.linux-amd64.tar.gz
sudo mv go /usr/local/
export GOROOT=/usr/local/go
Add in .bashrc
vi .bashrc
export GOPATH="/root/go"
export GOROOT=/usr/local/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Download latest version from https://golang.org/doc/install
tar -xzf go1.15.7.linux-amd64.tar.gz
move to /usr/lib/ to folder with version number
sudo mv go /usr/lib/go-1.15
create symkink link on /usr/bin/
ln -s /usr/lib/go-1.15/bin/go /usr/bin/go

Issue with activating virtualenv

I installed python environment by means of commands:
SYS_INSTALL="apt-get install -y"
PIP_INSTALL="pip install"
# Be sure to install setuptools before pip to properly replace easy_install.
$SYS_INSTALL git
$SYS_INSTALL python-dev
$SYS_INSTALL python-setuptools
$SYS_INSTALL python-pip
$PIP_INSTALL virtualenv
also was able to create new virtual environment:
virtualenv .env
However, after running a command like:
. .env/bin/activate
I got
-bash: .env/bin/activate: No such file or directory
After reviewing folder .env/bin I found only one python file. Whole list of files here:
.env/lib:
python2.7
.env/include:
python2.7
.env/bin:
python
What is the issue here?
SOLUTION add --always-copy
virtualenv .env --always-copy
For me it works when I do these steps:
Go to the directory/folder that you want
run virtualenv .env
then run source .env/bin/activate
The accepted answer is incomplete! The suggested code left out your error, but didn't comment on it.
The command . .env/bin/activate would indeed do the same as source on the file activate in the folder .env/bin. In fact, apparently the command "source" is an alias for the command ".", and not the other way around. Note that . here has a space after it, and used differently from the . discussed below (which makes files and folders hidden).
What I notice is that you are calling your folder .env, which is not standard practice. Files and folders preceded by . are made "hidden" by Mac OS X. Standard practice is to call a virtual environment directory env or venv, and to call the virtual environment specification file .env.
So, if your spec file is called .env and your virtual environment directory is called env, you can run either
source env/bin/activate
or
. env/bin/activate.
I had the same issue and the following steps resolved it:
$mkdir annotateNLP
$cd annotateNLP
$python -m venv env
$source env/Scripts/activate
Try these commands in the terminal:
$ mkdir djangoapp
$ cd djangoapp
$ python3 -m venv myvenv
$ source myvenv/bin/activate
You can't go straight into activate command without first creating your virtual environment.
you forgot to include source before activating command is
source env/bin/activate
this question is similar to your's
virtualenv is not compatible with this system or executable
where it creates virtualenv but,python file instead of activate in bin
After going to your virtual environment folder .\Scripts\activate.
In my case, I need to install
sudo apt-get install python3-venv
$ virtualenv env
$ cd env/Scripts/
$ . activate
I was facing this same issue. I uninstalled the virtualenv in Ubuntu and then I installed it again. After this nonsense, it works and now I am able to activate my virtualenv through -$source py3/bin/activate.
If installed venv on a Windows machine, run this command (assuming you are in the working directory that has your venv folder):
In bash terminal: source venv/Scripts/activate
In cmd terminal:
venv\Scripts\activate
where venv is the folder name for your virtual environment
For windows using git bash, run the below command:-
source env\Scripts\activate

Is there a command to update redis?

I'm working on the front end for a web app, but I'm trying to learn as much of the backend setup as I can as well. I am setting up redis on a new computer myself, but running into a few hiccups.
The wget command cannot be found, so I assume it Linux only? I am following these instructions to install redis on Mac OS 10.7. I have redis 2.0.0 installed, but while attempting to install 2.4.4 using the same commands, I am told redis-server, redis-cli, redis-benchmark cannot be found, and I can't copy them to /usr/local/bin.
I could not find an update command to bring redis up to the most recent version. I don't think it should be this difficult to install the most recent version on redis on Mac OS, but I can't see what I am doing wrong.
So far as I know, typing:
$ brew upgrade redis
should work, where $ indicates your command line. If it complains about HomeBrew not being installed, you can obtain that here. Brew is an excellent package manager, and a great way of taking care of your files.
If you're not using brew, then these steps will help you get up to date.
First, find the location of your installed redis-server instance before updating. In my case, it was in /usr/local/bin/, but it might also be in /usr/bin/. If it's not here, you can type which redis-server to find the location.
Next, download the redis tar file from https://redis.io/download, then install it from the directory it downloaded to:
cd Downloads
tar xzf redis-X.Y.Z.tar.gz
cd redis-X.Y.Z
make test
make
Next, we'll move the new installed redis to the location where the current instance is running:
sudo mv src/redis-server /usr/local/bin
sudo mv src/redis-cli /usr/local/bin
Now you should be ready to use redis-server and redis-cli in the new version.
PS - I also moved the redis-benchmark, redis-sentinel, redis-check-aof, and redis-check-dump files because they were also already in /usr/local/bin.
Ref: http://jasdeep.ca/2012/05/installing-redis-on-mac-os-x/
It would be better to follow this way.
$ brew update
$brew upgrade redis
Create a bash file...
cd ~
nano .update_redis
Go into the tmp directory and download the latest stable version
cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
Decompress the files
tar xvzf redis-stable.tar.gz
Compile
cd redis-stable
make
Copy the bin programs
cp src/redis-cli /usr/bin/
cp src/redis-server /usr/bin/
cp src/redis-benchmark /usr/bin/
Set Permissions
chmod 755 /usr/bin/redis-cli
chmod 755 /usr/bin/redis-server
chmod 755 /usr/bin/redis-benchmark
Execute
bash .update_redis

Resources