Getting a Rack GemNotFound with Sinatra - ruby

This is my first attempt with a ruby stack. I'm stuck with the following error:
Could not find rack-1.6.4 in any of the sources (Bundler::GemNotFound)
I've successfully installed the following components:
ubuntu 14.04.3 LTS
rvm 1.26.11
ruby 2.1.6p336
nginx 1.8
* LOCAL GEMS *
bigdecimal (1.2.4)
bundler (1.10.6)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.1)
minitest (4.7.5)
psych (2.0.5)
rack (1.6.4)
rack-protection (1.5.3)
rake (10.1.0)
rdoc (4.1.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
sinatra (1.4.6)
test-unit (2.1.6.0)
tilt (2.0.1)
* Gemfile *
gem 'sinatra', '1.4.6'
* Gemfile.lock *
GEM
remote: https://rubygems.org/
specs:
rack (1.6.4)
rack-protection (1.5.3)
rack
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
tilt (2.0.1)
PLATFORMS
ruby
DEPENDENCIES
sinatra (= 1.4.6)
BUNDLED WITH
1.10.6
* config.ru *
require './app.rb'
run Sinatra::Application
* app.rb *
require 'bundler/setup'
require 'sinatra'
get '/' do
'hello world'
end
I'm using the default Nginx folder for the app. I was able to execute the following test in config.ru:
app = proc do |env|
[200, { "Content-Type" => "text/html" }, ["hello world"]]
end
But as soon I try to switch to Sinatra I get the error above.
Thanks in advance!

Ok I found the problem.
I followed the installation instruction here: https://www.phusionpassenger.com/library/install/nginx/install/oss/trusty/
But since I'm using rvm I had to change the passenger_ruby directive to point to the rvm wrapper: /usr/local/rvm/wrappers/ruby-2.1.6/ruby

Problem is here:
rack (1.6.4)
...
sinatra (1.4.6)
rack (~> 1.4)
You have a conflict in the rack version. you want both 1.6.4 and 1.4.x
How did rack 1.6.4 end up in the gemfile.lock?

Related

Openshift: Cannot find rack-1.5.2 in any of sources

I want to run a small test Sinatra application. Here is the error message:
Could not find rack-1.5.2 in any of the sources (Bundler::GemNotFound)
I have verified that the rack 1.5.2 gem is installed in my environment.
Here is the Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
rack (1.5.2)
sass (3.1.20)
sequel (4.10.0)
sinatra (1.0)
rack (>= 1.0)
slim (2.0.2)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
sqlite3 (1.3.6)
temple (0.6.7)
tilt (2.0.1)
PLATFORMS
ruby
DEPENDENCIES
rack
sass (= 3.1.20)
sequel
sinatra
slim (= 2.0.2)
sqlite3 (= 1.3.6)
I would appreciate any help on how to proceed.

Redmine: cannot start WEBrick (LoadError)

I am working on a CentOs 5.5. I have never worked with ruby or rails before, but recently I had to upgrade a redmine 1.1.0 to version 2.3.1 following this tutorial. The update process went smoothly, but once I try to start WEBrick to host the application, with the command
ruby /var/www/redmine/script/server webrick -d -e production -p 8080 (port 80 is already being listened by an apache)
I get the following error:
/var/www/redmine/script/server:3:in `require': no such file to load -- commands/server (LoadError)
from /var/www/redmine/script/server:3:in `<main>'
The contents in '/var/www/redmine/script/server' are:
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
My ruby version, which is compatible with this redmine version, is 1.9.2. I believe I have installed every required gem in my Gemfile. I don't know why ruby doesn't find this file, and so I tried replacing the last require with what I suspected was the filepath of the desired file.
require '/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb'
It didn't seem to work, though. Despite the fact the error was gone, I still got an "Service Unavailable" error from my browser.
Just for the record, the output as shown by the command 'gem env' is:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.5
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [i686-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
The output of 'gem list' is:
actionmailer (3.2.13, 3.2.0)
actionpack (3.2.13, 3.2.0)
activemodel (3.2.13, 3.2.0)
activerecord (3.2.13, 3.2.0)
activeresource (3.2.13, 3.2.0)
activesupport (3.2.13, 3.2.0)
arel (3.0.2)
atomic (1.1.4)
bourne (1.1.2)
builder (3.0.4, 3.0.0)
bundler (1.3.5)
capybara (2.0.3)
childprocess (0.3.9)
coderay (1.0.9)
erubis (2.7.0)
fastercsv (1.5.5)
ffi (1.9.0)
hike (1.2.3)
i18n (0.6.4, 0.6.1)
journey (1.0.4)
jquery-rails (2.0.3)
json (1.8.0)
mail (2.5.4, 2.4.4)
metaclass (0.0.1)
mime-types (1.23)
mini_portile (0.5.1)
minitest (4.7.5, 1.6.0)
mocha (0.13.3, 0.10.5)
multi_json (1.7.7)
mysql (2.8.1)
net-ldap (0.3.1)
nokogiri (1.6.0)
pg (0.11.0)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack-openid (1.3.1)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.13, 3.2.0)
railties (3.2.13, 3.2.0)
rake (10.1.0, 0.8.7)
rake-compiler (0.8.3)
rdoc (3.12.2, 2.5.8)
rmagick (2.13.2)
ruby-openid (2.2.3, 2.1.8, 2.1.4)
rubygems-update (2.0.5)
rubyzip (0.9.9)
selenium-webdriver (2.33.0)
shoulda (3.5.0, 3.3.2)
shoulda-context (1.0.2)
shoulda-matchers (1.4.2)
sprockets (2.2.2, 2.1.3)
sqlite3 (1.3.7)
thor (0.18.1, 0.14.6)
thread_safe (0.1.0)
tilt (1.4.1)
treetop (1.4.14)
tzinfo (0.3.37)
websocket (1.0.7)
xpath (1.0.0)
yard (0.8.6.2)
Would someone please give me a hint of the cause of the error or how to fix it?
If I'm not mistaken script/server is rails 2.x.x way to start the rails application.
If I look at your bundler, it now uses rails 3.x and the way to start it suppose to be with rails server
I verify this by looking into
http://www.redmine.org/projects/redmine/repository/show/tags/2.3.1/script
there is no server executable. but there is rails executable there
Check if thre is rails executable on the same folder.
if there is, you should be able to run rails with:
$ /var/www/redmine/script/rails server

gem packetfu LoadError

I am attempting to use the packetfu gem. I'm new at ruby on rails, so please bear with me. I'm using rvm with ruby-1.9.3-head [ x86_64 ]. I also have Mac OSX 10.7.4 I am getting this error when trying to run sudo ruby app/models/simpleSniff.rb
/Users/aragorn/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- packetfu (LoadError)
from /Users/aragorn/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from app/simpleSniff.rb:2:in `<main>'
The code contained in simpleSniff.rb is
#!/usr/bin/env ruby
require 'packetfu'
include PacketFu
iface = "eth1"
cap = Capture.new(:iface => iface, :start => true)
cap.stream.each do |p|
put p
end
$gem list
* LOCAL GEMS *
actionmailer (3.2.8)
actionpack (3.2.8)
activemodel (3.2.8)
activerecord (3.2.8)
activeresource (3.2.8)
activesupport (3.2.8)
arel (3.0.2)
builder (3.0.0)
bundler (1.1.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.3)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
json (1.7.4)
mail (2.4.4)
mime-types (1.19)
multi_json (1.3.6)
packetfu (1.1.5)
pcaprub (0.11.2)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.8)
railties (3.2.8)
rake (0.9.2.2)
rdoc (3.12)
rspec (2.11.0, 0.9.4)
rspec-core (2.11.1)
rspec-expectations (2.11.2)
rspec-mocks (2.11.2)
rubygems-bundler (1.0.6)
rvm (1.11.3.5)
sass (3.2.1)
sass-rails (3.2.5)
sdoc (0.3.16)
sprockets (2.1.3)
sqlite3 (1.3.6)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.7)
Then finally my Gemfile is
source 'http://rubygems.org'
gem "rails", "3.2.8"
gem "rspec", "~> 0.9.2"
gem "sdoc", "~> 0.3.16"
gem "pcaprub", "~> 0.11.2"
gem "packetfu", "~>1.1.5"
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
A) The require problem specifically is because you're sudo'ing and not rvmsudo'ing (which will keep your ruby environment in tact)
B) If PacketFu and Pcaprub and injection and capture all works on your OS X machine, please let me know! I would be both shocked and awed. I've heard rumor it works.. for some people. I've never actually seen it with my own eyeballs, though.

heroku, thin rack 1.1.0, gemfile requires rack 1.0.1

My ror app runs on rails 2.3.5(which requires rack 1.0.1),
thin on heroku activates rack 1.1.0 by default
and throws error:
" You have already activated rack 1.1.0, but your Gemfile requires rack 1.0.1. Consider using bundle exec."
my Gemfile:
source 'http://rubygems.org'
group :test, :development do
gem "rack","1.0.1"
end
gem "rails","2.3.5"
gem "mysql"
gem "rake", "0.8.3"
gem "declarative_authorization", "0.5.2"
gem "searchlogic"
gem "prawn", "0.6.3"
gem "thin","1.2.11"
group :test, :development do
gem "rack","1.0.1"
end
group :development do
# bundler requires these gems in development
# gem "rails-footnotes"
end
group :test do
# bundler requires these gems while running tests
# gem "rspec"
# gem "faker"
end
----------------------
I installed bundler and developed Gemfile.lock :
GEM
remote: http://rubygems.org/
specs:
actionmailer (2.3.5)
actionpack (= 2.3.5)
actionpack (2.3.5)
activesupport (= 2.3.5)
rack (~> 1.0.0)
activerecord (2.3.5)
activesupport (= 2.3.5)
activeresource (2.3.5)
activesupport (= 2.3.5)
activesupport (2.3.5)
daemons (1.1.4)
declarative_authorization (0.5.2)
eventmachine (0.12.10)
mysql (2.8.1)
prawn (0.6.3)
prawn-core (>= 0.6.3, < 0.7)
prawn-format (>= 0.2.3, < 0.3)
prawn-layout (>= 0.3.2, < 0.4)
prawn-security (>= 0.1.1, < 0.2)
prawn-core (0.6.3)
prawn-format (0.2.3)
prawn-core
prawn-layout (0.3.2)
prawn-security (0.1.1)
rack (1.0.1)
rails (2.3.5)
actionmailer (= 2.3.5)
actionpack (= 2.3.5)
activerecord (= 2.3.5)
activeresource (= 2.3.5)
activesupport (= 2.3.5)
rake (>= 0.8.3)
rake (0.8.3)
searchlogic (2.4.28)
activerecord (>= 2.0.0)
thin (1.2.11)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
PLATFORMS
ruby
DEPENDENCIES
declarative_authorization (= 0.5.2)
mysql
prawn (= 0.6.3)
rack (= 1.0.1)
rails (= 2.3.5)
rake (= 0.8.3)
searchlogic
thin (= 1.2.11)
---------------------------
Please help me deploy it on heroku........
Solved it...
my app uses rack 1.0.1 , rails 2.3.5
and heroku activates rake 1.1.0 by default..
so i switched my rails app version to 2.3.11 which uses rack 1.1.2 in environment.rb and created a Gem file,
installed bundler
tested on my laptop...
generated lock file and pushed it to heroku...
finally worked....
took a week to get my app working...
:)

Ruby undefined method error using Deprecate.skip_during

I am trying to install Gitorious in my local computer. However I get this error when I execute the console application:
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:194:in
block in stub_source_index170':
undefined methodskip_during' for
Bundler::RubygemsIntegration::Deprecate:Class
(NoMethodError)
The ruby code that is executing in /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb is:
def stub_source_index170(specs)
Gem::SourceIndex.send(:define_method, :initialize) do |*args|
#gems = {}
# You're looking at this thinking: Oh! This is how I make those
# rubygems deprecations go away!
#
# You'd be correct BUT using of this method in production code
# must be approved by the rubygems team itself!
#
# This is your warning. If you use this and don't have approval
# we can't protect you.
#
Deprecate.skip_during do
self.spec_dirs = *args
add_specs(*specs)
end
end
end
I guess the error occurs because the deprecate module is not loaded or something like that... I don't know ruby... but how can I try to correct it?
I have ruby 1.9.1p431 (2011-02-18 revision 30908) with gem 1.8.5
List of gems:
* LOCAL GEMS *
actionmailer (2.3.5) actionpack
(2.3.5) activerecord (2.3.8, 2.3.5)
activeresource (2.3.5) activesupport
(2.3.8, 2.3.5) acts-as-taggable-on
(2.0.6) builder (3.0.0) bundler
(1.0.15) chronic (0.3.0)
daemon_controller (0.2.6) daemons
(1.1.0) diff-lcs (1.1.2) echoe (4.3.1)
eventmachine (0.12.10)
exception_notification (1.0.20090728)
factory_girl (1.3.3) fastthread
(1.0.7) gemcutter (0.6.1) geoip
(0.8.9) hoe (2.8.0) json_pure (1.5.0)
mime-types (1.16) mocha (0.9.10) mysql
(2.8.1) oauth (0.4.4) paperclip
(2.2.9.2) passenger (3.0.7)
proxymachine (1.2.4) rack (1.0.1)
rails (2.3.5) rake (0.8.7) rdiscount
(1.3.1.1) revo-ssl_requirement (1.1.0)
riddle (1.2.2) rmagick (2.13.1)
ruby-hmac (0.4.0) ruby-openid (2.1.8)
ruby-yadis (0.3.4) rubyforge (2.0.4)
shoulda (2.9.2) state_machine (0.9.4)
stomp (1.1) stompserver (0.9.9) tuxml
(0.0.1) validates_url_format_of
(0.1.1) will_paginate (2.3.15)
Many thanks in advance.
Carlos.
Newer versions of Rubygems are deprecating some old internal methods. You can downgrade Rubygems with gem update --system 1.x.y (e.g. 1.5.2) to see if that solves your problem.
Deprecate was namespaced to Gem::Deprecate. You can temporary patch it:
Gem::Deprecate.skip_during do
self.spec_dirs = *args
add_specs(*specs)
end

Resources