Ruby LoadError:无法加载此类文件--omniauth twitter

Ruby LoadError:无法加载此类文件--omniauth twitter,ruby,sinatra,oauth-2.0,omniauth,twitter-oauth,Ruby,Sinatra,Oauth 2.0,Omniauth,Twitter Oauth,我正试图通过OmniAuth让OAuth2为我的Sinatra应用程序工作,但收到: LoadError: cannot load such file -- omniauth-twitter 我遵循这些示例,尽管它们有点不一致 - app.rb - Sinatra配方告诉我将构建器放在“configure do”中,而官方示例没有,但有“use Rack::Session::Cookie” 我已经在网上搜索了好的Sinatra OmniAuth示例,但它似乎更倾向于Rails requ

我正试图通过OmniAuth让OAuth2为我的Sinatra应用程序工作,但收到:

LoadError: cannot load such file -- omniauth-twitter

我遵循这些示例,尽管它们有点不一致
- app.rb
-

Sinatra配方告诉我将构建器放在“configure do”中,而官方示例没有,但有“use Rack::Session::Cookie”

我已经在网上搜索了好的Sinatra OmniAuth示例,但它似乎更倾向于Rails

require "omniauth"
require "omniauth-twitter"

# OAuth2 configuration
use Rack::Session::Cookie
use OmniAuth::Builder do
  provider :twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'
end

before do
# we do not want to redirect to twitter when the path info starts
# with /auth/
  pass if request.path_info =~ /^\/auth\//

# /auth/twitter is captured by omniauth:
# when the path info matches /auth/twitter, omniauth will redirect to twitter
  redirect to('/auth/twitter') unless current_user
end

get '/auth/twitter/callback' do
# probably you will need to create a user in the database too...
  session[:uid] = env['omniauth.auth']['uid']
# this is the main endpoint to your application
  redirect to('/')
end

get '/twitter' do
  erb "<a href='/auth/twitter'>Sign in with Twitter</a>"
end

# Support for OAuth failure
  get '/auth/failure' do
  flash[:notice] = params[:message] # if using sinatra-flash or rack-flash
  redirect '/'
end
需要“omniauth”
需要“omniauth twitter”
#OAuth2配置
使用Rack::Session::Cookie
使用OmniAuth::Builder do
提供者:twitter、“消费者密钥”、“消费者秘密”
结束
在做之前
#我们不希望在路径信息启动时重定向到twitter
#使用/auth/
如果请求,则传递。路径\信息=~/^\/auth\//
#/auth/twitter由omniauth捕获:
#当路径信息匹配/auth/twitter时,omniauth将重定向到twitter
重定向到('/auth/twitter'),除非当前用户
结束
获取“/auth/twitter/callback”do
#可能您还需要在数据库中创建一个用户。。。
会话[:uid]=env['omniauth.auth']['uid']
#这是应用程序的主要端点
重定向到(“/”)
结束
获取“/twitter”do
雇员再培训局“
结束
#对OAuth失败的支持
获取“/auth/failure”do
闪存[:注意]=参数[:消息]#如果使用sinatra闪存或机架闪存
重定向“/”
结束

我得到的全部错误

Boot Error
Something went wrong while loading config.ru
LoadError: cannot load such file -- omniauth-twitter    /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/Users/chadsakonchick/Projects/restlessnapkin/app.rb:11:in `<top (required)>'
config.ru:1:in `require'
config.ru:1:in `block in inner_app'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `inner_app'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in `inner_app'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:102:in `assemble_app'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:86:in `proceed_as_child'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:31:in `call!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/favicon.rb:12:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
启动错误
加载config.ru时出错
LoadError:无法加载这样的文件--omniauth twitter/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active\u support/dependencies.rb:251:在'require'中
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_-support/dependencies.rb:251:in'block in require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active\u support/dependencies.rb:236:in'load\u dependency'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active\u support/dependencies.rb:251:in'require'
/Users/chadsakonchick/Projects/nappin/app.rb:11:in`'
config.ru:1:in'require'
config.ru:1:in`block in internal_app'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.5.2/lib/rack/builder.rb:55:in'instance_eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.5.2/lib/rack/builder.rb:55:in'initialize'
config.ru:1:in'new'
config.ru:1:in'internal_app'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in'eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:112:在“内部应用程序”中
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:102:in'assembly_app'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:86:“作为孩子继续”
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:31:in'call!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in'call'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/shotgun-0.9/lib/shotgun/favicon.rb:12:in'call'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.5.2/lib/rack/builder.rb:138:in'call'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:在“服务”中
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in'service'
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in'run'
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in'block in start_thread'

看起来好像没有安装omniauth twitter gem。例如:

> require "blahblahblah"
LoadError: cannot load such file -- blahblahblah

您需要
gem安装omniauth twitter
,如果您正在使用bundler,请将其包含在您的gemspec中,或者在您的项目中有意义的任何内容。

看起来omniauth twitter gem没有安装。例如:

> require "blahblahblah"
LoadError: cannot load such file -- blahblahblah

您需要
gem安装omniauth twitter
,如果您正在使用bundler,请将其包含在您的gemspec中,或者在您的项目中使用任何有意义的东西。

散弹枪是罪魁祸首。当我从终端运行“ruby app.rb”时工作正常,但使用shotgun时,我收到了错误。

shotgun是罪魁祸首。当我从终端运行“ruby app.rb”时工作正常,但使用shotgun时,我收到了错误。

安装了omniauth twitter gem。它是否安装在正确的rvm中?它的文件在
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/
我发现了,是鸟枪造成的。当我从终端运行“ruby app.rb”时工作正常,但使用shotgun时,我收到了错误。安装了omniauth twitter gem。它是否安装在正确的rvm中?它的文件在
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/
我发现了,是鸟枪造成的。当我从终端运行“ruby app.rb”时工作正常,但使用shotgun时,我收到了错误。