ruby on rails -v gives error - ruby-on-rails

i am getting this error below
/usr/lib64/ruby/site_ruby/1.8/rubygems.rb:926:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:244:in `activate_dep'
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:236:in `activate'
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:1307:in `gem'
from /usr/bin/rails:18
i started with a ruby 1.8.7 & rails 2.3.11
then i installed rvm
then installed ruby 2.0.0 & gem install rails 3.2.13
then started getting this error above.
any help will be appreciated, thanks.
i think it's a path issue of some sort but can't figure out, don't know much about unix stuff. i don't have root privs by the way.
this is my .bashrc if helps
# .bashrc
# User specific aliases and functions
alias mv='mv -i'
alias rm='rm -i'
alias cp='cp -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export HPATH=$HOME
export GEM_HOME=$HPATH/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib64/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HPATH/ruby/gems/bin
export PATH=$PATH:$HPATH/ruby/gems
this is .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM$

rvm use 2.0.0
will switch to ruby 2.0.0
You can then install rails and create a gemset named rails-3.2.13
rvm use 2.0.0#rails-3.2.13 --create
then
gem install rails -v 3.2.13
you can also pass the --default switch to make 2.0.0 the default ruby
you can see a list if all installed ruby versions and which one is current and or default using
rvm list
this produces output like this
rvm rubies
ruby-1.9.3-p385 [ x86_64 ]
=* ruby-1.9.3-p392 [ x86_64 ]
ruby-2.0.0-p0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
UPDATE
Also, This seems like a PATH issue since your last comment. Im not sure about your bash_profile but the PATH may be wrong for rvm. Just use
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
in your bash_profile
and in your `.bashrc' try this
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

Related

bash_history does not work outside session El-Capitan after installing ruby

in mac osx el-capitan .bash_history has stopped working when i close the window or session after i installed ruby (using either rvm or rbebnv) the last lines recorded by bash_history are;
rvm get stable --autolibs=enable
OR
rbenv install 2.3.0
If i comment out below lines in .bash_profile and .profile, .bash_history resumes...
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *$
OR
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
I want to work on rails with a bash history.
Please let me know if i can get bash history working
I encountered the same problem, it was resolved here.
Simply update your RVM using rvm get head.
You could also create a .bash_logout file with the following:
shell_session_update
Sourced from GitHub comment

Ubuntu not recognizing rails after successfull installation, using zshrc

I'm using ubuntu, zshrc, and after installing rails, using
gem rvm all do gem install rails
and getting a successful install, i'm getting a
zsh: command not found: rails
I'm guessing this has to do with my ~/.zshrc file
I have this at the end of it:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
I'm a noob at understanding how paths work, any idea how to get terminal to recognize rails commands?

.rvrmc / "Could not find railties" when cloning new Rails from github

