Skip to content

Commit

Permalink
Merge pull request #115 from eregon/gu_install_js
Browse files Browse the repository at this point in the history
GraalVM 22.2+ needs `gu install js` for JavaScript to be available
  • Loading branch information
byroot authored Jul 8, 2022
2 parents 5a5d36a + 19b1e4f commit 82dbb78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
- name: Set TRUFFLERUBYOPT
run: echo "TRUFFLERUBYOPT=--jvm --polyglot" >> $GITHUB_ENV
if: startsWith(matrix.ruby, 'truffleruby+graalvm')
- name: Install GraalVM js component
run: if ! gu list | grep '^js '; then gu install js; fi
if: startsWith(matrix.ruby, 'truffleruby+graalvm')

- name: Run test
run: rake
- name: Install gem
Expand Down
7 changes: 5 additions & 2 deletions lib/execjs/graaljs_runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def call(source, *args)
def translate
convert_js_to_ruby yield
rescue ForeignException => e
if e.message.start_with?('SyntaxError:')
if e.message && e.message.start_with?('SyntaxError:')
error_class = ExecJS::RuntimeError
else
error_class = ExecJS::ProgramError
Expand Down Expand Up @@ -96,8 +96,10 @@ def convert_js_to_ruby(value)

def convert_ruby_to_js(value)
case value
when nil, true, false, Integer, Float, String
when nil, true, false, Integer, Float
value
when String
Truffle::Interop.as_truffle_string value
when Symbol
value.to_s
when Array
Expand Down Expand Up @@ -136,6 +138,7 @@ def available?

unless Polyglot.languages.include? "js"
warn "The language 'js' is not available, you likely need to `export TRUFFLERUBYOPT='--jvm --polyglot'`", uplevel: 0 if $VERBOSE
warn "You also need to install the 'js' component with 'gu install js' on GraalVM 22.2+", uplevel: 0 if $VERBOSE
warn "Note that you need TruffleRuby+GraalVM and not just the TruffleRuby standalone to use #{self.class}", uplevel: 0 if $VERBOSE
return @available = false
end
Expand Down

0 comments on commit 82dbb78

Please sign in to comment.