Rails 全新安装抛出 TypeError,指向 spring gem
Rails fresh install throws TypeError, points to spring gem
当我尝试从我的应用程序目录中使用 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 塞拉利昂 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]
- ruby宝石 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'
事实证明,问题出在我的工作目录路径中的文件夹名称。似乎文件夹名称中的空格导致了错误。
删除空格并将文件夹名称更改为:
/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/
一切都很完美。问题解决了。
当我尝试从我的应用程序目录中使用 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 塞拉利昂 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] - ruby宝石 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'
事实证明,问题出在我的工作目录路径中的文件夹名称。似乎文件夹名称中的空格导致了错误。
删除空格并将文件夹名称更改为:
/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/
一切都很完美。问题解决了。