I created a new Rails API app. I am trying to create the database table for the app with the command for a postgres db
rake db:create:all
and Im getting this error:
AM@~/Documents/RailsWS/iosprototypevendors >rake db:create:all --trace
rake aborted!
Valid types are [:development, :runtime], not nil
/usr/local/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:52:in `initialize'
/Users/AM/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler- 1.2.0/lib/bundler/resolver.rb:371:in `new'
/Users/AM/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler- 1.2.0/lib/bundler/resolver.rb:371:in `search'
/Users/AM/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-
..............
A bunch of googling I found out that this might have something to do with the wrong version of ruby picked up.
(I recently upgraded my OS to Mountain Lion and had to upgrade my Rails and Ruby versions to the latest. Went through hell for 8 hrs to get rails up and going. Rails works now on my system but this is one discrepancy that just popped up).
In addition
I also noticed that for different rails apps on my system when I check their versions using rails -v the versions of rails sometimes come up as 3.2.1 and other time 3.2.8 and sometimes I get the above error message.
How can this be happenning? Here is what I get by running this command:
rvm info
ruby-1.9.3-p194:
system:
uname: "Darwin A-Ms-MacBook-Pro.local 12.1.0 Darwin Kernel Version 12.1.0: Tue Aug 14 13:29:55 PDT 2012; root:xnu-2050.9.2~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin12.0)"
rvm:
version: "rvm 1.15.8 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
updated: "1 day 22 hours 15 minutes 59 seconds ago"
ruby:
interpreter: "ruby"
version: "1.9.3p194"
date: "2012-04-20"
platform: "x86_64-darwin12.1.0"
patchlevel: "2012-04-20 revision 35410"
full_version: "ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.1.0]"
homes:
gem: "/Users/AM/.rvm/gems/ruby-1.9.3-p194"
ruby: "/Users/AM/.rvm/rubies/ruby-1.9.3-p194"
binaries:
ruby: "/Users/AM/.rvm/rubies/ruby-1.9.3-p194/bin/ruby"
irb: "/Users/AM/.rvm/rubies/ruby-1.9.3-p194/bin/irb"
gem: "/Users/AM/.rvm/rubies/ruby-1.9.3-p194/bin/gem"
rake: "/Users/AM/.rvm/gems/ruby-1.9.3-p194@global/bin/rake"
environment:
PATH: "/Users/AM/.rvm/gems/ruby-1.9.3-p194/bin:/Users/AM/.rvm/gems/ruby- 1.9.3-p194@global/bin:/Users/AM/.rvm/rubies/ruby-1.9.3- p194/bin:/Users/AM/.rvm/bin:/Users/AM/.rbenv/shims:/Users/AM/.rbenv/bin:/usr/local/bin:/usr/ local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/PostgreSQL/9.1/bin/"
GEM_HOME: "/Users/AM/.rvm/gems/ruby-1.9.3-p194"
GEM_PATH: "/Users/AM/.rvm/gems/ruby-1.9.3-p194:/Users/AM/.rvm/gems/ruby-1.9.3-p194@global"
MY_RUBY_HOME: "/Users/AM/.rvm/rubies/ruby-1.9.3-p194"
IRBRC: "/Users/AM/.rvm/rubies/ruby-1.9.3-p194/.irbrc"
RUBYOPT: ""
gemset: ""
Any help is appreciated
EDIT
Here is what I get when I run the command
echo $PATH on my terminal
/Users/AM/.rbenv/shims:
/Users/AM/.rbenv/bin:
/usr/local/bin:/usr/local/sbin:
/usr/local/mysql/bin:
/Users/AM/.rvm/gems/ruby-1.9.3-p194/bin:
/Users/AM/.rvm/gems/ruby-1.9.3-p194@global/bin:
/Users/AM/.rvm/rubies/ruby-1.9.3-p194/bin:
/Users/AM/.rvm/bin:
/usr/local/bin:
/usr/bin:/usr/bin:
/bin:/usr/sbin:/sbin:
/usr/local/bin:
/Library/PostgreSQL/9.1/bin/
So these are the paths on my system
So I didn't get the answers I was looking for. So after my own research I found out this, (in case4 others have this issue)
Mountain Lion ships with Postgresql and a native ruby version 1.8.7. The current ruby
version is 1.9.3. So once you upgrade to mountain lion upgrade your versions of rails
and ruby as well and makke sure you are running the right versions.
rvm is the version management tool on mountain lion and can update aand download these for you. See this post here
Also if you install the upgrades you will have multiple versions of ruby and rails on your computer. So it becomes important to set the right version as a default onyour system. You must do that each time you open a terminal window by the command to check the versions first: rails -v and ruby -v or rvm list
then you set the default versions like this rvm --default 1.9.3-p194 this will set the
default for that terminal session. If you want a more permanent setup per project then ]
you will have to create a .rvmrc file in the root of every project and specify the
vcersions there for that project to use. again see the post linked to above.