jruby 上的 Cucumber-rails 使用捆绑器将 gem 安装到我的应用程序根目录中

发布于 2024-08-31 17:29:01 字数 2410 浏览 7 评论 0原文

刚刚在 OSX 上安装了 cucumber 0.7.2cucumber-rails 0.3.1 以及 jruby-1.4.0。当我运行捆绑安装时,它会在我的主应用程序中放置一个 cucumber-rails 目录,其中包含所有 gem 代码/依赖项。

首先,这绝对不是我想要的,我不确定为什么这种情况只发生在黄瓜导轨上。

其次,如果我删除此文件夹并仅手动安装 cucumber-rails,当我运行 script/generate feature blah 时,我会得到

/Users/bradrobertson/.rvm/rubies/jruby-1.4.0/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:344:in `refresh!': source index not created from disk (RuntimeError)
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/vendor_gem_source_index.rb:34:in `refresh!'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/vendor_gem_source_index.rb:29:in `initialize'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/gem_dependency.rb:21:in `new'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:298:in `add_gem_load_paths'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:132:in `process'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
    from /Users/bradrobertson/Repos/app/source/trunk/config/environment.rb:13
    from /Users/bradrobertson/Repos/app/source/trunk/config/environment.rb:1:in `require'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/commands/generate.rb:1
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/commands/generate.rb:3:in `require'
    from script/generate:3

同样的运行 rake cucumber ,

rake aborted!
source index not created from disk

所以显然有些东西不会不工作。如果我重新添加 cucumber-rails 目录,那么我的 rake cucumber 就会实际运行。

有人能告诉我为什么需要在我的 Rails 应用程序中安装 gem 吗?我以前从未见过这个。

设置
jruby-1.4.0
黄瓜-0.7.2
黄瓜导轨 0.3.1
捆绑器 0.9.23
webrat 0.7.1

编辑

要添加到这一点,我决定我厌倦了尝试让它工作,所以我从我的 Gemfile 中删除了所有黄瓜/黄瓜轨道 deps 并重新运行 bundle install< /代码>。它仍然创建 cucumber-rails 目录,此外,除非该目录存在,否则我无法运行任何内容(rake 等...),否则我会收到 source index not create from disk 消息。

编辑2 我刚刚注意到我的 Rails.root/.bundle/configBUNDLE_PATH: cucumber-rails。有谁知道为什么会出现这种情况?

Just installed cucumber 0.7.2 and cucumber-rails 0.3.1 with jruby-1.4.0 on OSX. When I run a bundle install, it places a cucumber-rails directory in my main app with all of the gem code/dependencies.

First off, this is definitely not what I want and I'm not sure why this happens for cucumber-rails only.

Second, if I delete this folder and just manually install cucumber-rails, when I run script/generate feature blah I get

/Users/bradrobertson/.rvm/rubies/jruby-1.4.0/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:344:in `refresh!': source index not created from disk (RuntimeError)
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/vendor_gem_source_index.rb:34:in `refresh!'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/vendor_gem_source_index.rb:29:in `initialize'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/gem_dependency.rb:21:in `new'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:298:in `add_gem_load_paths'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:132:in `process'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
    from /Users/bradrobertson/Repos/app/source/trunk/config/environment.rb:13
    from /Users/bradrobertson/Repos/app/source/trunk/config/environment.rb:1:in `require'
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/commands/generate.rb:1
    from /Users/bradrobertson/.rvm/gems/jruby-1.4.0/gems/rails-2.3.5/lib/commands/generate.rb:3:in `require'
    from script/generate:3

Similarly running rake cucumber I get

rake aborted!
source index not created from disk

So something obviously doesn't work. If I add that cucumber-rails directory back in, then my rake cucumber actually runs.

Can someone tell me why it would need to install the gem right in my rails app? I've never seen this before.

setup
jruby-1.4.0
cucumber-0.7.2
cucumber-rails 0.3.1
bundler 0.9.23
webrat 0.7.1

EDIT

