I just recently switched over to using zsh with oh-my-zsh and I am having issues using the rails command line tool. Here are the steps that I ran through, and the error that I am receiving.
I ran the curl command that the github page provides:
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
Then I went to run rails s, this is the following error message that I receive:
.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
This looks like I am having a gem error so I reinstalled rvm, rails and bundler with nothing solving the issue. However if I switch my terminal back over to bash then I dont have any issues and rails works perfectly fine. Has anyone else run into a similar issue? I want to use zsh because it seems like it has better features but if I can't use rails then I have to dump it to the curb.
These are the lines at the end of my .zshrc file:
export PATH=/Users/thomascioppettini/.rvm/gems/ruby-1.9.3p0/bin:/Users/thomascioppettini/.rvm/gems/ruby-1.9.3-p0#global/bin:/Users/thomascioppettini/.rvm/rubies/ruby-1.9.3-p0/bin:/Users/thomascioppettini/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
What I have done to work bundle zsh and rvm, that is couple of body movies:
1) add to .zshrc at first line to correct find bin direcrory (your CO):
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
2) add next line after previous one:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
3) and at the end change PATH:
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
For me it is work fine (now it correct define $PATH with all rvm gemsets)
did you put the
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
into your .zshrc?
I assume the rvm-installer installs it only into .bashrc
Ok I got it to work by deleting the path that was set in the zshrc and copying the rvm lines from my bash_profile in order to get the right configuration from rvm. If you run the following command in your terminal it should work:
cat ~/.bash_profile >> ~/.zshrc
If you are using rbenv then copy this line from bash.rc which you can access by sudo gedit ~/.bashrc
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"enter code here
eval "$(rbenv init -)"
then paste it to zshrc, which can be accessed by sudo gedit ~/.zshrc
Related
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
I installed rvm with rails, from the official website of RVM, I specified the command suggested by the tutorial.
When the installation my system has rails 4.0.0, rvm 01/23/12, ruby 2.0.0, bundler gem 1.3.5 and 2.0.3
But I need to install ruby 1.9 to practice with a course that I am currently doing. "Rails for Zombies 2"
I try to execute the instruction rvm install 1.9.3 and the console returns this message:
rvm: command not found
Possible duplicate of: Ubuntu rvm setup issue
Your problem is that RVM is not loaded when you open a new terminal.
To solve this, run this command line: (if using login-shell)
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Or this (if using non-login shell):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
Or if you are using zsh (and/or oh-my-zsh):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.zshrc
This will add the path to RVM to load at each Terminal instantiation. You must either close and reopen your terminals or simply call source ~/.bashrc (or ~/.bash_profile or ~/.zshrc).
I had this problem after installing zsh. I'm a domain user so my $PATH and $HOME are not as straight-forward. What worked for me was
echo "source /usr/share/rvm/scripts/rvm" >> ~/.zshrc
The latest installation needs the users to be added to the Group rvm and then need to login again.
Please note that closing the terminal and reopening is not enough; the user has to logout and log back to take the Group addition in effect.
Adding the user to the Group can be done by:
sudo usermod -a -G rvm <user>
The binaries can also be at different locations based on the method you followed during the installation.
I had them at /usr/share/rvm/
You can also look at /usr/local/rvm/scripts/rvm
Then you add this line to the end of ~/.bashrc
[[ -s /usr/share/rvm/scripts/rvm ]] && source /usr/share/rvm/scripts/rvm
Note: If you are using a shell other than bash you may need to add the path accordingly.
For instance, if you using zsh shell add the above lines to the ~/.zshrc file.
I started using Terminator, the teminal emulator, but when I run a rails application it can't find Rails.
humberto#asterix:~$ rails -v
The program 'rails' can be found in the following packages:
* rails
* ruby-railties-3.2
Try: sudo apt-get install <selected package>
Does anyone knows how to solve it?
Ensure RVM is Properly Loaded
I don't know anything about your terminal emulator, but it's likely that your environment isn't being properly modified for use by RVM. Make sure your shell sources a file that contains the following:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Depending on your shell and emulator, this is likely to be one of:
~/.profile
~/.bash_profile
~/.bashrc
If all else fails, just create a shell script that contains the necessary line and source it interactively into the current shell. For example, you might create a script and then source ~/bin/my_rvm_setup.sh to set up the correct environment variables and shell functions.
You can simply run terminator from default gnome terminal by the command:
terminator
Than terminator will load paths defined for your default terminal. You can also load RVM on .bashrc file. To do that add this line on your ~/.bashrc file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I've recently changed my terminal to use Oh My ZSH but for some reason when I try to run rails commands I get the following error:
/Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rubygems.rb:1210:in `gem'
from /Users/david/.rvm/gems/ruby-1.9.3-p0#railstest/bin/rails:18:in `<main>'
Would anyone be able to help me with this?
I had exactly the same problem, and it turned out to be that I hadn't moved an essential line from ~/.bashrc to ~/.zshrc. Putting it in at the end and reopening the terminal fixed the problem:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
For people using rbenv, you should move your rbenv initialization to ~/.zshenv as in http://coderwall.com/p/0o64yq?i=1&p=1&q=author%3Awilhelmbot
Like mention first step is to add
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
If after adding this line of code if still not work check your export path.
Check your PATH (export PATH) in .zshrc and remove all references to .rvm within it. You should end up with something like this export
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin
When installing oh-my-zsh it will look at your current PATH and fill your .zshrc with it, which also pulls .rvm environment. And you won't want that there since rvm should be handling it.
For rbenv users
when you install omz (oh my zsh!), omz does two things
It copies the content of .zshrc into .zshrc.pre-oh-my-zsh
makes new .zshrc
To solve the "Rails is not currently installed ", what you could do is copy the content of .zshrc.pre-oh-my-zsh into the new .zshrc.
cd ~
cat .zshrc.pre-oh-my-zsh >> .zshrc
After this restarting the terminal worked for me.
1) Try these commands:
rbenv which rails
rbenv which gem
gem env
2) If the environment problem isn't clear from that output, then:
See if you have this file:
$HOME/.rvm/scripts/rvm
Try to "source" it
Q: Just out of curiousity, what is "ZSH" and why did you decide to try it?
Q: I imagine it's compatible with "bash", correct?
I have installed ruby via rvm on Mint 11 no problem. Installed gems, ditto. Installed rails via gem install rails, and when I type rails -v it returns the correct version. Until I close that terminal and reopen a terminal. When I do that and type rails -v I get the message
The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails
If I then type
rvm use 1.9.2-p180 --default
and then type rails -v I again get the correct version...until I close the terminal.
I should add that I have added a path statement to my .bashrc pointing to the 1.9.2-p180 directory in my .rvm directory.
Typing ruby -v always returns the correct version.
Create .bashrc file and add .rvm command
$ sudo touch ~/.bashrc
$ sudo gedit ~/.bashrc
(Add line to .bashrc file)
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
Logout and Login OR just update user profile from .bashrc with following command
$ . ~/.bashrc
Try adding this command to your .profile and reopening your shell:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
Use project rvmrc files. You can see how to set this up here http://beginrescueend.com/rvm/best-practices/
That way you keep all your gems seperate for each project and it's dead simple to set up
Try which rails. Maybe there is a link to a stub that gives you the note.
If that is the case calling the full path might help, e.g. /usr/local/bin/rails