简体   繁体   English

制作新的Rails应用程序时出错

[英]Error when making a new rails app

I got a problem. 我有问题 When I am trying to make a new rails project/app using the command: rails new app -d mysql or rails new app I get the error message below. 当我尝试使用以下命令创建新的Rails项目/应用程序时: rails new app -d mysqlrails new app,我收到以下错误消息。 My computer is running Windows 10, 64 bit and I am using the rails 4.2.4. 我的计算机运行的是Windows 10(64位),并且使用的是Rails 4.2.4。 If you need more information feel free to ask. 如果您需要更多信息,请随时询问。 (I have deleted my name so that is why you only see Documents\\Sider) (我已经删除了我的名字,所以这就是为什么您只看到Documents \\ Sider的原因)

Documents\Sider>rails new cmsw -d mysql
  create
  create  README.rdoc
  create  Rakefile
  create  config.ru
  create  .gitignore
  create  Gemfile
  create  app
  create  app/assets/javascripts/application.js
  create  app/assets/stylesheets/application.css
  create  app/controllers/application_controller.rb
  create  app/helpers/application_helper.rb
  create  app/views/layouts/application.html.erb
  create  app/assets/images/.keep
  create  app/mailers/.keep
  create  app/models/.keep
  create  app/controllers/concerns/.keep
  create  app/models/concerns/.keep
  create  bin
  create  bin/bundle
  create  bin/rails
  create  bin/rake
  create  bin/setup
  create  config
  create  config/routes.rb
  create  config/application.rb
  create  config/environment.rb
  create  config/secrets.yml
  create  config/environments
  create  config/environments/development.rb
  create  config/environments/production.rb
  create  config/environments/test.rb
  create  config/initializers
  create  config/initializers/assets.rb
  create  config/initializers/backtrace_silencers.rb
  create  config/initializers/cookies_serializer.rb
  create  config/initializers/filter_parameter_logging.rb
  create  config/initializers/inflections.rb
  create  config/initializers/mime_types.rb
  create  config/initializers/session_store.rb
  create  config/initializers/wrap_parameters.rb
  create  config/locales
  create  config/locales/en.yml
  create  config/boot.rb
  create  config/database.yml
  create  db
  create  db/seeds.rb
  create  lib
  create  lib/tasks
  create  lib/tasks/.keep
  create  lib/assets
  create  lib/assets/.keep
  create  log
  create  log/.keep
  create  public
  create  public/404.html
  create  public/422.html
  create  public/500.html
  create  public/favicon.ico
  create  public/robots.txt
  create  test/fixtures
  create  test/fixtures/.keep
  create  test/controllers
  create  test/controllers/.keep
  create  test/mailers
  create  test/mailers/.keep
  create  test/models
  create  test/models/.keep
  create  test/helpers
  create  test/helpers/.keep
  create  test/integration
  create  test/integration/.keep
  create  test/test_helper.rb
  create  tmp/cache
  create  tmp/cache/assets
  create  vendor/assets/javascripts
  create  vendor/assets/javascripts/.keep
  create  vendor/assets/stylesheets
  create  vendor/assets/stylesheets/.keep
     run  bundle install
C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rbreadline.rb:1097:in `<module:RbReadline>': HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory (RuntimeError)
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rbreadline.rb:17:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/readline.rb:10:in `<module:Readline>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/readline.rb:8:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb:2:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/vendor/thor/lib/thor/line_editor.rb:2:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/vendor/thor/lib/thor/base.rb:8:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/vendor/thor/lib/thor.rb:2:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/vendored_thor.rb:2:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:3:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/bin/bundle:17:in `<main>'

This is really one annoying fix if your reason was like mine: My first name included an extended ASCII charactor, "ø". 如果您的原因像我的一样,这确实是个烦人的解决方法:我的名字包括扩展的ASCII字符“ø”。 That one was used, when the computer setup my account on my PC. 当计算机在我的PC上设置我的帐户时,就使用了那个。 Eg c:\\users\\Bjørn. 例如c:\\ users \\Bjørn。

Fix: Rename the folder and your home account to Bjorn. 修复:将文件夹和您的家庭帐户重命名为Bjorn。

Create another admin account on you system, which you can use for renaming your account to c:\\users\\Bjorn\\ 在系统上创建另一个管理员帐户,该帐户可用于将帐户重命名为c:\\ users \\ Bjorn \\

Here is howto rename an account: https://superuser.com/questions/495290/how-to-rename-user-folder-in-windows-8 这是重命名帐户的方法: https : //superuser.com/questions/495290/how-to-rename-user-folder-in-windows-8

I would never have used an extended char in a username in the first place, but when I setup Win8 some years ago and was new to having a possibility to use a microsoft account, then the wizard chose the username. 首先,我永远不会在用户名中使用扩展字符,但是几年前当我设置Win8并开始使用Microsoft帐户时,向导就选择了用户名。

It seems that your environment variable is not set. 似乎您的环境变量未设置。 Please follow the link to set the variable: 请点击链接以设置变量:

NOTE: The Window is not recommended for the ruby on rails development. 注意:不建议将Window用于开发Rails的红宝石。 So I suggest Mac/Ubuntu for ROR. 因此,我建议Mac / Ubuntu进行ROR。 That will really make your life much easier 那将使您的生活更加轻松

I faced the same problem. 我遇到了同样的问题。 I did not find the exact solution, but found some workaround. 我没有找到确切的解决方案,但是找到了一些解决方法。 Actually Rails on Windows takes the environment variables not directly from Windows' environment variables but from the file: 实际上,Windows上的Rails并非直接从Windows的环境变量中而是从文件中获取环境变量:

C:\\RailsInstaller\\Git\\etc\\profile C:\\ RailsInstaller \\ Git \\ etc \\ profile

I created a folder C:\\Users\\Test and used its path it in C:\\RailsInstaller\\Git\\etc\\profile to replace the malfunctioning real homepath: 我创建了一个文件夹C:\\Users\\Test ,并将其路径用于C:\\RailsInstaller\\Git\\etc\\profile以替换出现故障的真实主路径:

HOME="C:/Users/Test" #added

# normalize HOME to unix path
HOME="$(cd "$HOME" ; pwd)"

After that the error "HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory (RuntimeError)" has gone. 之后,错误“必须设置HOME环境变量(或HOMEDRIVE和HOMEPATH)并指向目录(RuntimeError)”。

This might generally be a wrong decision but the real solution is somewhat alike. 通常这可能是一个错误的决定,但真正的解决方案有点相似。

In my case the problem is about the different encoding, my real homepath contains cyrillic characters and since they are not ASCII rbreadline.rb does not understand them - since some recent time. 在我的情况下,问题出在不同的编码上,我的真实归位路径包含西里尔字符,由于它们不是ASCII,rbreadline.rb从最近开始就不理解它们。 But earlier there was no such problem, I don't know what happened to make this encoding trouble appear. 但是以前没有这样的问题,我不知道是什么使这种编码问题出现了。

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

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