新的 Rails 应用程序尝试在“捆绑安装”上使用 jruby当我期望它使用常规红宝石时,有错误吗?

发布于 2024-12-20 04:07:30 字数 3731 浏览 1 评论 0原文

我过去做过很多 Rails 和 ruby​​ 工作(使用 rvm,有许多不同类型的 ruby​​),但最近根本没有做过任何 ruby​​ 工作。我只是尝试制作一个新的 Rails 应用程序,以确保我的技能不会生疏,使用以下设置:

使用系统 ruby​​:

哪个 ruby​​:/usr/bin/ruby
ruby -v: ruby​​ 1.8.7 (2008-08-11> 补丁级别 72) [i586-linux]

rails -v:Rails 3.0.7

当我输入:rails new TestApp 时,我得到一个新的 Rails 应用程序,带有 Gemfile 和所有内容看起来不错。

在 TestApp 内部,当我运行时:

捆绑安装

我得到:

http://pastie.org/2986861

让我沮丧的是:

org/jruby/RubyArray.java:1671:in `each': Detected invalid array contents due to unsynchronized modifications with concurrent users (ConcurrencyError)
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/spec_set.rb:12:in `each'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:49:in `run'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:8:in `install'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/cli.rb:222:in `install'
from org/jruby/RubyObject.java:1334:in `send'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/task.rb:21:in `run'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/base.rb:389:in `start'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/bin/bundle:13:in `(root)'
from org/jruby/RubyKernel.java:1066:in `load'

这似乎意味着捆绑包正在使用jruby(并且在执行此操作时出错并且无法执行我的捆绑包安装)。

这里有什么明显的问题吗?我正在使用新的 Rails 应用程序中包含的默认 gem 文件...(可在此处找到:http://pastie.org/ 2986869

我上次做任何 Rails 工作时,一切都工作正常......但那是不久前的事了(几个月,也许将近一年?)。有什么我忘记了吗?

编辑:

哪个捆绑包:/home/jenny/bin/bundle which Rails: /home/jenny/bin/rails

我不相信自己现在正在使用 RVM,但只是为了确保我确保 rvm 指向系统 ruby​​(所以 rvm 或不,它应该是使用相同的东西)。

编辑:“rvm list”让我:

rvm列表

rvm红宝石

<前><代码>ruby-1.9.2-p136 [ i386 ]

jruby-1.3.1 [ i386-java ]

jruby-1.5.6 [ i386-java ]

ruby-1.9.2-p0 [i386]

ruby-1.9.2-rc1 [i386]

jruby-1.2.0 [i386-java]

jruby-1.6.1 [ linux-i386-java ]线程“main”中出现异常 java.lang.NoClassDefFoundError: org/jruby/Main 引起原因:java.lang.ClassNotFoundException:org.jruby.Main 在 java.net.URLClassLoader$1.run(URLClassLoader.java:217) 在 java.security.AccessController.doPrivileged(本机方法) 在 java.net.URLClassLoader.findClass(URLClassLoader.java:205) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:319) 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:264) 在 java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332) 找不到主类:org.jruby.Main。程序将退出。

jruby-head[]

jruby-1.6.2 [linux-i386-java]

jruby-1.4.0 [i386-java]

看起来也不太好......删除 jruby head 可以解决这个问题,但是我仍然有同样的捆绑问题。

编辑:删除所有 jruby rvm 具有相同的结果。因此,它的 RVM 看起来并没有把事情搞砸。输入 which jruby 会得到“/home/jenny/bin/jruby”。但是...通常情况下,如果我想使用 jruby,我必须指定它(例如 jruby Rails)...默认情况下,bundle 不应该使用它,对吗?

编辑(2012 年 1 月 9 日):更新我的捆绑程序给我带来了一条新的(非常相似)错误消息。特别是“并发错误,由于并发用户的修改不同步而导致无效的数组内容”与gem“多语言”。至少没有什么奇怪的地方。 (我还卸载了 rvm 中的所有内容并重新安装了所有内容,这似乎有所帮助,并且我将从这里开始使用 rvm)。卸载多语言并重新安装它根本没有帮助。

最后,我卸载了rvm,然后重新安装了它,卸载了我的系统ruby和我的系统jruby,并在rvm中只安装了ruby 1.9.2,一切正常。呼。

好吧,至少我解决了这个问题。现在我可以捆绑,但不能制作新模型?我想是时候提出一个新问题了。

I have done a lot of rails and ruby work in the past (using rvm, with many different types of rubies), but lately haven't done any ruby work at all. I just tried to make a new rails app to make sure my skills aren't rusty, using the following setup:

Using system ruby:

which ruby: /usr/bin/ruby
ruby -v: ruby 1.8.7 (2008-08-11> patchlevel 72) [i586-linux]

rails -v: Rails 3.0.7

when I type: rails new TestApp I get a new rails app, with a Gemfile and everything seems fine.

Inside of TestApp, when I run:

bundle install

I get:

http://pastie.org/2986861

What frustrates me is:

org/jruby/RubyArray.java:1671:in `each': Detected invalid array contents due to unsynchronized modifications with concurrent users (ConcurrencyError)
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/spec_set.rb:12:in `each'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:49:in `run'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:8:in `install'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/cli.rb:222:in `install'
from org/jruby/RubyObject.java:1334:in `send'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/task.rb:21:in `run'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/base.rb:389:in `start'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/bin/bundle:13:in `(root)'
from org/jruby/RubyKernel.java:1066:in `load'

