update .bashrc file to locate opencv libraries - bash

I am not a sudo user in a server and want to use my version of opencv.
There is .bashrc file for each user. I too have it. Please tell how to set path of local installation of opencv into .bashrc.
Each time I set path in .bashrc and do source ~/.bashrc. And check the version, its still the same.

Make sure you're adding the correct path and that you're appending it at the end of $PATH (i.e. export PATH=$PATH:/path/to/opencv).
Then do a source ~/.bashrc and verify what path is being used using which opencv.

Related

How to change CMAKE_INSTALL_PREFIX in a generated file at installation

For backward compatibility with older pre-cmake packages I need cmake to generate a pkg-config like script foo_config to install with my library. The library user can then execute this script with e.g.
foo-config --prefix
to find a package prefix. Other options are --cflags etc. Right now I can do this by creating a file foo-config.cmake.in which has a substitution
#!/bin/bash
prefix=#CMAKE_INSTALL_PREFIX#
#
# more scripting logic
and I can create my actual script using in CMakeLists.txt the lines
configure_file(bin/foo-config.cmake.in bin/foo-config)
install(FILE ${CMAKE_CURRENT_BINARY_DIR}/bin/foo-config
PERMISSIONS OWNER_EXECUTE OWNER_READ
DESTINATION bin)
This works fine for installing into /usr/local or if the user specifies -DCMAKE_INSTALL_PREFIX=... at configuration time.
However CMake also allows installation via:
cmake --install . --prefix=/foo/bar
where the /foo/bar path will override the CMAKE_INSTALL_PREFIX. At this time my script is already configured and the previous CMAKE_INSTALL_PREFIX will have already been substituted. Just installing will not replace my existing substitution for #CMAKE_INSTALL_PREFIX#. Is there a facility in CMake for doing some kind of path replacement in a file at install time that I can use so that the prefix will be set correctly in the installed file?

gfortran: error: libgfortran.spec: No such file or directory

I am attempting to install and run gfortran-8 on macOS with the following makefile. I installed it from http://hpc.sourceforge.net/ (8.3 version). I keep getting this error:
gfortran: error: libgfortran.spec: No such file or directory
I know libhfortran.spec is located in /usr/local/Cellar/gcc#8/8.4.0/lib/gcc/8/libgfortran.spec. I have added it to my etc/paths and my .bash_profile. I have also uninstalled gfortran and reinstalled it. Anyone have a clue on what I might be missing? I am attaching my makefile below.
Makefile:
https://drive.google.com/open?id=1Y_Zo2dSYI32dQpwMtdUy5rWB8avDHXor
Bellhop Macintosh Installation
Note: I know gfortran is now part of gcc but newest at version still only works with older gfotran compilers. If you have Catalina as well, don’t worry this will still work on Mojave as well as on Catalina. I had tested it.
Go to this link.
Download
Install the downloaded gfortran-8.2-Mojave.dmg, this compiler is being used by the at to create binaries for your MacOS.
Go to the path where you extracted at folder. (In Mac you don’t need windows binary, you need to compile using gfotran compiler.)
Execute the following commands in the at folder.
Once you installed. Close all the terminals.
Open new terminal. Do as follows:
In your terminal, type this:
echo $PATH
Above command give you current path in your zsh file, If you have one.
Add bellhop to your zsh file. You can use these commands in terminal:
cd
nano .zsh
Please note that there is no Bellhop in the path right now, so we are going to add that by adding the following line in the .zsh file, Copy and paste below list (change the path accordingly)
export PATH=your_local_macOS_path/at:your_local_macOS_path/at/Bellhop:$PATH$
For me, it was:
export PATH=/Users/jaypatel/Downloads/at:/Users/jaypatel/Downloads/at/Bellhop:$PATH$
Refer the screenshot below for more details.
Once you’re done, press ctrl+X and it will ask you do you want to save your file, type Y and press enter and it will save the path successfully.
And now source ~/.zsh to your terminal using this command :
source ~/.zsh
echo $PATH
This means your acoustic toolbox and bellhop.exe are in path’s now.
And now source ~/.zsh to your terminal using this command : source ~/.zsh
And Voila, Your Bellhop is successfully installed.
Reference :
You can find more details here.

mvn: command not found - terminal

I am using a Mac Pro machine and want to install maven. So here is what I am doing. First I download the appropriate .zip. I unzip it and in terminal I type
Theodosioss-MacBook-Pro:~ theo$ export M2_HOME=/Users/theo/apache-
maven-3.5.4
and
Theodosioss-MacBook-Pro:~ theo$ export
PATH=$PATH:/Users/theodosiostziomakas/apache-maven-3.5.4
Then I check if maven is installed but I get this.
mvn --version
-bash: mvn: command not found
How to properly fix this?
First you need to add maven path to your PATH variable correctly,as others have said
export PATH=/YOUR_LOCAL_LOCATION/apache-maven-3.5.4/bin:$PATH
then you need to call source /etc/profile(pay attention to check the user type,root or no root) to make it into effect and then open a new terminal for test
Try
export PATH=$PATH:/Users/theodosiostziomakas/apache-maven-3.5.4/bin
mvn executable is inside bin folder.
You have not indicated proper dir, try as below
export PATH=/YOUR_LOCAL_LOCATION/apache-maven-3.5.4/bin:$PATH
The following works for me.
Changes are done to .bash - .profile did not work on my mac
Update the config in ~/.profile
export M2_HOME=<PATH>/apache-maven-X.Y>Z
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

