I have been following the tutorial to install Ruby on Rails on the mac from this website:
http://ruby.railstutorial.org/
I installed rvm and it wasn't working. The tutorial said to enter this command:
~ $ [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
After I did that it seemed to have loaded successfully as it said this:
~ DUFF$ rvm reload
RVM reloaded!
~ DUFF$ rvm notes
Notes for Darwin ( Mac OS X )
For Lion, Rubies should be built using gcc rather than llvm-gcc. Since
/usr/bin/gcc is now linked to /usr/bin/llvm-gcc-4.2, add the following to
your shell's start-up file: export CC=gcc-4.2
(The situation with LLVM and Ruby may improve. This is as of 07-23-2011.)
For Snow Leopard be sure to have Xcode Tools Version 3.2.1 (1613) or later
You should download the latest Xcode tools from developer.apple.com.
(This is since the dvd install for Snow Leopard contained bugs).
If you intend on installing MacRuby you must install LLVM first.
If you intend on installing JRuby you must install the JDK.
If you intend on installing IronRuby you must install Mono (version 2.6 or greater is recommended).
To seamlessly abandon the Apple-installed system ruby (ruby 1.8.7 patchlevel 174 for Snow Leopard):
rvm install 1.8.7 # installs patch 302: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system # migrate your gems
rvm --default 1.8.7
NOTE: For all installations, as of 1.7, RVM no longer autoloads .rvmrc files. In order to return this functionality, you MUST add 'export rvm_project_rvmrc=1' to your $HOME/.rvmrc file. This causes RVM to override 'cd' which, while toggleable even < 1.7, is currently defaulted to 'off'. This knob returns the previous behaviour to active which causes per-project .rvmrc files to be loaded once again.
Example: echo 'export rvm_project_rvmrc=1' >> $HOME/.rvmrc && rvm reload
So after all of that I entered this as directed:
type rvm | head -n1
and it said:
-bash: type: rvm: not found
So after that long introduction my question would be do you know why it is not recognizing the rvm type after it seemed to have installed. I am a complete newbie so please be gentle. I have been having a ton of issues and this seemed to be moving along nicely up until this point.
Any help would be appreciated. Thanks.
Are you following this tutorial? http://beginrescueend.com/rvm/install/
You should run this entire command:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
That way it's appended to your .bash_profile file, and loaded in every new terminal. The command you entered will only load the rvm function for a single terminal session.
.rvm/scripts/rvm is a shell script itself that loads all necessary functions into your environment.
Have a look at the same question I posted some time ago.
The install guide says to "register" RVM in the terminal this way:
user$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
Basically, when you load the RVM function in your shell, where you're going to put the instruction depends on your distribution; here it's going into .bash_profile.
As a user of Ubuntu, I found using .bashrc instead of .bash_profile worked better.
The difference between .bash_profile and .bashrc is outlined here: http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
Related
I have followed this thread and followed Linuxios' answer, everything was working fine but then I get
-bash: export: `[[': not a valid identifier
-bash: export: `-s': not a valid identifier
-bash: export: `/Users/duaneadam/.rvm/scripts/rvm': not a valid identifier
-bash: export: `]]': not a valid identifier
So, I went and removed from .bash__profile via Terminal.
export PATH=$PATH:/usr/local/git/bin/ [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
.. thinking that lines of code is the problem but what I get after that is even worse. For some reasons.. Ruby is not installed.. again.
So, I re-added the lines of code and tried rebooting/restarting my Mac but problem still persist.
Screenshots:
.bash_profile:
Solution please? I even tried re-installing using his method.
Gosh, this is hard maybe Ruby on Rails isn't just for me.
Setting up ruby with rvm can get pretty complicated at times.
A few golden rules is never to sudo when using a package manager like rvm.
Try the following:
rvm implode (This essentially removes the rvm installation
completely.)
Remove all references of rvm from ~/.bash_profile and ~/.bashrc
which ruby (The output should be something like /usr/bin, also ruby --version should be 1.8.7, the default bundled with OS X.)
Install rvm again in a single user mode.
Install the ruby version of your choice.
Make sure to create the .rvmrc file where ever the ruby program resides. (Typical contents of .rvmrc -> rvm use ruby-version#gemset-name --create; eg: rvm use 1.9.3#my-awesome-project --create)
cd into the directory with .rvmrc
Make sure the right gemset is loaded with rvm gemset list
Also ensure that rvm is loaded as a function. (You can verify this by typing type rvm | head -1 in the console.)
Some more points, which were helpful to me from http://jfire.io/blog/2012/03/02/xcode-4-dot-3-homebrew-and-ruby/:
Install apple-gcc42, autoconf and automake (Using a package manager like homebrew can be useful.)
Also rvm requirements tells you what are the other tools you need to install.
Cheers!
In chapter 1.2.2 of Michael Hartl's Ruby on Rails tutorial we are using rvm to install rails.
Following the first few steps is no problem.
But when I get to this command:
rvm use 1.9.3#rails3tutorial2ndEd --create --default
I get this response.
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
I did a lot of research before posting this question. But could not find one that addresses my problem specifically.
I'm using linux under Ubuntu (in a VM on Windows 7).
Thank you.
The above is one way to fix it, although RVM says you should instead change your shell settings.
Press ctrl+alt+t to bring up the terminal, and then go to edit >> profile preferences >> title & command tab, then select "Run Command as Login Shell".
That should work as well.
You have probably not yet installed RVM correctly.
Make sure that you source RVM from your .bash_profile or .bashrc file.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
This is what I have in my .bash_profile for RVM to work. (After adding this restart your console or type source ~/.bash_profile
I'm getting this error when I try to invoke rails, rails -v or rails -c:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
I installed RVM, used it to install Ruby 1.9.3, and switched to it rvm use 1.9.3 --default.
When I ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
I also gem install rails --no-rdoc --no-ri and checked...ls ~/ruby/gems/gems/:
actionmailer-3.2.8/ journey-1.0.4/ rake-0.9.2.2/
actionpack-3.2.8/ json-1.7.5/ rdoc-3.12/
activemodel-3.2.8/ mail-2.4.4/ rubygems-bundler-1.0.7/
activerecord-3.2.8/ mime-types-1.19/ rvm-1.11.3.5/
activeresource-3.2.8/ multi_json-1.3.6/ sprockets-2.1.3/
activesupport-3.2.8/ polyglot-0.3.3/ sprockets-2.4.5/
arel-3.0.2/ rack-1.4.1/ thor-0.16.0/
builder-3.0.0/ rack-cache-1.2/ tilt-1.3.3/
bundler-1.1.5/ rack-ssl-1.3.2/ treetop-1.4.10/
erubis-2.7.0/ rack-test-0.6.1/ tzinfo-0.3.33/
hike-1.2.1/ rails-3.2.8/
i18n-0.6.0/ railties-3.2.8/
And if I echo $GEM_PATH:
/home/flackend/.rvm/gems/ruby-1.9.3-p194:/home/flackend/.rvm/gems/ruby-1.9.3-p194#global
echo $PATH:
/home/flackend/.rvm/gems/ruby-1.9.3-p194/bin:/home/flackend/.rvm/gems/ruby-1.9.3-p194#global/bin:/home/flackend/.rvm/rubies/ruby-1.9.3-p194/bin:/home/flackend/.rvm/bin:/usr/local/jdk/bin:/home/flackend/perl5/bin:/usr/kerberos/bin:/usr/lib/courier-imap/bin:/usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/home/flackend/.rvm/bin:/home/flackend/bin
cat ~/.bashrc:
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
cat ~/.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
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
So somewhere something has a path that says to look at the system Ruby install. Any ideas? Thanks!
EDIT
Okay, also, If i switch back to the system Ruby, rvm use system, and rails -v, I get:
Rails 2.3.8
So I have no idea at all what this error is indicating.
You have not completed rvm installation. You need add ~/.rvm bin paths before /usr/bin by command in .bashrc:
[[ -s "/Users/pftg/.rvm/scripts/rvm" ]] && source "/Users/pftg/.rvm/scripts/rvm".
To test just check $PATH env. Should be similar to:
/.../.rvm/gems/ruby-1.9.3-p125#global/bin:/.../.rvm/rubies/ruby-1.9.3-p125/bin:/.../.rvm/bin:/usr/local/bin
If you installed everything ruby as well as rails means, you may need to select the 'Run command as login shell' checkbox by doing following,
Open terminal
Go to Edit tab, then select Profile Preferences from the menu item.
The Profile Preferences window should be displayed, then select Title and Command tab.
Then select the checkbox Run command as a login shell.
I just used RVM to create a "gemset", switched to it, and tried installing Rails again and it works now.
https://rvm.io/gemsets/
I'm not sure why that fixed it or why it wasn't working before. I like when things work, but I would rather have figured out why it wasn't working with the #global gemset.
Thanks for all your help!
I had the exact symptoms described above as well and was stuck on this problem for quite some time (the ruby environment and dependencies are a horrible mess). I can't say I'm out of the woods yet but at least I'm picking up the correct version of rails now and gotten past this error.
I believe the real issue here is actually to do with zlib. It seems that it's a crucial component to separate your system version of ruby (v1.8 likely install via yum/apt-get) with the other versions or Ruby you need (installed via rvm) for other projects.
If you do not have zlib installed, or rvm is not using it correctly, then sometimes you will pick up the system ruby/rails and all sorts of strange errors occur.
If you DO have zlib installed (yum/apt-get install zlib) then the trick I discovered was that I specifically had to tell rvm which version of zlib to use when installing ruby.
rvm install 1.9.3 --with-zlib-dir=$rvm_path/usr
I am using ruby on rails on Ubuntu 11.10. Ruby 1.8.7 works fine but I cannot get rvm to work with 1.9.3 or any other version.
When I run rvm reload, rvm list or rvm info, I get the following message:
bash: /usr/bin/rvm: No such file or directory
I have Ruby 1.9.3 installed via rvm and when I change the default it doesn't give me an error. But then when I check the ruby -v it defaults back to 1.8.7.
Also, when I check which ruby it shows the following:
/usr/local/bin/ruby
My guess is that it has something to do with the bash file. What do you suggest?
I am guessing that it isn't even installing it correctly.
This is what happens:
I type the following into the prompt:
bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
And it outputs:
ERROR: Unable to checkout branch .
Are you following the installation instructions from the rvm site?
http://beginrescueend.com/rvm/install/
If you are then look at section 2 about the shell again.
specifically this command that they tell you to run :-)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
remember to reload or restart your shell after running that command.
run the command
source /usr/local/rvm/scripts/rvm
and then
type rvm | head -1
you should get output -
rvm is a function.
And after that run
rvm use rvm use 2.0.0 --default
I installed RVM, Ruby 1.9.2 and Rails 3.0.9 on Lion which works fine. Only problem is, after I close the terminal I need to execute this:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
for it to pick up RVM.I then need to make RVM use Ruby 1.9.2 first before I can do Rails stuff again.
How can I make this permanent?
After you first execute
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
you shouldn't need to do it again. That line appends the necessary file inclusion information RVM into your .bash_profile. If you are using bash (as opposed to zsh, ksh, csh, tcsh or any other shell), then RVM will be accessible each time you open a new session. If you are using a different shell, that line may need to be in a different startup file. For example, if you are using zsh, then you'll probably want to append it to your ~/.zshrc file.
Having done this, simply running rvm --default use ruby-1.9.2 once should ensure that you have the desired version of Ruby by default. Note, you should not need to add this line to your .bash_profile or similar.
try this
rvm --default use ruby-1.9.2
In order to make Terminal (e.g. bash) enable RVM every time you open it, edit ~/.profile and add the following line to it:
[[ -s "/Users/foo/.rvm/scripts/rvm" ]] && source "/Users/foo/.rvm/scripts/rvm" # This loads RVM into a shell session.
Then to make the RVM's version of ruby default, as fl00r has mentioned, run:
rvm --default use ruby-1.9.2
Alternatively, you can add an .rvmrc file to the root folder of your app that uses Rails 3.0.9 and specify which version of Ruby you want to use with that project there:
rvm ruby-1.9.2
Even better, you should create a gemset by running rvm gemset create rails-3.0.9 and update you .rvmrc file to become like this:
rvm ruby-1.9.2#rails-3.0.9
Then run cd into the project once again (you must cd into it once again), and run bundle install.
This way your project will have its own isolated gemset.
this also work for me
rvm --default use 1.9.2