About Ruby Version Manager Installation - ruby-on-rails

I was trying to install RVM:Ruby Version Manager from:
http://rvm.beginrescueend.com/rvm/install/
I opened up my terminal in my mac os version 10.5.8 and use the command line
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
then I got the message,
"You must now finish the install manually:
1) Place the folowing line at the end of your shell's loading files(.bashrc or .bash_profile for bash and .zshrc for zsh), after all path/variable settings:
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
Please note that this must only occur once - so, you only need to add it the first time you install rvm.
2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly).
This means that if you see '[ -z ] && return' then you must change this line to:
if [[ ! -z ]] ; then
... original content that was below the && return line ...
fi # <= be sure to close the if.
#EOF .bashrc
Be absolutely sure to REMOVE the '&& return'.
If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile.
placing all non-interactive items in the .bashrc, including the 'source' line above
3) Then CLOSE THIS SHELL and open a new one in order to use rvm.
Installation of RVM to /Users/Home/.rvm/ is complete.
kapplej-4:~ Home$ #!/usr/bin/env bash
kapplej-4:~ Home$
kapplej-4:~ Home$ # Install git
kapplej-4:~ Home$ mkdir -p $HOME/.rvm/src && cd $HOME/.rvm/src && version=1.6.5.3
kapplej-4:src Home$ curl -O http://kernel.org/pub/software/scm/git/git-$version.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2645k 100 2645k 0 0 953k 0 0:00:02 0:00:02 --:--:-- 1060k
kapplej-4:src Home$ cd git-$version && ./configure --prefix=/usr/local && make && sudo make install
-bash: cd: git-1.6.5.3: No such file or directory"
I have no idea how to complete installation manually, I am a complete newbie so can someone please give me a step by step instruction on how to do this. For eg, where do I go to add those lines to the shell's loading files?
Thanks,