I cloned a Rails app developed by another person within my company from Github.
When I cd into the app's directory I get this message in the terminal:
You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /Users/george/evil-genius/Loopadoop/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
Then when I try to run any rails command e.g. rails server I get this error:
/Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [rvm-1.11.3.8] (Gem::LoadError)
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /Users/george/.rvm/rubies/ruby-1.9.3-p448/bin/rails:22:in `<main>'
If I run rvm rvmrc to .ruby-version, I no longer get the "you are using '.rvmrc'..." warning, but I still get the same error message about railties when trying to run rails commands.
rvm list shows these versions of Ruby installed:
rvm rubies
* ruby-1.9.3-p385 [ x86_64 ]
=> ruby-1.9.3-p448 [ x86_64 ]
ruby-2.0.0-p195 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
And my rvm version is 1.22.18.
What's happening? I don't understand rvm or .rvmrc files at all, and all other Rails stuff in other apps on my machine work perfectly fine. How can I get this rails app to work?
FWIW, here's what the .rvmrc file looks like when I first clone the repo from GH. (Comments removed for brevity):
#!/usr/bin/env zsh
environment_id="ruby-1.9.3-p448#loopAdoop"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
do
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
then \. "${__hook}" || true
fi
done
unset __hook
if (( ${rvm_use_flag:=1} >= 2 )) # display only when forced
then
if [[ $- == *i* ]] # check for interactive shells
then printf "%b" "Using: \E[32m$GEM_HOME\E[0m
" # show the user the ruby and gemset they are using in green
else printf "%b" "Using: $GEM_HOME
" # don't use colors in non-interactive shells
fi
fi
else
rvm --create "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
And after I run rvm rvmrc to .ruby-version, the .rvmrc file is deleted, and two new files are generated: .ruby-gemset, which just contains the name of my app, and .ruby-version, which just contains the text "ruby-1.9.3-p448"
you need to run:
gem install bundler &&
bundle install
it will install the gems needed for this project
you can make it automated on cd with:
echo rvm_autoinstall_bundler_flag=1 >> ~/.rvmrc

RVM switching to #global gemset instead of a specific one

When I enter my rails dir on server RVM switch to
/home/capistrano/.rvm/gems/ruby-1.9.2-p290#global/bin/bundle
although it should use ruby-1.9.2-p290#mygemset/bin/bundle as it works on my local machine. When I type rvm use 1.9.2#mygemset it works. Nginx server is also looking for gems in the #global gemset
my .rvmrc file:
environment_id="ruby-1.9.2-p290#mygemset"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
then
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
if ! rvm --create use "$environment_id"
then
echo "Failed to create RVM environment '${environment_id}'."
return 1
fi
fi
I'm not sure if I understood you but you could place an .rvmc file in your rails folder and put something like this in it.
rvm use ruby-1.9.2#mygemset
Whenever you cd into that directory rvm will use settings from the .rvmc file.
RVM is going through rapid develpment so the syntax and functionality of commands sometimes vary. Anyway, I solved it with upgrading to stable RVM:
rvm get stable
which is now rvm 1.14.1 (stable). Afterwards commands like rvm 1.9.3-p194#mygemset --create
works perfectly.
Another thing I was missing is the new syntax for executing commands:
rvm #mygemset do bundle install
This will install all gems for given gemset and ruby specified in .rvmrc file

Set Global default Ruby for RVM on machine with multiple (too many?) Rubies

I am struggling to get Rails to deploy on a server that has:
a factory installed Ruby (1.8.7) in /etc/
an updated Ruby (1.9.2p290) in /usr/local/bin/
the Ruby I want to be using(1.9.2p290) in /usr/local/rvm/rubies.
Is there a way to set a GLOBAL default Ruby in RVM for ALL users?
When I set default with rvm --default 1.9.2#railspre it'll work fine for that session. But, when I log back in the ruby switches back to the one in /usr/local/bin. And, due to RVM's hocus pocus, that I don't fully understand, I can't just edit the $PATH for it in .bashrc.
$PATH at login:
/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:/opt/subversion/bin:/usr/local/rvm/gems/ruby-1.9.2-p290#railspre/bin:/usr/local/rvm/gems/ruby-1.9.2-p290#global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
$PATH after rvm --default 1.9.2#railspre:
/usr/local/rvm/gems/ruby-1.9.2-p290#railspre/bin:/usr/local/rvm/gems/ruby-1.9.2-p290#global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:/opt/subversion/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
No matter what (before or after changing RVM's default) rvm default list says the same thing:
$ rvm default list
rvm rubies
=> ruby-1.9.2-p290 [ ppc ]
Ideas?
Edit- adding requested info
$ type rvm | head -1
rvm is a function
$ which ruby
/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby
$ whereis ruby
/usr/bin/ruby
Please post the result of the following :
type rvm | head -1
rvm notes
which ruby
whereis ruby
rvm list known
Do =>
rvm use 1.9.2 --default
Being root and normal user do =>
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source .bash_profile
Restart your pc and see if it works.

Resources