如何在Windows上让项目使用JRuby代替Ruby [英] How to get project to use JRuby instead of Ruby on Windows

查看:67
本文介绍了如何在Windows上让项目使用JRuby代替Ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows VM上建立一个JRuby/Ruby-on-Rails环境.结果,我安装了Ruby,Rails和 RailsInstaller 下载中的项目.然后,我安装了 JRuby .一切都已安装,当我执行jruby -vruby -v时都看到了.

I'm trying to stand up a JRuby/Ruby-on-Rails environment on a Windows VM. As a result, I installed Ruby, Rails and the items from the RailsInstaller download. I then installed JRuby. Everything installed and I see both when I do jruby -v and ruby -v.

我如何使我的Rails项目识别JRuby而不是Ruby?我可以不安装RVM来实现吗?我应该只在Windows VM上安装RVM(我试图避免,但是我不应该这样做)吗?我只在Gemfile中放一行吗?

How do I get my Rails project to recognize JRuby instead of Ruby? Can I achieve this without installing RVM? Should I just install RVM on the Windows VM (which I was trying to avoid, but, maybe I shouldn't)? Do I just put a line in the Gemfile?

(我对JRuby/Ruby-on-Rails的有限经验是在Unix环境中使用RVM.)

(My very limited experience with JRuby/Ruby-on-Rails is with using RVM on a Unix environment.)

这是我执行gem env时的输出:

RubyGems Environment:
 - RUBYGEMS VERSION: 2.1.9
 - RUBY VERSION: 1.9.3 (2014-09-25 patchlevel 392) [java]
 - INSTALLATION DIRECTORY: C:/jruby-1.7.16/lib/ruby/gems/shared
 - RUBY EXECUTABLE: C:/jruby-1.7.16/bin/jruby.exe
 - EXECUTABLE DIRECTORY: C:/jruby-1.7.16/bin
 - SPEC CACHE DIRECTORY: C:/Users/user/.gem/specs
 - RUBYGEMS PLATFORMS:
   - ruby
   - universal-java-1.7
 - GEM PATHS:
    - C:/jruby-1.7.16/lib/ruby/gems/shared
    - C:/Users/user/.gem/jruby/1.9
 - GEM CONFIGURATION:
    - :update_sources => true
    - :verbose => true
    - :backtrace => false
    - :bulk_threshold => 1000
    - "install" => "--no-rdoc --no-ri --env-shebang"
    - "update" => "--no-rdoc --no-ri --env-shebang"
 - REMOTE SOURCES:
    - https://rubygems.org/
 - SHELL PATH:
    - C:\Windows\system32
    - C:\Windows
    - C:\Windows\System32\Wbem
    - C:\Windows\System32\WindowsPowerShell\v1.0\
    - c:\jruby-1.7.16\bin
    - C:\RailsInstaller\Git\cmd
    - C:\RailsInstaller\Ruby1.9.3\bin
    - C:\Program Files\jruby-1.7.16\bin

推荐答案

Rails是一个gem,由Rubygems安装在Ruby安装程序中,该程序是Ruby发行版的一部分.路径设置是通过gem命令来自Ruby而不是来自JRuby来进行设置的.您可以暂时从路径中删除所有Ruby命令,只要JRuby的命令在路径中,它将自动选择这些命令.

Rails is a gem and it's installed within a Ruby installation by Rubygems, which is part of a Ruby distribution. Your path setting are set in the way, that the gem command is coming from Ruby and not from JRuby. You can remove all Ruby commands temporarily from your path, and as long as JRuby's commands are on the path it will automatically pick those.

通过执行gem install bundlerbundle install,您将使用JRuby安装Rails和所有项目依赖项.

By doing gem install bundler and bundle install you then will install Rails and all the project dependencies with JRuby.

但是,版本管理器实际上就是这样做的.他们只是正确地切换了路径设置.使用它们可以大大简化开发环境的配置.而且,对于Windows,有 pik (RVM仅在Unix系统上有效).

However, that's what version managers actually do. They just switch the path settings properly. Using them simplifies the configuration of an development environment a lot. And, for Windows there is pik (RVM works only on Unix systems).

这篇关于如何在Windows上让项目使用JRuby代替Ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