在MacOS上以100%CPU运行的VS Code进程“ ruby​​”:如何解决?

时间:2018-12-20 08:23:03

标签: visual-studio-code

为我的Ruby on Rails开发项目运行Visual Studio Code时,有一个“红宝石”进程不断以几乎100%的CPU运行,这使我的粉丝发疯了。在活动监视器中查看该进程的打开文件和端口,看来这是由于某些进程(node_modules.asar?)扫描数据引起的目录(my_project/public/system/**):

cwd
/Users/pascal/projects/RoR/my_project
txt
/Users/pascal/.rbenv/versions/2.4.4/bin/ruby
txt
/usr/local/Cellar/gmp/6.1.2_2/lib/libgmp.10.dylib
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/encdb.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/trans/transdb.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/stringio.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/etc.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/digest/sha1.bundle
txt
/usr/local/Cellar/openssl/1.0.2o_2/lib/libcrypto.1.0.0.dylib
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/digest.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/openssl.bundle
txt
/usr/local/Cellar/openssl/1.0.2o_2/lib/libssl.1.0.0.dylib
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/io/nonblock.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/io/console.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/zlib.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/socket.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/io/wait.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/windows_31j.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/json-2.1.0/lib/json/ext/parser.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/json-2.1.0/lib/json/ext/generator.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/ripper.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/cgi/escape.bundle
txt
/Library/Preferences/Logging/.plist-cache.KjBd2ZgB
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/readline.bundle
txt
/usr/local/Cellar/readline/7.0.3_1/lib/libreadline.7.0.dylib
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/date_core.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/psych.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/strscan.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/utf_16le.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/utf_16be.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/racc/cparse.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/enc/trans/single_byte.bundle
txt
/Users/pascal/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.5/lib/nokogiri/nokogiri.bundle
txt
/usr/local/Cellar/xz/5.2.4/lib/liblzma.5.dylib
txt
/usr/lib/dyld
0
->(none)
1
->(none)
2
->(none)
3
->0xebb30f785d0d6639
4
->0xebb30f785d0d4fb9
5
->0xebb30f785d0d70b9
6
->0xebb30f785d0d7b39
7
/dev/null
8
->0xebb30f785d0d7bf9
9
->0xebb30f785d0d6e79
10
localhost:59701
11
localhost:59701->localhost:59702
12
[ctl com.apple.netsrc id 9 unit 64]
13
->0xebb30f7867f30159
14
192.168.10.31:59810->151.101.0.70:https
15
/Users/pascal/projects/RoR/my_project
16
/Users/pascal/projects/RoR/my_project/public
17
/Users/pascal/projects/RoR/my_project/public/system
18
/Users/pascal/projects/RoR/my_project/public/system/dragonfly
19
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test
20
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images
21
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662
22
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017
23
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12
24
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12/08
25
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12/08/13
26
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12/08/13/11
27
/Users/pascal/projects/RoR/my_project/public/system/dragonfly/test/images/662/2017/12/08/13/11/27
36
/dev/ptmx
38
/private/var/folders/fn/wjmjy_xj1vv2n8lhfcsjb3480000gn/T/com.microsoft.VSCode.ShipIt.3TPnSs1E/Visual Studio Code.app/Contents/Resources/app/node_modules.asar

我希望某些exclude folders设置可以解决此问题,但是我找不到任何相关设置。还是有其他解决方案?

1 个答案:

答案 0 :(得分:0)

原来是由Solargraph宝石引起的。根据作者的this explanationexclude文件中此gem的.solargraph.yml设置不能很好地工作。相反,应该使用更具体的include设置。就我而言,我将- **/*.rb用作单个包含设置。我现在将其更改为:

include:
- app/**/*.rb
- db/migrate/**/*.rb
- db/seeds/**/*.rb
- config/**/*.rb
- lib/**/*.rb 
- spec/**/*.rb 

从那时起,红宝石的加工似乎就被驯服了。