2017-05-07 31 views
0

Ruby on Railsアプリケーションの問題を過去2.5日間解決しています。オンラインでリソースを使い、ここでstackoverflowを使っているので、私は進歩しましたが、まだ問題を解決していません。LoadError:そのようなファイルをロードできません - roo

不意打ち:Railsアプリケーションにroo gemやスプレッドシートの宝石を読み込むことができません。

簡単なスクリプトを実行してスプレッドシートから読み込んだデータを端末に出力するために、IRB端末のスプレッドシートの宝箱をうまく使用しました。これは、gemが正しくインストールされ、正しく機能していることを示します。

しかし、Railsはこれら2つの宝石を認識したくないようです。これは、依存関係のバージョンと開発の依存関係を適切に構成しようとする多くの試みの後に行われます。

マイようこそコントローラ:

class WelcomeController < ApplicationController 
    require 'roo' 

    def index 
     puts "Hello Rails!" 
    end 
end 

マイGemfile

source 'https://rubygems.org' 

git_source(:github) do |repo_name| 
    repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 
    "https://github.com/#{repo_name}.git" 
end 


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '~> 4.2.8' 
# Use sqlite3 as the database for Active Record 
gem 'sqlite3' 
# Use Puma as the app server 
gem 'puma', '~> 3.0' 
# Use SCSS for stylesheets 
gem 'sass-rails', '~> 5.0' 
# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 
# Use CoffeeScript for .coffee assets and views 
gem 'coffee-rails', '~> 4.2' 
# See https://github.com/rails/execjs#readme for more supported runtimes 
# gem 'therubyracer', platforms: :ruby 

# Use jquery as the JavaScript library 
gem 'jquery-rails' 
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 
gem 'turbolinks', '~> 5' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 2.5' 
# Use Redis adapter to run Action Cable in production 
# gem 'redis', '~> 3.0' 
# Use ActiveModel has_secure_password 
# gem 'bcrypt', '~> 3.1.7' 

# Use Capistrano for deployment 
# gem 'capistrano-rails', group: :development 

group :development, :test do 
    # Call 'byebug' anywhere in the code to stop execution and get a  debugger console 
    gem 'byebug', platform: :mri 
end 

group :development do 
    # Access an IRB console on exception pages or by using <%= console %>  anywhere in the code. 
    gem 'web-console', '>= 3.3.0' 
    gem 'listen', '~> 3.0.5' 
    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 
    gem 'spring' 
    gem 'spring-watcher-listen', '~> 2.0.0' 
end 

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 

gem 'minitest', '~> 5.4' 

gem 'rack', '~> 1.6' 

gem 'nokogiri' 

gem 'ruby-ole' 

gem 'hoe', '~> 3.14' 

gem 'rdoc', '~> 4.0' 

gem 'roo', '2.7.0' 

gem 'spreadsheet', '1.1.0' 

マイroo.gemspecファイル:

# encoding: utf-8 
lib = File.expand_path('../lib', __FILE__) 
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 
require 'roo/version' 

Gem::Specification.new do |spec| 
    spec.name   = 'roo' 
    spec.version  = Roo::VERSION 
    spec.authors  = ['Thomas Preymesser', 'Hugh McGowan', 'Ben Woosley', 'Oleksandr Simonov', 'Steven Daniels'] 
    spec.email   = ['[email protected]', '[email protected]'] 
    spec.summary  = 'Roo can access the contents of various spreadsheet files.' 
    spec.description = "Roo can access the contents of various spreadsheet files. It can handle\n* OpenOffice\n* Excelx\n* LibreOffice\n* CSV" 
    spec.homepage  = 'http://github.com/roo-rb/roo' 
    spec.license  = 'MIT' 

    spec.files   = `git ls-files -z`.split("\x0") 
    spec.files.reject! { |fn| fn.include?('test/files') } 
    spec.require_paths = ['lib'] 

    spec.add_dependency 'nokogiri', '~> 1' 
    spec.add_dependency 'rubyzip', '~> 1.1', '< 2.0.0' 

    spec.add_development_dependency 'rake', '~> 10.1' 
    spec.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3' 
    spec.add_development_dependency 'rack', '~> 1.6', '< 2.0.0' 
end 

私はspec.require_paths変数を変更するには、ファイルを編集してみました次のようになります。

spec.require_paths = ['lib/roo'] 

しかし、私はカンガルーの宝石に

>> bundle update 
>> bundle install 

私のパスを実行した後、何の成功はなかった:

/var/lib/gems/2.3.0/gems/roo-2.7.0/ 

私はLXLEのLinux、Lubuntu誘導体を実行しているし。

私はこれらの質問で見つかったソリューションを試みたが、何も私のために働くように思わない:

Ruby roo LoadError: cannot load such file -- spreadsheet/note

cannot load such file -- sqlite3/sqlite3_native (LoadError) on ruby on rails

私はRubyGemsの上のマニュアルに従って正しく私の依存関係を設定しているように思え.org。

誰もこのような問題はありましたか?私はここ数日、この問題を見てきたので、重要なことを何かに掘り下げているかもしれないので、それを書いて、それが助けになると思った。私は今日それに数時間を費やしています。あなたがチェックすることができ

+0

これがあることが可能ですRails 3対Rails 5のことです。新しいRails 5プロジェクトを作成し、 'roo'で読み込んでも期待通りに動作しますか? – tadman

+0

Hey tadman - 私はRails 5.0.2プロジェクトを使い始めましたが、Railsのバージョンを使用しているときに、バンドルのいくつかの依存関係について不平を言っていました。たぶん私はちょうどクリーンなプロジェクトが必要です - 私はあなたの提案をお試しください。ありがとう – Nathan

+0

Rubyの現在のバージョンを実行している新しいプロジェクトで再現性のある問題が発生した場合は、問題を提出したいかもしれませんが、それ以前にはさまざまな組み合わせを試してみてください。あなたはそれを修正できることを願っています! – tadman

答えて

0

2つのこと:

  • gemset:宝石はあなたが
  • ルビーバージョンであるのと同じgemsetにインストールされていることを確認してください:宝石は同じルビーバージョンにインストールされていることを確認してくださいあなたが使っているように。

チェックするには、プロジェクトディレクトリから「gem list」を実行して、宝石がリストされているかどうかを確認します。

同じgemsetに、あなたが使用することができない場合は、次の

rvm use gemset_name 

ではなく、同じルビーバージョンでは、Rubyのバージョンを使用するように設定した場合、例2.3.3

rvm use 2.3.3 
関連する問題