set the path of a particular executable in csh - path

Currently, I have make a non-root installation of an updated version of autoconf on the user home directory of the UNIX workstation. The workstation has an older version of autoconf which is to be executed as default.
How could I change the path in .cshrc so that the autoconf I execute would be pointed to the updated version that I installed instead of the older version?

Assuming your non-root install is $HOME/my/autoconf/bin then something like this will work:
set path = ( $HOME/my/autoconf/bin $PATH )

Related

sudo luarocks command not found on centos7

I installed luarocks on centos7, then I execute 'luarocks install luacheck', there is an error:
'Error: Your user does not have write permissions in /usr/local/lib/luarocks/rocks
-- you may want to run as a privileged user or use your local tree with --local.'
So, I execute 'sudo luarocks install luacheck', but there is also an error:
'sudo luarocks command not found'.
I confirm that luarocks has installed correctly, bucause when I execte 'luarocks --version' shows:
/usr/bin/luarocks 2.4.2
As luarocks isn't installed using the native package manager its installed to /usr/local/bin. This isn't in the PATH variable available in the sudo context - you can see (and edit) the configured paths in the secure_path property in the sudoers file.
Workaround that I use it to add a symbolic link to a path included in the secure_path property: sudo ln -s /usr/local/bin/luarocks /usr/bin/luarocks
You can either use
sudo /usr/bin/luarocks install luacheck
to install luacheck system-wide
or
luarocks --local install luacheck
to install to your user only. To use the second option, you also need to run
eval $(luarocks path --bin)
to make sure that the Lua paths are updated in your shell. To make these Lua paths permanent, you can add the above line to your shell config file (~/.bash_profile or similar).

asdf-erlang doesn't install man pages

