我已经能够使用sinatra在本地运行我的应用程序,但是当我将它推送到heroku时,我不断收到此错误:
/app/lib/initializers/twitter.rb:1:in `require': cannot load such file -- Twitter
我授权自己在初始化文件中使用twitter gem。
APP_ROOT = File.dirname(__FILE__)
require 'sinatra'
require 'json'
require File.join(APP_ROOT,"lib","bot")
require './lib/bot'
get '/' do
File.read(File.join( APP_ROOT, 'index.html'))
end
require 'Twitter'
$client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV["CONSUMER_KEY"]
config.consumer_secret = ENV["CONSUMER_SECRET"]
config.access_token = ENV["ACCESS_TOKEN"]
config.access_token_secret = ENV["ACCESS_TOKEN_SECRET"]
end
ruby '2.3.1'
source 'https://rubygems.org'
gem 'rack'
gem 'twitter'
gem 'sinatra'
gem "sinatra-activerecord"
gem 'thin'
gem 'json'
require './lib/initializers/secrets'
require './lib/initializers/twitter'
require './init'
run Sinatra::Application
即使是rake任务,我仍然在本地获得以下错误:
LoadError: cannot load such file -- active_record/railties/databases.rake
/Users/sahil/.rvm/gems/ruby-2.3.1/gems/sinatra-activerecord-2.0.11/lib/sinatra/activerecord/rake.rb:1:in `load'
/Users/sahil/.rvm/gems/ruby-2.3.1/gems/sinatra-activerecord-2.0.11/lib/sinatra/activerecord/rake.rb:1:in `<top (required)>'
/Users/sahil/Documents/work/practice/twitter_bot/Rakefile:2:in `<top (required)>'
/Users/sahil/.rvm/gems/ruby-2.3.1/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/Users/sahil/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
/Users/sahil/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
LoadError: cannot load such file -- sinatra/activerecord/rake
/Users/sahil/Documents/work/practice/twitter_bot/Rakefile:2:in `<top (required)>'
/Users/sahil/.rvm/gems/ruby-2.3.1/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/Users/sahil/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
/Users/sahil/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
require "./lib/bot"
require "sinatra/activerecord/rake"
Dir.glob('lib/tasks/*.rake').each { |r| load r}
require './../bot'
desc "This task is called by the Heroku scheduler add-on"
task :fav_tweets => :environment do
bot = Bot.new
end
如何在我的本地运行调度程序,以便我可以将它添加到heroku?
答案 0 :(得分:1)
您似乎正在投放:
require 'Twitter'
注意大写T
。如果你改为运行它是否有效:
require 'twitter'
看起来您的本地计算机正在运行OS X,它通常使用不区分大小写的HFS +文件系统。
Heroku在Linux系统上运行,Linux系统通常使用区分大小写的文件系统。