蛋白石看起来很棒!!!当我尝试在两个不同的Windows 7和Windows 10系统上要求“ opal-jquery”时,出现相同的“找不到所需文件”错误:
C:\opaltest>node --version
v10.15.3
C:\opaltest>ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x64-mingw32]
C:\opaltest>gem list -a opal
*** LOCAL GEMS ***
opal (0.11.4)
opal-jquery (0.4.3)
文件test.js.rb由以下三行组成:
require 'opal'
require 'opal-jquery'
puts 'success'
C:\opaltest>opal -c test.js.rb > test.js
Traceback (most recent call last):
12: from C:/Ruby/Ruby250-1-x64/bin/opal:23:in `<main>'
11: from C:/Ruby/Ruby250-1-x64/bin/opal:23:in `load'
10: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/exe/opal:24:in `<top (required)>'
9: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/cli.rb:65:in `run'
8: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/cli.rb:87:in `builder'
7: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/cli.rb:116:in `create_builder'
6: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/cli.rb:156:in `evals_or_file'
5: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/cli.rb:116:in `block in create_builder'
4: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/builder.rb:89:in `build_str'
3: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/builder.rb:89:in `map'
2: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/builder.rb:89:in `block in build_str'
1: from C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/builder.rb:189:in `process_require'
C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib/opal/builder.rb:174:in `read': A file required by "test.js.rb" wasn't found. (Opal::Builder::MissingRequire)
can't find file: "opal-jquery" in:
- C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/opal
- C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/stdlib
- C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/opal-0.11.4/lib
- C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/ast-2.4.0/lib
- C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/ast-2.4.0/lib
- C:/Ruby/Ruby250-1-x64/lib/ruby/gems/2.5.0/gems/parser-2.3.3.1/lib
With the following extensions:
- .js
- .js.js
- .rb
- .js.rb
- .opal
- .js.opal
- .opalerb
- .js.opalerb
- .erb
- .js.erb
And the following processors:
- Opal::BuilderProcessors::JsProcessor
- Opal::BuilderProcessors::RubyProcessor
- Opal::BuilderProcessors::OpalERBProcessor
- Opal::BuilderProcessors::ERBProcessor
存在文件opal-jquery.rb:
C:\Ruby\Ruby250-1-x64\lib\ruby\gems\2.5.0\gems\opal-jquery-0.4.3\lib\opal-jquery.rb
但错误消息指示未搜索到包含该文件的目录。
如果我删除要求的“ opal-jquery”行以创建2行文件test_without_jquery.js.rb,则它起作用:
require 'opal'
puts 'success'
C:\opaltest>opal -c test_without_jquery.js.rb > test_without_jquery.js
C:\opaltest>node test_without_jquery.js
success
同时运行ruby的require语句可以正常工作
C:\opaltest>ruby test.js.rb
success
在opal进行编译时,我使用了Process Monitor实用程序来监视所有文件访问。 ruby可执行文件读取opal-jquery-0.4.3.gemspec文件,但从未尝试打开任何其他opal-jquery文件。显然,gemspec中的某些原因导致了此错误,但唯一的运行时依赖项是opal <0.12.0,> = 0.10.0,应由0.11.4满足。
我在Ubuntu 16.04,蛋白石0.11.4,蛋白石jquery 0.4.3上看到完全相同的“未找到“ test.js.rb”所需的文件”错误, ruby 2.3.1p112(2016-04-26修订版54768)[x86_64-linux]
非常感谢您的协助。谢谢!!!
答案 0 :(得分:1)
您需要先在红宝石土地中要求opal-jquery
或手动将opal-jquery的文件夹附加到由opal检查的文件夹:
如果要通过CLI进行操作,可以使用RUBYOPT:
export RUBYOPT="-ropal-jquery"
opal -c test.js.rb > test.js