Reputation: 1299
In my Heroku/Sinatra app I set up my gemfile with Ruby 1.8.7 and then later used RVM to set my default to 2.0.0. Now when I try and install any new gems such Sinatra-flash or Pony, the gems aren't recognized or found when I require them in my main.rb file.
When I add gem "pony" in my gemfile I get a popup message saying:
Gem 'pony' is not available in SDK 'ruby-1.8.7-p385'
even though I've installed it. When I type gem list
into the terminal, it returns all the gems I've installed that aren't being recognized as installed in my program.
If I add require 'sinatra/flash'
or require 'pony'
in my main.rb, I get a message:
no such file to load
I'd really appreciate any help on this, this has been driving me nuts.
Edited:
Using command sudo gem install 'gemname'
When I enter rvm info
I get back
ruby :
interpreter: "ruby"
version: "2.0.0p195"
date: "2013-05-14"
platform: "x86_64-darwin12.3.0"
patchlevel: "2013-05-14 revision 40734"
full_version: "ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]"
homes:
gem: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195"
ruby: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195"
binaries:
ruby: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/bin/ruby"
irb: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/bin/irb"
gem: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/bin/gem"
rake: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195@global/bin/rake"
environment:
PATH: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195/bin:/Users/adam419/.rvm/gems/ruby-2.0.0-p195@global/bin:/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/bin:/Users/adam419/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/git/bin/[["
GEM_HOME: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195"
GEM_PATH: "/Users/adam419/.rvm/gems/ruby-2.0.0-p195:/Users/adam419/.rvm/gems/ruby-2.0.0-p195@global"
MY_RUBY_HOME: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195"
IRBRC: "/Users/adam419/.rvm/rubies/ruby-2.0.0-p195/.irbrc"
RUBYOPT: ""
gemset: ""
Edit: After I enter 'rvm use ruby-2.0.0' and then 'bundle install'
I get;
Adams-MacBook-Pro:songs adam419$ rvm use ruby-2.0.0
Using /Users/adam419/.rvm/gems/ruby-2.0.0-p195
Adams-MacBook-Pro:songs adam419$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Could not find gem 'sinatra/flash (>= 0) ruby' in the gems available on this machine.
After changing from gem "sinatra/flash" to gem "sinatra-flash" and then running bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Enter your password to install the bundled RubyGems to your system:
Using addressable (2.2.8)
Installing daemons (1.1.9)
Using data_objects (0.10.12)
Using dm-core (1.2.0)
Using dm-do-adapter (1.2.0)
Installing dm-migrations (1.2.0)
Using do_sqlite3 (0.10.12)
Using dm-sqlite-adapter (1.2.0)
Installing eventmachine (1.0.3)
Using rack (1.5.2)
Using rack-protection (1.5.0)
Using sass (3.2.9)
Using tilt (1.4.1)
Using sinatra (1.4.2)
Using sinatra-flash (0.3.0)
Installing temple (0.6.5)
Installing slim (1.3.9)
Installing thin (1.5.1)
Using bundler (1.3.5)
Your bundle is complete!
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Current Gemfile
source 'https://rubygems.org'
gem "sinatra"
gem "slim"
gem "sass"
gem "dm-core"
gem "sinatra-flash"
gem "dm-migrations"
gem "thin"
gem "pg", :group => :production
gem "dm-postgres-adapter", :group => :production
gem "dm-sqlite-adapter", :group => :development
Gemlock file dependencies
DEPENDENCIES
dm-core
dm-migrations
dm-postgres-adapter
dm-sqlite-adapter
pg
sass
sinatra
sinatra-flash
slim
thin
Upvotes: 1
Views: 5440
Reputation: 2733
I had the same problem and i deleted my rubymine .idea file and now its working fine.
Upvotes: 0
Reputation: 8488
By using sudo gem install pony
you're triggering the system Ruby install which is different from RVM's version. Do not use sudo
. Just make sure that RVM is loaded, then use the correct version of your ruby:
rvm use ruby-2.0.0
Then run bundler:
bundle install
This should give you the full environment.
Upvotes: 1