I am using asdf + asdf-erlang as my version manager for Erlang. All seems to be working fine, except that typing erl -man mnesia results in No manual entry for mnesia.
I have installed all dependencies mentioned on the asdf-erlang github page. I have also installed xsltproc and fop. Unfortunately "man" folder located under ~/.asdf/installs/erlang/18.3/lib/erlang/erts-73/ is empty. I haven't found man pages being generated elsewhere.
I was trying to locate build log, but I was not successful with that either.
I am using 64bit Ubuntu 16.10 & 16.04.
OK. I finally managed to resolve the issue:
Go to https://www.erlang.org/downloads/ and download manpages for the version(s) of Erlang you have installed using asdf (so for 18.3 you're looking for: http://erlang.org/download/otp_doc_man_18.3.tar.gz)
Copy man folder with its content (extracted from the archive) to ~/.asdf/installs/erlang/<version>/lib/erlang/. After doing so, you should have .~/asdf/installs/erlang/<version>/lib/erlang/man containing man1, man3, man4, man6, man7 (and each of those folders should have some manpages in it).
Repeating steps above for all the versions installed using asdf, allows you to use manpages for specific version of Erlang you are using at the moment.
looks like erlang-manpages are not included in the asdf-erlang since you are using ubuntu i would suggest you add Erlang Solutions repository to your system, call the following commands:
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
then install erlang-manpages:
sudo apt-get install erlang-manpages
you could also install erlang-doc — HTML/PDF documentation
sudo apt-get install erlang-doc
check this page for more information
The man path in #MaciekTalaska 's answer seems not correct, it does not work at all, for erlang 18.3.
After reading ASDF's activate script(), here's one statement:
_KERL_MANPATH_REMOVABLE="$HOME/.asdf/installs/erlang/18.3/lib/erlang/man:$HOME/.asdf/installs/erlang/18.3/man"
Therefore, you just need to:
Go to https://www.erlang.org/downloads/ and download manpages for the version(s) of Erlang you have installed using asdf (so for 18.3 you're looking for: http://erlang.org/download/otp_doc_man_18.3.tar.gz)
Copy man folder with its content (extracted from the archive) to $HOME/.asdf/installs/erlang/${version}, but not $HOME/.asdf/installs/erlang/${version}/lib/erlang/ (in fact, there isn't a folder named erlang under lib).

verify that an OS package is installed

I need to verify that an OS package is installed after deploying using capistrano (it's a rails project, in case it matters). I'd like to support the major linux distros and OS X. Fortunately, the name of the package is the same on all platforms.
I've thought adding a capistrano task, something like (untested code):
%w(yum apt-get brew).each do |manager|
path = `which #{manager}`.chomp
if path && path.size > 0
`#{path} install -y #{PKG}`
return
end
end
Inspired by this question.
Is there a better way?
I've thought checking uname, but it doesn't always have the distro, just "Linux". I also thought using lsb_release or listing files in /etc/*-release, but not all distros support it (e.g. centos).

Modularizing and distributing bash script via Homebrew

Context
I have some functions defined in my ~/.bashrc which I'd like to turn into a Homebrew package. Currently, these functions act as custom commands on my command line:
# .bashrc
function foo() {
# do something interesting
}
# at terminal
$ foo
# => does the interesting thing
Approach
I've created a homebrew formula using brew create. My current approach is as follows:
Move the function definitions into a separate file, script, within a directory, brew-script
Make brew-script downloadable as a tarball, brew-script.tar.gz
Have my brew formula append text to the end of ~/.bash_profile to include script when terminal session starts
Concerns
Is modifying .bash_profile in a brew formula bad practice? (eg. when uninstalling with brew uninstall script, brew should somehow remove the text that was appended to .bash_profile... Parsing .bash_profile doesn't seem very fun.)
Is there a convention already established for including functions in bash scripts so that they are available from the command line?
Is it common to simply ask the user to add some text to their .bash_profile or .bashrc?
Desired result
Should be able to install cleanly with brew and then run foo as a command:
$ brew install script
$ foo
# => does the interesting thing
(Assume the brew formula is already installed locally. I'll worry about auditing and pushing the formula to homebrew later)
Refer https://github.com/Homebrew/homebrew/issues/50232 and https://github.com/Homebrew/homebrew/issues/50231.
I have a script that safely‡ modifies ~/.bash_profile as part of a homebrew install process. https://github.com/paul-hammant/homebrew-tap/blob/master/switchjdk.rb
‡ allegedly
Without using homebrew:
to put your bash scripts in some file such as bashrc or any other name works, then put the following line:
source "path/to/brew-script/script"
somewhere in your bash profile.
Then you just have to make sure you refresh or reload your bash profile by running . ~/.bash_profile or source ~/.bash_profile.
How homebrew installs work:
When you installed homebrew it added a line to your bash_profile that modifies your $PATH variable to include the path to the homebrew install repo, so that whenever brew installs something it becomes findable through your PATH.
If you use brew create you must have your script uploaded somewhere on the internet, because the argument brew install takes is a URL. I.e if I create my script at my_bash_function.tar.gz then I would do
brew create http://web.mit.edu/dianah13/www/my_bash_function.tar.gz
It also templates a pull request to include your package in homebrew's main repo.

How do I make grails choose the right JDK?

I'm using Mac OSX 10.8.5 with Oracle's Java 1.7 installed in addition to the mac's 1.6.
I have my JAVA_HOME set and the JAVA_HOME/bin in the front of my path.
When I run a grails compile from the command line I can see it's choosing the Java 1.6 instead of 1.7. How do I make the grails command-line choose the JDK I want?
➤ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home
➤ echo $PATH
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin /usr/local/share/npm/bin /Users/kbrodhagen/bin /Users/kbrodhagen/.rvm/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /opt/X11/bin /usr/local/git/bin
➤ set -x JAVA_OPTS "-showversion"
➤ grails compile
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)
Which shell are you using and exactly how did you set JAVA_HOME? Grails should respect your JAVA_HOME setting as long as it is visible to the grails command, for example in bash you must export the variable rather than just setting it, in tcsh you would use setenv rather than set.
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home
You can also remove /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin from your PATH as /usr/bin/java will automatically delegate to the appropriate java command for the current JAVA_HOME.
If you want to localise the Java version only to Grails the best way is to edit below file,
.gvm/bin/gvm-init.sh
You can set the JAVA_HOME in this file as below,
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
I have Java 8 in my machine and here I am setting java 1.7 for grails ONLY.
For the new SDKman method you can export JAVA_HOME in [YOUR HOME]/.sdkman/candidates/grails/[concrete version or current]/bin/grails
I needed to be able to switch between a Java 7/Grails 2.4.4 project and a Java 8/Spring 4 project in Ubuntu 12.04 and certain things made this difficult:
I'd set Java 8 as the default version after installing it using sudo apt-get install oracle-java8-set-default, but that apparently creates /etc/profile.d/jdk.sh and /etc/profile.d/jdk.csh containing JAVA_HOME, JRE_HOME and other env vars that prevented me from swapping the JDK.
This kinda worked, but the above env vars clouded things too much.
In the end, I removed both of the above items from my environment and the files in /etc/profile.d and I now:
Change the JDK by running sudo update-java-alternatives -s java-8-oracle (or java-7-oracle) as mentioned in the webupd8 article;
Run gvm to set the current or default grails and other tools as required
Seems messier than it should be, but I think it is working now.
If you use SDKMAN to install Grails (which is the currently recommended method), you can add any versions of Java you have installed to SDKMAN and it will manage them for you as well. For example:
sdk install java openjdk-8 /usr/lib/jvm/java-8-openjdk-amd64
sdk use java openjdk-8
Note that this will set JAVA_HOME for your user, so if you don't want that you may want to consider one of the other options.
$ echo $JAVA_HOME
/home/user/.sdkman/candidates/java/current
For more information: SDKMAN local versions

Resources