简体   繁体   English

尝试使Rails服务器在Windows命令提示符下运行时出错

[英]Error trying to get rails server running in windows command prompt

I've been developing a (very simple) Rails project and have moved the files to a new machine. 我一直在开发一个(非常简单的)Rails项目,并将文件移到新机器上。 I have Ruby (version 2.0.0p195) and Rails (4.0.0) installed. 我安装了Ruby(版本2.0.0p195)和Rails(版本4.0.0)。 From the C:\\Sites directory in command prompt (console), when I type 'rails server' I get a whole bunch of information that starts with: 从命令提示符下的C:\\ Sites目录(控制台),当我键入“ rails server”时,我会获得一堆以以下内容开头的信息:

Usage:
rails new APP_PATH [options]
...

...and continues with Options:, Runtime options:, Rails options: and so on. ...并继续执行选项:,运行时选项:,Rails选项:等等。
When I cd to the directory of my copied project: 当我进入复制项目的目录时:
C:\\Sites\\elearning C:\\网站\\网络学习
and try 'rails server' I get the following error: 并尝试“ rails server”,我得到以下错误:

'mri_21' is not a valid platform. The available options are: [:ruby, :ruby_18, :ruby_19, :ruby_20, :mri, :mri_18, :mri_19, :mri_20, :rbx, :jruby, :mswim, :mingw, :mingw_18, :mingw_19, :mingw_20]

Does anyone know what I'm doing wrong? 有人知道我在做什么错吗? Is it possible to copy a rails project from another computer? 是否可以从另一台计算机复制Rails项目? And if so, how would I do that? 如果是这样,我该怎么做?

Any help, much appreciated. 任何帮助,不胜感激。

Edit: 编辑:

FYI, my gemfile is as follows: 仅供参考,我的gemfile如下:

source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.1.5'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'spring',        group: :development
gem 'bootstrap-sass'
gem 'devise'
gem 'sqlite3'
gem 'thin'
group :development do
  gem 'better_errors'
  gem 'binding_of_caller', :platforms=>[:mri_21]
  gem 'quiet_assets'
  gem 'rails_layout'
  gem 'byebug'
end

For those trying to transfer a mac project to PC: I've finally got rails server running. 对于那些试图将Mac项目转移到PC的用户:我终于运行了Rails服务器。

First, in the gem file, I changed the reference 'mri_21' to 'mri_20' and changed the ruby version number to match my version of ruby. 首先,在gem文件中,我将引用“ mri_21”更改为“ mri_20”,并更改了ruby版本号以匹配我的ruby版本。

I had other errors, but the short story is that I created a new rails project, copied MOST of the old project files into the corresponding files of the new project and EVENTUALLY noticed the comment at the bottom of the new (freshly created) routes.rb file: 我还有其他错误,但总而言之,我创建了一个新的Rails项目,将旧项目文件的MOST复制到了新项目的相应文件中,并在新(新创建)路线的底部注意到了该注释。 rb文件:

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem

So I added: 所以我补充说:

gem 'tzinfo-data', platforms: [:mingw, :mswin]

and all is, for now, right with the world. 就目前而言,一切都与世界接轨。

So, if you're transferring a mac project to PC, you'll need to add the tzinfo-data gem to your gemfile. 因此,如果要将Mac项目传输到PC,则需要将tzinfo-data gem添加到gemfile中。

尝试运行“ gem更新捆绑程序”,看看是否可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM