[英]LoadError: cannot load such file — roo
在過去的2.5天里,我一直在排除Ruby on Rails應用程序中的問題。 在線使用資源,然后在stackoverflow上使用資源,我已經取得了進步,但是仍然沒有解決問題。
難題:我無法將roo gem或電子表格gem加載到我的Rails應用程序中。
我已經成功地使用了IRB終端中的電子表格gem來執行一個簡單的腳本,並將從電子表格中讀取的數據輸出到終端。 這表明該寶石已正確安裝並且可以正常運行。
盡管如此,Rails似乎並不想識別這兩個寶石。 這是在多次嘗試正確配置依賴項版本和開發依賴項之后進行的。
我的歡迎控制器:
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 = ['ruby.ruby.ruby.roo@gmail.com', 'oleksandr@simonov.me']
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
我通往roo gem的道路:
/var/lib/gems/2.3.0/gems/roo-2.7.0/
我正在運行Lubuntu衍生產品LXLE Linux。
我嘗試了以下問題的解決方案,但似乎沒有任何效果:
Ruby Roo LoadError:無法加載此類文件-電子表格/注釋
無法加載此類文件-Raillite上的ruby上的sqlite3 / sqlite3_native(LoadError)
似乎我已經根據rubygems.org上的文檔正確設置了依賴項。
有人遇到過這樣的問題嗎? 最近幾天,我一直在關注這個問題,所以也許我正在掩蓋重要的事情,所以我認為編寫並詢問有關問題將有所幫助。 我今天還要花幾個小時。
您可以檢查兩件事:
要進行檢查,請從您的項目目錄中執行“ gem list”,然后查看是否列出了gem。
如果不在同一個gemset中,則可以使用:
rvm use gemset_name
如果不是同一Ruby版本,則將其設置為使用Ruby版本,例如2.3.3。
rvm use 2.3.3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.