Not sure why you're installing git through rvm, but my guess is that you didn't extract the tar.gz file before trying to access the directory. Before cd'ing into the git directory you'll need to do
tar -zxf git-$version.tar.gz
To complete the install you need to add the line:
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
to the end of your .bashrc file (assuming you're using bash which you can determine with echo $SHELL.)
You also need to verify that your bash script doesn't return (the -z return bit in the RVM message. If it does return do what RVM says during the install.)
Once the line is added exit your shell and open a new one. You should then be able to do rvm info to see rvm info and rvm to get more information on RVM.

If Git is already installed, the up-to-date command to install RVM is curl -L get.rvm.io | bash -s stable.

Related

Adaptive Ruby version when opening a terminal

This question is the opposite of this one (also asked here, here and here)
I have two versions of ruby installed
ubuntu:~/environment $ rvm list
ruby-2.6.6 [ x86_64 ]
=* ruby-3.0.2 [ x86_64 ]
and every time I open a terminal window, ruby-3.0.2 (the default) is set. The problem is for a couple of my older projects I have to use ruby-2.6.6, so every time I have to switch with
rvm use 2.6.6
Is there a way to automatically select ruby 2.6.6 when I open the terminal window of the specific projects? I have tried to override the default rvm version with the .ruby-version file (as suggested here) but it does not do the trick.
EDIT File /home/ubuntu/.rvm/scripts/cd contains the following
#!/usr/bin/env bash
# Source a .rvmrc file in a directory after changing to it, if it exists. To
# disable this feature, set rvm_project_rvmrc=0 in /etc/rvmrc or $HOME/.rvmrc
case "${rvm_project_rvmrc:-1}" in
1|cd)
# cloned from git#github.com:mpapis/bash_zsh_support.git
source "$rvm_scripts_path/extras/bash_zsh_support/chpwd/function.sh"
# not using default loading to support older Zsh
[[ -n "${ZSH_VERSION:-}" ]] &&
__rvm_version_compare "$ZSH_VERSION" -gt 4.3.4 ||
{
function cd() { __zsh_like_cd cd "$#" ; }
function popd() { __zsh_like_cd popd "$#" ; }
function pushd() { __zsh_like_cd pushd "$#" ; }
}
__rvm_after_cd()
{
\typeset rvm_hook
rvm_hook="after_cd"
if [[ -n "${rvm_scripts_path:-}" || -n "${rvm_path:-}" ]]
then source "${rvm_scripts_path:-$rvm_path/scripts}/hook"
fi
}
__rvm_cd_functions_set()
{
__rvm_do_with_env_before
if [[ -n "${rvm_current_rvmrc:-""}" && "$OLDPWD" == "$PWD" ]]
then rvm_current_rvmrc=""
fi
__rvm_project_rvmrc >&2 || true
__rvm_after_cd || true
__rvm_do_with_env_after
return 0
}
[[ " ${chpwd_functions[*]} " == *" __rvm_cd_functions_set "* ]] ||
chpwd_functions=( "${chpwd_functions[#]}" __rvm_cd_functions_set )
# This functionality is opt-in by setting rvm_cd_complete_flag=1 in ~/.rvmrc
# Generic bash cd completion seems to work great for most, so this is only
# for those that have some issues with that.
if (( ${rvm_cd_complete_flag:-0} == 1 ))
then
# If $CDPATH is set, bash should tab-complete based on directories in those paths,
# but with the cd function above, the built-in tab-complete ignores $CDPATH. This
# function returns that functionality.
_rvm_cd_complete ()
{
\typeset directory current matches item index sep
sep="${IFS}"
export IFS
IFS=$'\n'
COMPREPLY=()
current="${COMP_WORDS[COMP_CWORD]}"
if [[ -n "$CDPATH" && ${current:0:1} != "/" ]] ; then
index=0
# The change to IFS above means that the \command \tr below should replace ':'
# with a newline rather than a space. A space would be ignored, breaking
# TAB completion based on CDPATH again
for directory in $(printf "%b" "$CDPATH" | \command \tr -s ':' '\n') ; do
for item in $( compgen -d "$directory/$current" ) ; do
COMPREPLY[index++]=${item#$directory/}
done
done
else
COMPREPLY=( $(compgen -d ${current}) )
fi
IFS="${sep}";
}
complete -o bashdefault -o default -o filenames -o dirnames -o nospace -F _rvm_cd_complete cd
fi
;;
2|prompt)
if
[[ -n "${ZSH_VERSION:-}" ]]
then
precmd_functions+=(__rvm_do_with_env_before __rvm_project_rvmrc __rvm_do_with_env_after)
else
PROMPT_COMMAND="${PROMPT_COMMAND%% }"
PROMPT_COMMAND="${PROMPT_COMMAND%%;}"
PROMPT_COMMAND="${PROMPT_COMMAND:-}${PROMPT_COMMAND:+; }__rvm_do_with_env_before; __rvm_project_rvmrc; __rvm_do_with_env_after"
fi
;;
esac
You are probably using RVM as a shell script, and not as a shell function.
You can check like this in a typical shell (bash, zsh, ...) : execute: type rvm
If it displays rvm is /home/ying/.rvm/bin/rvm : you are using as a script (found in $PATH)
If it displays rvm is a function : you are using as a function (much better).
Check out: https://rvm.io/rvm/basics#post-install-configuration
If you are using as a script, and want to use as a function: you need to "source" the rvm function, it is located in <rvm main folder>/scripts/rvm, for instance if installed in $HOME:
source $HOME/.rvm/scripts/rvm
source /usr/local/rvm/scripts/rvm
Typically, at RVM installation time, it add the following line in the equivalent of .profile (depending on shell and if its global or user):
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
RVM changes automatically the version as described here:
https://rvm.io/workflow/projects
For detection of .ruby-version, the following is required:
RVM must be a recent version that supports the feature
RVM must be loaded in the shell (typically by .profile, or equivalent) so that is is executed as a function
the shell must be compatible with this callback feature (bash and zsh are)
Here is what happens:
When you load rvm as a function, it registers callback in the shell
when you cd into the project, RVM callbacks (in shell) detect the file .ruby-version (or others) and automatically do the equivalent of rvm use.
For instance, I use zsh (on osx) which has preexec and precmd callbacks
and it detect the ruby version file and applies when I cd into it or a sub folder.
It works with bash too.
If you are curious or want to see why it does not work for you look at the file <rvm main dir>/scripts/cd
typically the shell variable chpwd_functions is set to __rvm_cd_functions_set
which is the function called after a cd by rvm

How to get asdf and rvm to co-exist

Is it possible to have asdf and rvm coexist? If so, how do you set it up? I made a test project to try out asdf but it seems that's affecting another existing project that's managed by rvm. When I run rails I'm getting:
asdf: No version set for command ruby
you might want to add one of the following in your .tool-versions file:
ruby 2.6.1
I've came across the same issue while installing asdf in macOS. I was able resolve it by creating .tool-versions file and adding the ruby version entry. You can do the same by running following command in the terminal.
$ echo 'ruby 2.6.1' >> .tool-versions
more information can be found here in this blog post
This is the hack I currently use. Running use-rvm or use-asdf uncomments the respective line in my ~/.bash_profile, and comments the unwanted line.
# RVM
# source $HOME/.rvm/scripts/rvm
# ASDF
. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash
# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
use-rvm () {
sed -i "" 's|^# source $HOME/.rvm/scripts/rvm|source $HOME/.rvm/scripts/rvm|' ~/.bash_profile
sed -i "" 's|^. $HOME/.asdf/asdf.sh|# . $HOME/.asdf/asdf.sh|' ~/.bash_profile
bash --login
}
use-asdf () {
sed -i "" 's|^source $HOME/.rvm/scripts/rvm|# source $HOME/.rvm/scripts/rvm|' ~/.bash_profile
sed -i "" 's|^# . $HOME/.asdf/asdf.sh|. $HOME/.asdf/asdf.sh|' ~/.bash_profile
bash --login
}
And here's the gist

