First time running a ruby app - ruby

I am trying to run a Rails app on my Snow Leopard Mac. I never worked with Ruby or Rails before, so any hint is welcome.
In terminal I went to the folder of the app, and ran rails server
and received the following error:
Could not find gem 'mysql2 (>= 0) ruby' in any of the gem sources
listed in your Gemfile. Run `bundle install` to install missing gems.
My gemfile looks like:
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do
gem 'mysql2'
end
group :production do
gem 'pg'
gem 'thin'
end
and database.yml has adapter: mysql2 for all environments. I already ran bundle install, and from running gem list I got:
mysql2 (0.3.11)
My gem environment is:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.17
- RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [x86_64-darwin10.8.0]
- INSTALLATION DIRECTORY: /Users/user/.rvm/gems/ruby-1.9.3-p125#rails3
- RUBY EXECUTABLE: /Users/user/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
- EXECUTABLE DIRECTORY: /Users/user/.rvm/gems/ruby-1.9.3-p125#rails3/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/user/.rvm/gems/ruby-1.9.3-p125#rails3
- /Users/user/.rvm/gems/ruby-1.9.3-p125#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I have been going around with this for more than last two hours with no luck so far.

Related

already installed gems not detected in gem list

I ran railsinstaller on a new computer that I bought and afterwards, in an effort to have this computer run all my old rails projects, I copied over all the gem dependencies. However, for some reason, "bundle install --local" does not work, which is odd since this particular way of copying rails projects and gems worked just fine in the past. I ran "gem env" and got this:
C:\Users\Owner\rails_projects\depot>gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.28
- RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/RailsInstaller/Ruby1.9.3/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1
- C:/Users/Owner/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I tried being more specific and tried "gem install rake-10.2.2 --local" and I get the following error:
ERROR: Could not find a valid gem 'rake-10.2.2' (>= 0) in any repository
And finally, I see that less than half of the actual gems that are in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems show up when running "gem list". Any help would be appreciate in figuring out how to get my gems detected. Thank you.

Ruby gem fails to load

I've installed a gem from command line:
sudo gem install jalalidate
gem says it's installed:
$ gem list jalalidate
*** LOCAL GEMS ***
jalalidate (0.3.2)
And it can be loaded:
ruby -rubygems -e 'require "jalalidate"' # output is empty, (success?)
Though when I try to include this gem in a Rakefile, rake fails:
# Rakefile:
require "rubygems"
require "bundler/setup"
require "stringex"
require "jalalidate"
# Terminal:
$ rake new_post["title"]
rake aborted!
cannot load such file -- jalalidate
(See full trace by running task with --trace)
Note:
I'm using octopress blogging system, and I'm trying to convert dates generated by Time.now.strftime('%Y-%m-%d %H:%M') to Jalali calender system, (JalaliDate.new(Date.today).strftime('%Y-%m-%d')).
I'm not familiar with Ruby
Update:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/soroush/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Your Rakefile has require "bundler/setup" before you try to require jalalidate which means you are using Bundler and so you have a Gemfile, which is restricting the gems (and versions) available.
In order to use the gem in your project, add the line
gem "jalalidate"
to the Gemfile.
See this question about why using sudo with gem commands is mostly a bad idea.
I recommend trying to install the gem without sudo: gem install jalalidate

ruby cannot find jiveapp gem although i installed it

I searched through similar questions, but still could not solve this problem. I installed my jiveapps gem, but then it cannot be found.
Successfully installed jiveapps-1.0.7
1 gem installed
Installing ri documentation for jiveapps-1.0.7...
Installing RDoc documentation for jiveapps-1.0.7...
new-host-2:sites jeffreyerickatz$ gem list jiveapps
*** LOCAL GEMS ***
The following also did not work:
new-host-2:sites jeffreyerickatz$ gem which jiveapps
ERROR: Can't find ruby library file or shared library jiveapps
new-host-2:sites jeffreyerickatz$ rake gemspec
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
(See full trace by running task with --trace)
You can see that I only have one version of ruby installed
ew-host-2:sites jeffreyerickatz$ rvm list
rvm rubies
=* ruby-1.9.3-p194 [ x86_64 ]
# => - current
# =* - current && default
# * - default
and here are my gem paths
- GEM PATHS:
- /Users/jeffreyerickatz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1
- /Users/jeffreyerickatz/.gem/ruby/1.9.1
and when I do sudo gem environment I get
sudo gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin11.4.2]
- INSTALLATION DIRECTORY: /Users/jeffreyerickatz/.rvm/rubies/ruby-1.9.3- p194/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/jeffreyerickatz/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jeffreyerickatz/.rvm/rubies/ruby-1.9.3-p194/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/jeffreyerickatz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1
- /Users/jeffreyerickatz/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
gem path
new-host-2:Desktop jeffreyerickatz$ echo $GEM_HOME
/Users/jeffreyerickatz/.rvm/gems/ruby-1.9.3-p194
If you copied pasted that correctly, it looks like gems are being installed into "/Users/jeffreyerickatz/.rvm/rubies/ruby-1.9.3- p194/lib/ruby/gems/1.9.1" (note the space between 1.9.3- and p194).
You can further check by echo $GEM_HOME. $GEM_HOME should be set to your gem path.

Why are the gems not findable by 'gem list local' even though the gem folder is full of installed gems?

When I type:
gem env
on my Windows system, it produces this info:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby/lib/ruby/gems/1.8
- RUBY EXECUTABLE: C:/Ruby/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby/lib/ruby/gems/1.8
- C:/Users/pb/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
When I go to the GEM path:
C:\Ruby\lib\ruby\gems\1.8\gems
I see many gem folders with all of the installed gems. But when I type
gem list local
I get an empty listing:
*** LOCAL GEMS ***
Why are the gems not findable?
I'm not sure, but i think the command is
gem list --local
gem list local tells RubyGems to list all gems whose name starts with the string local. (See gem help list for details.) Do you have any gems with that name installed? Otherwise, it's not really surprising that the list is empty.

What to do when Net-SSH complains about exec! method missing?

This is driving me crazy. I run into this every now and then on a new ubuntu/debian server.
Basically I can't do a exec! through net-ssh. Note, that I can require 'net/ssh' perfectly fine.
sample code
require 'rubygems'
require 'net/ssh'
Net::SSH.start('my.random.box', 'myuser', :forward_agent => "true") do |ssh|
#output = ssh.exec("hostname")
#puts output
output = ssh.exec!("hostname")
puts stdout
end
relevant system environment info
me#box:~$ gem list | grep net-ssh
net-ssh (2.0.11)
me#box:~$ which ruby
/usr/bin/ruby
me#box:~$ which gem
/usr/bin/gem
cyn0n#spicetrader:~$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/me/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
A couple of things to try:
Verify that the exec! method is in the source.
Check both gem repositories to make sure there isn't an older net-ssh version in there. gem list has some oddities; it's more straightforward to just go into the directories and see what's there.
require the current version in your script.
require 'rubygems'
gem 'net-ssh', '=2.0.11'
require 'net-ssh'

Resources