Error "command not found" after installing go-eval

I'm trying to run Go in an interactive mode.
I want to use go-eval for that, I followed their README instructions:
I ran go get github.com/sbinet/go-eval/ successfully
I ran go-eval which resulted in -bash: go-eval: command not found
Some more information:
echo $PATH returns: /usr/local/go/bin:...
echo $GOPATH returns: $HOME/golang
running whereis go-eval returns no output
running go install go-eval returns:
can't load package: package go-eval: cannot find package "go-eval" in any of:
/usr/local/go/src/go-eval (from $GOROOT)
$HOME/golang/src/go-eval (from $GOPATH)
You'll need to add GOPATH/bin to PATH.
PATH="$GOPATH/bin:$PATH"
Update [Go 1.8 and above]: GOPATH will default to $HOME/go. The above will not work if GOPATH is not explicitly set.
To set both, add this to your .profile file:
export GOPATH="$HOME/go"
PATH="$GOPATH/bin:$PATH"
Ran into this issue while using export PATH="~/go/bin:$PATH".
Seems the ~ was causing problems and changing to the full path worked.
Try something like this instead, which won't use a tilde:
export PATH="$HOME/go/bin:$PATH"
Is the binary go-eval in $GOPATH/bin? Are you running the command with $GOPATH/bin/ as your working directory? If not, thats likely the problem.
go get & go install installs go binaries (if any) in $GOPATH/bin
Check $GOPATH/bin for the go-eval binary. If its there, try running it from $GOPATH/bin with ./go-eval. If that works, you're good.
In future, if you wish to run go binaries found in $GOPATH/bin from anywhere in your shell, add the following to your .bashrc or profile:
export PATH=$PATH:$GOPATH/bin
Then restart your terminal or run . ~/.bashrc or . /etc/profile
When running go install go-eval I get:
can't load package: package go-eval: cannot find package "go-eval" in any of:
/usr/local/go/src/go-eval (from $GOROOT)
$HOME/golang/src/go-eval (from $GOPATH)
You get the above error because go-eval is not in $HOME/golang/src/go-eval. Running go get github.com/sbinet/go-eval/ will download the source to $GOPATH/src/github/sbinet/go-eval/. If you want to run go install go-eval, you have to specify the package name relevant to its position in the directory hierarchy in $GOPATH/src.
e.g.
go install github/sbinet/go-eval
I'd like to add this in addition to the answers given.
As a helpful tip, uou can always test your commands with the which command.
Such as: which go
If the command is not found, you know you have a PATH problem you need to address first.
Then you can focus on finding the command with the find command.
Such as: find / -name "go" -print 2>/dev/null
The first slash is the directory to start the search, the argument to the -name is the command you're looking for and the -print gets a good results look. the 2>/dev/null sends results of directories that are not accessible to neverland (null) so that you do not need to see a bunch of errors.
Using this process helps you quickly find the command in question and then you can add it to your PATH env variable and it becomes accessible as stated in the other answers.
All above answers are self explaining. Over and above those I would like to add that by default you can access only those commands from terminal without path to binary whose bin folder is added to the environment variable, be it linux, mac or windows.
Else you will have to specify the path to bin folder of that software followed by the binary name. For instance in your case <path_to_bin_folder>/go-eval.
This is the most common reason that you are not able to execute that command directly from the command line. Please remember this and try this before searching for answers online because this will most probably solve your issue. All you have to know is the installation path.
So, write the following into the rc or profile file for your terminal and save, example for zsh it is ~/.zshrc, for bash it is ~/.bash_profile or ~/.bash_rc.
export GOPATH="$HOME/go"
export PATH=$PATH:$GOPATH/bin
Now although the file is saved but the changes will not reflect immediately. You have to source the profile file as mentioned above. For this type source ~/.zshrc. You should now be able to run the command directly from command line now. Even if the problem still persists try quit the terminal session and logging off and then logging in.
In case you want to add path to bin folder for other packages, you can append it to the $PATH environment variable using :. So for example if you want to add path to java binary as well, then just do
export PATH=$PATH:$JAVA_HOME/bin
Also it is a good practice to define the path to root folder of a package in its separate environment variable(example $GOPATH="$HOME/go"). In case if the installation path changes in future then you'll just have to update the environment variable related to that binary (example just update, $GOPATH="newpath") and your command will work as previously, since the change in $GOPATH will reflect in $PATH.
add those line in to ~/.zshrc
export GOPATH="$HOME/go"
export PATH=$PATH:$GOPATH/bin
run source ~/.zshrc

How can I prepend a directory to PATH using RVM on a per project basis?

RVM supports .ruby-version and .ruby-gemset on a per project basis and ensures those are set correctly when you navigate to a directory containing those files.
Is there a similar construct I can use for adding directories to my environment PATH variable using RVM?
I haven't found a way to do this using RVM, but I came across another project called direnv that accomplishes exactly what I want.
Here are the steps I took to prepend ./bin to my environment PATH variable on OSX every time I go to my project directory in the shell:
brew install direnv
Add eval "$(direnv hook $0)" to the end of my .zshrc file.
Create a .envrc file in the root of my project with the following content:
PATH_add bin

Resources