Vagrant add to PATH - linux

I've just installed vagrant now I would like to make for example vagrant up global. In the docs I read this:
Sometimes you may want to vagrant up your Homestead machine from anywhere on your filesystem. You can do this on Mac / Linux systems by adding a Bash function to your Bash profile. On Windows, you may accomplish this by adding a "batch" file to your PATH. These scripts will allow you to run any Vagrant command from anywhere on your system and will automatically point that command to your Homestead installation:
Mac / Linux
function homestead() {
( cd ~/Homestead && vagrant $* )
}
But when I add the code above to my ~/.bash_profile:
And restart the terminal vagrant up is not working globally. I have no experience with the ~/.bash_profile file.
I would appreciate it if someone could put me in the right direction

This bash function allows you to type things like: homestead up and it will change directories to Homestead and pass the vagrant command in front of any other vagrant command. homestead up means cd homestead, and vagrant up. Typing vagrant up doesn't invoke the function and vagrant isn't in your path.
What you're looking for is simply adding vagrant to your path. You may do this by adding the executable path of vagrant.
export PATH=$PATH:/usr/local/vagrant:
So, you're bash profile would read:
export PATH=$PATH:/usr/local/bin/:~/composer/vendor/bin:
Note: I'm guessing your vagrant is installed in /usr/local/bin; it might be installed elsewhere, in which case put the proper path in lieu of /usr/local/bin.

Related

Where does '~' expand to when mounted in docker with windows subsystem for linux?

I have a docker container I wrote that sets up AWS profiles for me. In Linux it works great, on WSL it partially works.
When I run the container I am mounting the ~/.aws directory, checking if the profiles exist and if they don't exist I create them. If they do exist I don't do anything.
In Linux I can run this container and then continue to use aws-cli with no problems.
In Windows subsystem for Linux - when I run the container the first time around, it will create the profiles for me. If I choose to run the container again it sees that the profiles already exist so it does nothing. This tells me the file exists somewhere but I cant use aws-cli because the file doesn't exist at ~/.aws.
So my question is where is ~/.aws in WSL when mounted to a docker container? I've attempted to do a find on the entire filesystem in WSL and that returns nothing. I've also tried changing the mount path to /root/.aws and I run into the same conditions.
EDIT:
I still don't know the answer to my question above. But if anyone comes across this question I did find a work around.
I've updated Docker Desktop to allow mounting the entire c:/ drive. Then I just changed my docker run command to mount c:/.aws instead of ~/.aws, so my command looks like -v c:/.aws:/root/.aws. After that I added this environment variable in WSL export AWS_SHARED_CREDENTIALS_FILE="/mnt/c/.aws/credentials" and now aws cli picks up on my profile changes.
The shell always expands ~ to the value of the HOME environment variable. If that environment variable is not set, then it expands to nothing. If you want to find where ~/.aws is located, then you can write something like echo ~/.aws and the shell will expand it for you.
The only exception is that ~user expands to the home directory of the user user; the HOME environment variable is not consulted there.
You have to remember that in your setup the docker engine (docker for windows) is installed on windows, it is inside the windows environment that the docker command is 'launched'. So when you say use ~/.aws it looks in the windows file system for this location.
In windows ~ is a valid directory name (try mkdir ~ from a cmd prompt) so when you say map ~/.aws I'm unsure what actually gets created. maybe try searching your c drive for a folder called ~. There is no ~ shortcut in windows for the home folder, and if there was which home would it be? the home of the logged in windows user? or the home inside WSL?
To make this work in WSL you need to pass ~/.aws to wslpath like this:
➜ echo $(wslpath ~/.aws)
/mnt/c/home/damo/.aws
But this location is the path according to WSL not windows you need to do it twice with the -w flag the second time
➜ echo $(wslpath -w $(wslpath ~/.aws))
C:\home\damo\.aws
which would make your final docker command look like this:
docker run -it -v $(wslpath -w $(wslpath ~/.aws)):/root/.aws awsprofileprocessor:latest
With this you will now be telling docker for windows the windows path to put the mount
Please let me know if this works for you, I'm interested in how it turns out.

Vagrant up gives 'cygpath' Vagrant was not found in path

