Getting a Rack GemNotFound with Sinatra

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?

    链接地址: http://www.djcxy.com/p/32538.html

    上一篇: SSH到Elastic Beanstalk实例

    下一篇: 使用Sinatra获得Rack GemNotFound