Can't compile CUDA samples: ld: library not found for -lgomp clang: error: linker command failed with exit code 1 [duplicate]

I'm trying to get openmp to run in my program on Mavericks, however when I try to compile using the flag -fopenmp I get the following error:
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The command I am running is:
gcc myProgram.cpp -fopenmp -o myProgram
Also, when I run gcc I get Clang warnings which I find to be very strange. And looking into /usr/bin/gcc it does not appear to link to Clang.
Any suggestions on how to fix my Clang errors and get openmp to compile?
The gcc command in the latest Xcode suite is no longer the GCC frontend to LLVM (based on the very old GCC 4.2.1) but rather a symlink to clang. Clang does not (yet) support OpenMP. You have to install separately another version of GCC, e.g. by following this tutorial or by using any of the available software package management systems like MacPorts and Homebrew.
I just recently attacked this problem and have scripted the process of getting everything working based on the official instructions.
The script will download everything into ~/code for easy maintenance and will append the correct environment variables to your ~/.profile file. For advanced users, pick a nice location you want the lib, bin and include installed and move them manually. The script depends on knowing the latest OpenMP runtime from Intel, which can be altered at the top of the script.
The script should work out of the box with vanilla Mavericks, except for one small problem. In the OpenML runtime make script, it does not reliably accept clang when specified and continues with the default GCC. As such, if you don't have GCC installed (which is not normal on out of the box Mavericks), it will fail to build. To fix this, you must comment out two lines (as noted in the script) based on the libomp_20131209_oss.tgz build of OpenMP. Newer builds of OpenML might break this script, so use at your own peril on newer versions.
Simply save this script into a file, run 'chmod +x filename.sh', and run './filename.sh' from terminal. It will take a while to build LLVM and Clang, so be patient.
EDIT: This script will most likely fail on Yosemite and I am having issues using the built clang2 after the update to the dev builds of OSX 10.10.
INTEL_OPENMP_LATEST_BUILD_LINK=https://www.openmprtl.org/sites/default/files/libomp_20131209_oss.tgz
DEST_FOLDER = ~/code
CLANG_INCLUDE=${DEST_FOLDER}/llvm/include
CLANG_BIN=${DEST_FOLDER}/llvm/build/Debug+Asserts/bin
CLANG_LIB=${DEST_FOLDER}/llvm/build/Debug+Asserts/lib
OPENMP_INCLUDE=${DEST_FOLDER}/libomp_oss/exports/common/include
OPENMP_LIB=${DEST_FOLDER}/libomp_oss/exports/mac_32e/lib.thin
mkdir ${DEST_FOLDER}
cd ${DEST_FOLDER}
git clone https://github.com/clang-omp/llvm
git clone https://github.com/clang-omp/compiler-rt llvm/projects/compiler-rt
git clone -b clang-omp https://github.com/clang-omp/clang llvm/tools/clang
cd llvm
mkdir build
cd build
../configure
make
cd Debug+Asserts/bin
mv clang clang2
rm -rf clang++
ln -s clang2 clang2++
echo "LLVM+Clang+OpenMP Include Path : " ${CLANG_INCLUDE}
echo "LLVM+Clang+OpenMP Bin Path : " ${CLANG_BIN}
echo "LLVM+Clang+OpenMP Lib Path : " ${CLANG_LIB}
cd ${DEST_FOLDER}
curl ${INTEL_OPENMP_LATEST_BUILD_LINK} -o libomp_oss_temp.tgz
gunzip -c libomp_oss_temp.tgz | tar xopf -
rm -rf libomp_oss_temp.tgz
cd libomp_oss
echo "You need to do one or two things:"
echo "1.) [Required] Comment out line 433 from libomp_oss/src/makefile.mk"
echo "2.) [Optional] If you do not have GCC installed (not normal on vanilla Mavericks), you must comment out lines 450-451 in libomp_oss/tools/check-tools.pl. Have you done this or want to compile anyway?"
select yn in "Yes" "No"; do
case $yn in
Yes ) make compiler=clang; break;;
No ) exit;;
esac
done
echo "OpenMP Runtime Include Path : " ${OPENMP_INCLUDE}
echo "OpenMP Runtime Lib Path : " ${OPENMP_LIB}
(echo 'export PATH='${CLANG_BIN}':$PATH';
echo 'export C_INCLUDE_PATH='${CLANG_INCLUDE}':'${OPENMP_INCLUDE}':$C_INCLUDE_PATH';
echo 'export CPLUS_INCLUDE_PATH='${CLANG_INCLUDE}':'${OPENMP_INCLUDE}':$CPLUS_INCLUDE_PATH';
echo 'export LIBRARY_PATH='${CLANG_LIB}':'${OPENMP_LIB}':$LIBRARY_PATH';
echo 'export DYLD_LIBRARY_PATH='${CLANG_LIB}':'${OPENMP_LIB}':$DYLD_LIBRARY_PATH}') >> ~/.profile
source ~/.profile
echo "LLVM+Clang+OpenMP is now accessible through [ clang2 ] via terminal and does not conflict with Apple's clang"
If you are running homebrew you can fix this problem by calling:
brew install clang-omp
The compiler will be available under clang-omp++ name
Just worked through this problem. Here's the answer plus how to get it worked with Xcode.
Grab the latest version of openMP runtime library from
https://www.openmprtl.org/download
unzip and compile it by
mkdir build && cd build && cmake .. && make && sudo make install
install it by
sudo cp ./libiomp5.dylib /usr/lib/
sudo cp ./omp.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/
Grab openmp/clang from Git following the instructions on http://clang-omp.github.io/
compile openmp/clang
cd llvm && mkdir build && cd build && ../configure --enable-optimized && make -j
sudo make install
normally it would install clang/clang++ into /usr/local/bin, we need replace the Apple clang with our version
cd /usr/bin
sudo mv clang clang-apple
sudo mv clang++ clang++-apple
sudo ln -s /usr/local/bin/clang ./clang
sudo ln -s /usr/local/bin/clang++ ./clang++
cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
sudo mv clang clang-apple
sudo mv clang++ clang++-apple
sudo ln -s /usr/local/bin/clang ./clang
sudo ln -s /usr/local/bin/clang++ ./clang++
cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
sudo mv -f * ../../
Create a project in Xcode, using the Hello World code on clang-openmp website for test. After created, add "-fopenmp" to Custom Compiler Flags -> Other C Flags in project settings; add /usr/lib/libiomp5.dylib to the build phases of project (project settings -> Build Phases -> Drag /usr/lib/libiomp5.dylib into Link Binary with Libraries)
It should work. Yosemite + Xcode 6 is tested.
Note: the custom clang is NOT as stable as Apple's. Switch back if you meet strange instruction error after compiled.