I've installed Vagrant, Vagrant init worked fine. When I now run Vagrant up I get this error:
The executable 'cygpath' Vagrant is trying to run was not
found in the %PATH% variable. This is an error. Please verify
this software is installed and on the path.
Im using cygwin as terminal and I have windows 8, and I've placed C:\cygwin64\bin in my PATH in envoirment variables.
My question is, why do I get this error message when I've specified the path to my cygwin bin?
Thanks!
I am assuming you have Cygwin installed, simply add the path to cygwin (usually c:\cygwin\bin\cygwin.exe) to your shells %path% variable and you should be ready to go.
Ctrl-X => System => Advanced Settings => Variables
Restart your Powershell/Cmd-Window
I just experienced the same error after removing cygwin, and figured out that the answer is not in reinstalling it, but simply removing it from the %Path%, so that Vagrant wouldn't search for it when booting.
So, you can open Control Panel => System => Advanced System Settings => Environment Variables...
And then find Path under System Variables, and remove any references to cygwin.
Restart your shell, and you're good to go.
My soultion was to create a small wrapper script, vagrant.bat:
#setlocal
#set PATH=C:\HashiCorp\Vagrant\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
#vagrant %*
#endlocal
The vagrant.bat file is in a directory that is first in my PATH.
I suddenly had the same problem and found that for some reason Cygwin had been erased from the system (I was running from git bash shell). I reinstalled Cygwin and it then worked again.

how to fix $PATH in Virtual Box Ubuntu 14.04 after npm global install

I've been trying to install npm globally in virtual box with ubuntu 14.04 and Apache 2.4 with various problems with Laravel 5.1
Reading through the docs on npm adn following through these instructions https://docs.npmjs.com/getting-started/fixing-npm-permissions I know I have completed wrecked my $PATH
Previously when I ran echo $PATH I got something like this;
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games
Now when I echo $PATH I get the following;
/usr/local/bin:/bin
I have managed to stuff everything up on my Laravel install, composer no longer works, php artisan no longer works - am just wondering if anyone is able to help me get back to where I was...
For the novices who may be struggling with this, I got the path, composer, artisan and Laravel functioning by first, replacing the .bashrc with a non corrupt one in terminal from the /etc/skel directory (in local indicated by $)
$cp /etc/skel/.bashrc ~/
Commit changes with
$source ~/.bashrc
Then used the following to export /usr/bin to my PATH - the error for anything attempted in terminal was "The command could not be located because '/usr/bin' is not included in the PATH"
$export PATH="/usr/bin:$PATH"
To permanently commit the changes
$sudo nano /etc/environment
Check the file contains the following
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
CTRL & X to save and Y

run jedit single command from terminal linux

I'm trying to run jedit from the terminal on fedora. its installed to the path /usr/local/share....
How do I get it to run "jedit" from the terminal rather than switching to the directory and typing java -jar jedit.jar to execute the program.
I created a sh file in that same direectory with "java -jar jedit.jar" and added that directory to ~/.bashrc. I'm aware that I need to type "sh file.sh" to run that file but I know there is a gap in my knowledge somewhere.
i want to use jedit as a commit editor for git and be able to change core.editor='jedit -w' in git config
someone please help
I assume you used the Java installer?
If this is the case, the installer should also have placed a jedit launch script in /usr/local/bin which should be in your PATH by default, so calling jedit from a terminal should instantly work after installation.
If it does not work, then please check whether the file jedit is available in /usr/local/bin and whether /usr/local/bin is in your PATH environment variable.

Shared Library issues when running over SSH (linux)

I am having some difficulty running jobs over SSH. I have a series of networked machines which all have access to the same Home folder (when my executable is installed). While working on one machine I would like to be able run my code through ssh using the following sort of command:
ssh -q ExecutableDir/MyExecutable InputDir/MyInput
If I ssh in to any of the machines I wish to run the job on remotely and simply run:
ExecutableDir/MyExecutable InputDir/MyInput
It runs without fail, however when I run through SSH I get an error saying some shared libraries can't be found. Has anyone come across this sort of thing before?
ok I figured it out myself.
It seems when you run things through ssh in the way shown above you don't inherit the path variables etc. that you would if you ssh-ed in 'properly'. You can see this by running:
ssh RemoteMachine printenv
and comparing the output to what you would normally get if you were connected to the remote machine. The solution I then went for was to run something like the following:
ssh -q ExecutableDir/MyExecutable source ~/.bash_profile && InputDir/MyInput
Which then gets all the paths and stuff you might need from the bash_profile file on the remote machine

Resources