Which seems to imply that the bundle is using jruby (and erroring while doing it and failing to do my bundle install).

Is there anything obviously wrong here? I'm using the default gem file included with the new rails app... (found here: http://pastie.org/2986869)

The last time I did any rails work, everything worked fine...but that was a while ago (months, maybe nearly a year?). Is there something I'm forgetting?

Edit:

which bundle: /home/jenny/bin/bundle
which rails: /home/jenny/bin/rails

I don't BELIEVE myself to be using RVM at the moment, but just to be sure I made sure that rvm was pointed to the system ruby (so rvm or no, it should be using the same things).

Edit: "rvm list" gets me:

rvm list

rvm rubies

ruby-1.9.2-p136 [ i386 ]

jruby-1.3.1 [ i386-java ]

jruby-1.5.6 [ i386-java ]

ruby-1.9.2-p0 [ i386 ]

ruby-1.9.2-rc1 [ i386 ]

jruby-1.2.0 [ i386-java ]

jruby-1.6.1 [ linux-i386-java ]Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main
Caused by: java.lang.ClassNotFoundException: org.jruby.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
Could not find the main class: org.jruby.Main. Program will exit.

jruby-head [ ]

jruby-1.6.2 [ linux-i386-java ]

jruby-1.4.0 [ i386-java ]

which doesn't look all that great, either...Deleting jruby head gets rid of that issue, but i still have the same bundle issue.

Edit: Deleting ALL jruby rvms has the same result. So, it doesn't LOOK like its RVM messing things up. Typing which jruby gets me "/home/jenny/bin/jruby". But...normally if I WANT to use jruby I have to specify it (jruby rails, for example)....bundle shouldn't be using it by default, right?

Edit (1/9/12): Updating my bundler gets me a new (very similar) error message. Specifically "Concurrency Error, invalid array contents due to unsynchronized modifications with concurrent users" with the gem "polyglot". At least no jruby weirdness. (I also uninstalled everything in rvm and reinstalled everything, which seemed to help, and am just gonna use rvm from here on out). Uninstalling polyglot and reinstalling it doesn't help at all.

In the end, I uninstalled rvm, then reinstalled it, uninstalled both my system ruby and my system jruby, and installed only ruby 1.9.2 in rvm and everything worked. Whew.

Well, at least I got through THAT problem. Now I can bundle, but not make new models? Time for a new question, I guess.

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

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

发布评论

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

评论(3

猥琐帝 2024-12-27 04:07:30

$HOME/bin 中的 bundle 来自哪里?它是指向 .rvm 目录树中某个文件的符号链接,还是一个脚本?如果是脚本,第一行(shebang)是什么?也许它设置为始终在 JRuby 中运行?

我以前见过这种“错误的 Ruby”事情发生过,要么是通过我想要的 Ruby 之前的 $PATH 中的某个可执行文件,要么是通过 RVM 直接进入杂草并安装宝石到了错误的地方。

如果是我的机器,我会尝试消除可能干扰我尝试运行的 (J)Ruby 的池,如下所示:

  1. Move ruby, jrubygembundle 以及任何其他与 Ruby 相关的可执行文件从我的 $HOME/bin 复制到备份目录,而不是在我的$PATH
  2. $HOME/.rvm 树重命名为不在我的 $PATH 上的名称。
  3. 重新安装新的 RVM 副本或 rbenv 并仅添加我需要的 Ruby 版本。

Where did the bundle in your $HOME/bin come from? Is it a symlink to a file in your .rvm directory tree somewhere, or is it a script? If it's a script, what's on the first (shebang) line? Perhaps it's set to always run in JRuby?

I've seen this kind of "wrong Ruby" thing happen before, either through an executable somewhere in my $PATH ahead of the Ruby I wanted, or through RVM just plain going off into the weeds and installing gems to the wrong place.

If it were my machine, I'd try to eliminate the pool of possible (J)Rubies that might be interfering with the one I'm trying to run, something like this:

  1. Move ruby, jruby, gem, bundle, and any other Ruby-related executables from my $HOME/bin to a backup directory not on my $PATH.
  2. Rename the $HOME/.rvm tree to something not on my $PATH.
  3. Reinstall a fresh copy RVM or rbenv and add just the versions of Ruby I need.
静赏你的温柔 2024-12-27 04:07:30

将 .rvmrc 文件添加到 Rails 目录,其中包含以下内容:

rvm ruby-1.9.2-p136

然后 cd ..,然后再次 cd 进入 Rails 应用程序。 (我建议升级到1.9.2-p290)

Add an .rvmrc file to the rails directory with the contents:

rvm ruby-1.9.2-p136

then cd .. and then cd into the rails app again. (I'd suggest upgrading to 1.9.2-p290)

朕就是辣么酷 2024-12-27 04:07:30

也许升级到最新的捆绑程序会有帮助?目前版本为 1.0.21。

您正在使用 1.0.13。

确保您的 1.8.7 ruby​​ 已安装它。

Maybe upgrading to latest bundler will help? its at 1.0.21 at the moment.

You are using 1.0.13.

Make sure that it is installed for your 1.8.7 ruby.

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