Cryptic error when trying to run POW

I am having a rather weird error message when running POW for my rails app.
I followed the instructions:
- cd ~/.pow
- ln -s /Users/mingyeow/Dailymuses-Server-Side
And got this:
Error starting application
Your Rack app raised an exception when Pow tried to run it.
Error: '/Users/mingyeow/Dailymuses-Server-Side/.powrc' failed to load:
true &&
source '/Users/mingyeow/Dailymuses-Server-Side/.powrc' > /dev/null &&
env > '/var/folders/cl/fd2wt82149x9trkxmsvqrt500000gn/T/pow.18625.1358760244196.27206'
Error: '/Users/mingyeow/Dailymuses-Server-Side/.powrc' failed to load:
true &&
source '/Users/mingyeow/Dailymuses-Server-Side/.powrc' > /dev/null &&
env > '/var/folders/cl/fd2wt82149x9trkxmsvqrt500000gn/T/pow.18625.1358760244196.27206'
at ChildProcess.exithandler (child_process.js:282:15)
at ChildProcess.emit (events.js:70:17)
at maybeExit (child_process.js:362:16)
at Process.onexit (child_process.js:398:5)
Tried resetting everything I could find.
I've had the exact same error today with an Octopress install.
Does your .powrc look like the following?
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ] ; then
source "$rvm_path/scripts/rvm"
source ".rvmrc"
fi
That's the one provided with Octopress, but I guess it's pretty generic.
In my case, I had modified the .rvmrc file and it contained a syntax error. I corrected the error, deleted the symlink in ~/.pow and created it again, and all went back to normal.
Hope that helps!
(if not, maybe you should update your question with the content of your .powrc file)

etc/bash.bashrc: line 2: GREP_OPTIONS: command not found

When I run a command on my Ubuntu 12 server I get the following warning...
etc/bash.bashrc: line 2: GREP_OPTIONS: command not found
I've probably messed something up by uninstalling various Rails pieces. How can I fix this? This is for the root user. Thanks.
The beginning of my bashrc file has the following...
type rvm >/dev/null 2>/dev/null || echo ${PATH} | GREP_OPTIONS \grep
"" > /dev/null || export PATH="${PATH}:"
It appears that you have uninstalled rvm from your system, as it cannot find $rvm_path_bin. I would recommend commenting out the line from /etc/bash.bashrc.

Resources