gpt4 book ai didi

ruby datamapper 不会加载

转载 作者:数据小太阳 更新时间:2023-10-29 07:01:21 26 4
gpt4 key购买 nike

我试图按照本教程学习 Sinatra ruby​​ 框架:

http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra-the-recall-app-2/

但是,在运行 gem 安装并在 test.rb 中编写一个简单的 sinatra 服务器后,如下所示:

require 'sinatra'
require 'datamapper'

get '/' do
"Hello, World!"
end

但是当我运行命令 ruby test.rb 时,出现以下错误:

/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- datamapper (LoadError)
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from datamapper_test.rb:2:in `<main>'
glenn@ubuntu:~/Dropbox/Repositories/sandbox/sinatra$ ruby datamapper_test.rb
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- datamapper (LoadError)
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from test.rb:3:in `<main>'

它似乎找不到数据映射器 gem。我该如何解决这个问题?

编辑:使用 ruby​​ 1.9.2

编辑(再次):gem list 的(部分)输出:

data_mapper (1.2.0)
data_objects (0.10.8)
datamapper (1.2.0)
devise (1.4.5)
directory_watcher (1.4.0)
dm-aggregates (1.2.0)
dm-constraints (1.2.0)
dm-core (1.2.0)
dm-do-adapter (1.2.0)
dm-migrations (1.2.0)
dm-serializer (1.2.1)
dm-sqlite-adapter (1.2.0)
d m-timestamps (1.2.0)
dm-transactions (1.2.0)
dm-types (1.2.1)
dm-validations (1.2.0)
do_sqlite3 (0.10.8)
sinatra (1.3.2, 1.2.6)
sqlite3 (1.3.5, 1.3.4)
sqlite3-ruby (1.3.3)

最佳答案

您需要需要'data_mapper',而不是datamapper

请注意,有一个 datamapper gem 和一个 data_mapper gem,但它们是相同的东西,只是名称不同。您需要使用 data_mapper 作为它们中的库名称。

据我所知,datamapperdata_mapper 的直接副本:

$ diff -r data_mapper-1.2.0/ datamapper-1.2.0/
diff -r data_mapper-1.2.0/Rakefile datamapper-1.2.0/Rakefile
21c21
< GEM_NAME = 'data_mapper'
---
> GEM_NAME = 'datamapper'

关于ruby datamapper 不会加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9368561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com