1

我是 Ruby/Rails/Spree 的新手,我正在尝试按照本教程创建一个简单的 spree 扩展。

我输入这个命令:

spree extension simple_sales

和 cd 进入spree_simple_sales

我现在在此目录中键入的任何 rails 命令(例如。rails -v)都会导致此错误:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': Unable to activate rails-3.2.4, because activesupport-4.0.0 conflicts with activesupport (= 3.2.14), actionpack-4.0.0 conflicts with actionpack (= 3.2.14), railties-4.0.0 conflicts with railties (= 3.2.14), activerecord-4.0.0 conflicts with activerecord (= 3.2.14), actionmailer-4.0.0 conflicts with actionmailer (= 3.2.14) (Gem::LoadError)
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:746:in `activate'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:780:in `block in activate_dependencies'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:766:in `each'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:750:in `activate'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:780:in `block in activate_dependencies'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:766:in `each'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:750:in `activate'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems.rb:212:in `rescue in try_activate'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems.rb:209:in `try_activate'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from D:/Dev/Tests and Tutorials/rails/extensions/spree_simple_sales/lib/spree_simple_sales/engine.rb:3:in `<class:Engine>'
    from D:/Dev/Tests and Tutorials/rails/extensions/spree_simple_sales/lib/spree_simple_sales/engine.rb:2:in `<module:SpreeSimpleSale>'
    from D:/Dev/Tests and Tutorials/rails/extensions/spree_simple_sales/lib/spree_simple_sales/engine.rb:1:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine/commands.rb:11:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from script/rails:7:in `<main>'

我能做些什么来解决这个问题?我在 Win 7 上,使用 RailsInstaller 安装 Ruby 1.9.3。我有 Rails 4.0.0 和 3.2.14,但我使用的是带有 Spree 的 Rails 3.2.14。

更新 我发现如果我bundle exec在 rails 命令前面添加例如。bundle exec rails -v它可以工作..但是任何没有bundle exec生成上述错误的rails命令..但是为什么?为什么这个问题只发生在spree extension生成的目录中?

4

1 回答 1

0

您的错误可能是因为您正在执行的 rails 命令是 Rails 4,而您在扩展中使用的 Gemfile 和/或 gemspec 指定了 rails 3.2.x(反之亦然)。

尝试使用以下命令运行相同的命令:

rails _3.2.4_ -v

在那个目录中。


另请注意,Rails 3.2.4 已经过时,存在多个安全漏洞。您应该尽快升级。

于 2013-08-18T05:25:34.890 回答