我一直在尝试使Rails环境正常运行。我最初在Win 7上与XAMPP一起安装了Rails 5.2.0以及ruby 2.5.1p57(2018-03-29修订版63029)[x64-mingw32]。我创建了一个新的演示应用程序,并移植了一个现有的应用程序。启动服务器和mysql之后,我将尝试启动Rails服务器并不断出错。我注意到Win 7中需要大量更新,并且不断进行更新并重试,但是始终出现相同的错误。最终,在有人指出这是操作系统问题,而Win8 / 10对此做得更好之后,我忍无可忍并升级到Win10。不幸的是,我仍然遇到同样的错误。
有人可以给我一些如何前进的指导吗?谢谢
此错误是由于尝试为新创建的原始演示应用程序启动服务器而导致的。我根本没有修改任何文件。
C:\demo>rails s
Traceback (most recent call last):
43: from bin/rails:4:in `<main>'
42: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
41: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
40: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
39: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
38: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
37: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
36: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
35: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
34: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<top (required)>'
33: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
32: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
31: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
30: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
29: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
28: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'
27: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'
26: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:145:in `block in perform'
25: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
24: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
23: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
22: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
21: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
20: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
19: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
18: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
17: from C:/demo/config/application.rb:7:in `<top (required)>'
16: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler.rb:114:in `require'
15: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:65:in `require'
14: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:65:in `each'
13: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:76:in `block in require'
12: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:76:in `each'
11: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
10: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
9: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
8: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
7: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
答案 0 :(得分:1)
当您期望Rails
应用使用sqlite
时,您的MySQL
应用似乎使用了config/database.yml
数据库。您需要重新配置它:
将您的development:
adapter: mysql2
database: your_app_name_dev
username: user
password:
host: localhost
socket: /tmp/mysql.sock
更改为以下内容:
mysql2
并将Gemfile
宝石放入您的gem 'mysql2'
中:
public ListenableFuture<StompSession> connect() {
List<Transport> transports = new ArrayList<>(2);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
transports.add(new RestTemplateXhrTransport());
SockJsClient sockJsClient = new SockJsClient(transports);
sockJsClient.setMessageCodec(new Jackson2SockJsMessageCodec());
WebSocketStompClient stompClient = new WebSocketStompClient(sockJsClient);
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
headers.add("x-user-id", "5B59F68B7B7811E88C3E52964BF487E4");
return stompClient.connect(socket_url, headers, new StompSessionHandlerAdapter() {});
}