To add to this, I decided I was sick of trying to get this to work so I removed all cucumber / cucumber-rails deps from my Gemfile and reran bundle install. It still creates the cucumber-rails directory and furthermore, I can't run anything unless that directory is present, (rake etc...) otherwise I get the source index not created from disk message.

EDIT2
I just noticed that my Rails.root/.bundle/config has BUNDLE_PATH: cucumber-rails. Does anyone have any idea why this would be there?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心房的律动 2024-09-07 17:29:01

这与您使用捆绑器安装东西的方式有关。

你可能做了类似的事情:

bundle install cucumber-rails

如果你这样做,这个捆绑器会假设你想要供应你的捆绑包
位于项目内的此目录中。

你的.bundle/config
可能应该只包含:


BUNDLE_DISABLE_SHARED_GEMS: "1"

通过删除此文件夹,您实际上是在删除您的捆绑包。

只需像上面那样更改它,然后运行:

bundle install。

This has got to do with the way you are installing stuff with bundler.

you probably did something like:

bundle install cucumber-rails

If you do this bundler assumes you want to vendor your bundle
in this directory inside your project.

your .bundle/config
should probably just contain:


BUNDLE_DISABLE_SHARED_GEMS: "1"

By deleting this folder you are in fact deleting your bundle.

Just change this as above, and run:

bundle install.

清引 2024-09-07 17:29:01

我能够获得一个使用以下 gem 运行的从头开始的应用程序:

$ jruby -S gem list

*** LOCAL GEMS ***

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activerecord-jdbc-adapter (0.9.6)
activeresource (2.3.5)
activesupport (2.3.5)
builder (2.1.2)
bundler (0.9.25)
cucumber (0.7.2)
cucumber-rails (0.3.1)
database_cleaner (0.5.2)
diff-lcs (1.1.2)
gherkin (1.0.24)
jdbc-sqlite3 (3.6.3.054)
jruby-openssl (0.7)
json_pure (1.4.3)
nokogiri (1.4.1)
rack (1.0.1)
rack-test (0.5.3)
rails (2.3.5)
rake (0.8.7)
term-ansicolor (1.0.5)
trollop (1.16.2)
webrat (0.7.1)

我必须升级到 Bundler 0.9.25,并且按照此处的说明将 Bundler 与 Rails 2 一起使用:

http://gembundler.com/rails23.html

这是我的 Gemfile 的外观:

source :gemcutter
gem "rails", "~> 2.3.5"
gem 'activerecord-jdbc-adapter', :require => false
gem 'jdbc-sqlite3', :require => false

group :development do
end

group :test do
  gem 'cucumber-rails'
  gem 'webrat'
  gem 'database_cleaner'
end

I was able to get a from-scratch application running with the following gems:

$ jruby -S gem list

*** LOCAL GEMS ***

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activerecord-jdbc-adapter (0.9.6)
activeresource (2.3.5)
activesupport (2.3.5)
builder (2.1.2)
bundler (0.9.25)
cucumber (0.7.2)
cucumber-rails (0.3.1)
database_cleaner (0.5.2)
diff-lcs (1.1.2)
gherkin (1.0.24)
jdbc-sqlite3 (3.6.3.054)
jruby-openssl (0.7)
json_pure (1.4.3)
nokogiri (1.4.1)
rack (1.0.1)
rack-test (0.5.3)
rails (2.3.5)
rake (0.8.7)
term-ansicolor (1.0.5)
trollop (1.16.2)
webrat (0.7.1)

I had to upgrade to Bundler 0.9.25 and I followed the instructions here for using Bundler with Rails 2:

http://gembundler.com/rails23.html

Here's how my Gemfile looked:

source :gemcutter
gem "rails", "~> 2.3.5"
gem 'activerecord-jdbc-adapter', :require => false
gem 'jdbc-sqlite3', :require => false

group :development do
end

group :test do
  gem 'cucumber-rails'
  gem 'webrat'
  gem 'database_cleaner'
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文