【问题标题】:Rails fresh install throws TypeError, points to spring gemRails全新安装抛出TypeError,指向spring gem
【发布时间】:2017-11-21 23:48:50
【问题描述】:

当我尝试从我的应用程序目录中使用 rails 命令时,我不断收到以下错误:

/Users/useraccount/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load': no implicit conversion of nil into String (TypeError)

这就是我到达那里的方式......

安装和更新所有必要的软件后,我开始进行以下配置:

  • Mac OS Sierra 10.12.5
  • xcode 8.3.3
  • Rails 5.1.1
  • ruby 2.4.1p111(2017-03-22 修订版 58053)[x86_64-darwin16] ruby 2.4.0p0(2016-12-24 修订版 57164)[x86_64-darwin16]
  • rubygem 2.6.12
  • 自制 1.2.3
  • Homebrew/homebrew-core(git 修订版 ab5ba7;最后一次提交 2017-06-19)

我进入我的项目文件夹并运行以下内容:

$ rails new testapp
...output omitted...
$ cd testapp
$ rails s

这就是我得到 TypeError 的地方。如果我运行rails -v,它会给我同样的错误。


这是完整的跟踪:

/Users/useraccount/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load': no implicit conversion of nil into String (TypeError)
    from /Users/useraccount/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
    from /Users/useraccount/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
    from /Users/useraccount/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
    from /Users/useraccount/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
    from /Users/useraccount/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
    from /Users/useraccount/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
    from /Users/useraccount/Google Drive Family/code/Rails/12-Week-Challenge/Week_0 [Dry Run]/testapp/bin/spring:15:in `require'
    from /Users/useraccount/Google Drive Family/code/Rails/12-Week-Challenge/Week_0 [Dry Run]/testapp/bin/spring:15:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

更新 1:

我将 ruby​​ 从 2.4.0 升级到 2.4.1,但完全相同的问题仍然存在。

/Users/brianjason/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load': no implicit conversion of nil into String (TypeError)

更新 2:

当我在 Gemfile 中注释掉 spring 时,应用程序运行时没有错误:

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  #gem 'spring'
  #gem 'spring-watcher-listen', '~> 2.0.0'
end

然后我尝试继续开发应用程序。 我按照rails getting started guide

第 4 节中概述的步骤进行操作

这是我尝试运行应用程序时得到的结果:

ActionView::Template::Error (bad URI(is not URI?): file:///Users/useraccount/Google%20Drive%20Family/code/Rails/12-Week-Challenge/Week_0%20[Dry%20Run]/testapp/app/assets/stylesheets/application.css?type=text/css&pipeline=debug):
    4:     <title>Testapp</title>
    5:     <%= csrf_meta_tags %>
    6:
    7:     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    8:     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    9:   </head>
   10:

app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___42966888540102183_70217709639480'

【问题讨论】:

  • 你是如何安装 Ruby 的?你用的是 RVM 还是 RBENV?
  • RVM。我正在使用最新的稳定版本。
  • 你试过gem uninstall rails然后重新安装了吗?
  • 还可以尝试使用 Ruby 2.3.4 或 Ruby 2.4.1 的当前稳定版本。这些可以在这里找到ruby-lang.org/en/downloads
  • 我会尝试不同版本的 Ruby。您使用的是 2.4.0p0,Rails 和 Ruby 2.4.0 存在一些问题。

标签: ruby-on-rails ruby ruby-on-rails-5.1


【解决方案1】:

事实证明,问题在于我的工作目录路径中的文件夹名称。似乎文件夹名称中的空格导致了错误。

一旦我删除了空格并将文件夹名称更改为:

/Users/useraccount/Google Drive Family/code/Rails/12-Week-Challenge/Week_0 [Dry Run]/testapp/

到:

/Users/useraccount/Google_Drive_Family/code/Rails/12-Week-Challenge/Week_0_DryRun/testapp/

一切都很完美。问题解决了。

【讨论】:

    猜你喜欢
    • 2016-07-08
    • 2013-12-27
    • 2023-03-19
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    • 2020-12-11
    • 1970-01-01
    • 2013-05-21
    相关资源
    最近更新 更多