hpi-swa / trufflesqueak

A Squeak/Smalltalk VM and Polyglot Programming Environment for the GraalVM.
MIT License
286 stars 14 forks source link

Typing in a Rubby cell causes an Error #134

Closed jirir closed 3 years ago

jirir commented 3 years ago
  1. Open /Applications/graalvm/graalvm-ce-java11-20.2.0/Contents/Home/bin/trufflesqueak
  2. Open Polyglot notebook by clicking in the "PolyglotNotebook open" button
  3. Set the cell to Ruby
  4. Type a single character (i.e. 'a') in the cell. –> error appears: Error: org.truffleruby.language.control.RaiseException: cannot load such file -- rouge (LoadError)

Polyglot class(Object)>>error: Polyglot class>>signalPolyglotError Polyglot class>>primitive Eval:string:inInnerContext: Polyglot class>>eval:string: PolyglotTextStyler>>newRougueFormater PolyglotTextStyler>>formatter PolygloTextStyler>>style:language: PNBCodeCellEditor>>applyStyle MorphicAlarm(MesageSend)>>value MorphicAlarm>>value:

fniephaus commented 3 years ago

If you have Ruby installed, the notebook system currently requires rouge to be installed (bin/gem install rouge) for syntax highlighting. We should turn this into a soft dependency at some point and hint the user to install rouge somehow.

jirir commented 3 years ago

I did sudo gem install rogue from the Terminal but the error is still there. Perhaps rogue has to be installed somehow into the grallvm ..?

fniephaus commented 3 years ago

You must use the "gem" binaries that comes with installing TruffleRuby, which is right next to bin/trufflesqueak.

jirir commented 3 years ago

Even after /Applications/graalvm/graalvm-ce-java11-20.2.0/Contents/Home/bin/gem install rogue the error is still there.

The error appears also after typing into a Markdown cell. A message Initializing ruby for polyglot text styler appears shortly and then the error described above appears.

jirir commented 3 years ago

The TruffleSqueak standalone bundle would be a godsend👍🏻

fniephaus commented 3 years ago

Did you restart TruffleSqueak after installing the gem?

jirir commented 3 years ago

Yes. The TruffleSueak was restarted after installing the gem.

jirir commented 3 years ago

I removed everything and started from scratch. But now the rogue gem will not install because: <internal:core> core/kernel.rb:234:ingem_original_require': Library "/usr/lib/libSystem.B.dylib" does not exist. (RuntimeError)`

The process:

  1. Download grallvm, untar and copy graalvm-ce-java11-20.2.0 into /Applications/graalvm/
  2. sudo xattr -r -d com.apple.quarantine /Applications/graalvm/graalvm-ce-java11-20.2.0
  3. /Applications/graalvm/graalvm-ce-java11-20.2.0/Contents/Home/bin/gu -C https://raw.githubusercontent.com/hpi-swa/trufflesqueak/master/gu-catalog.properties install smalltalk
  4. /Applications/graalvm/graalvm-ce-java11-20.2.0/Contents/Home/bin/trufflesqueak
  5. Ok. The Squeak image is running and there are no problems with typing into the MarkDown cells.
  6. Close Squeak.
  7. /Applications/graalvm/graalvm-ce-java11-20.2.0/Contents/Home/bin/gu install ruby
  8. /Applications/graalvm/graalvm-ce-java11-20.2.0/Contents/Home/bin/gem install rogue
  9. Error: Could not find OpenSSL headers, install via Homebrew or MacPorts or set OPENSSL_PREFIX
  10. Install MacPorts from the Big Sur "pkg" installer
  11. sudo port -v selfupdate
  12. sudo port install openssl (it also installs zlib)
  13. Once more: /Applications/graalvm/graalvm-ce-java11-20.2.0/Contents/Home/bin/gem install rogue
  14. Error: <internal:core> core/kernel.rb:234:ingem_original_require': Library "/usr/lib/libSystem.B.dylib" does not exist. (RuntimeError)` (plus about 10 more lines ..)

So now it's ducked:-|

fniephaus commented 3 years ago

Sorry for the inconvenience. I'm afraid TruffleRuby 20.2.0 does not support macOS Big Sur, 21.0.0 does. We haven't done a TruffleSqueak release for 21.0.0 yet. But you can force-install TruffleSqueak on top of 21.0.0 via: bin/gu install -f -u https://github.com/hpi-swa/trufflesqueak/releases/download/20.2.0/trufflesqueak-installable-java11-darwin-amd64-20.2.0.jar

jirir commented 3 years ago

Ok :-)

  1. GraalVM 21.0.0 in /Applications/graalvm/graalvm-ce-java11-21.0.0

  2. sudo xattr -r -d com.apple.quarantine /Applications/graalvm/graalvm-ce-java11-21.0.0

  3. /Applications/graalvm/graalvm-ce-java11-21.0.0/Contents/Home/bin/gu install ruby

  4. /Applications/graalvm/graalvm-ce-java11-21.0.0/Contents/Home/bin/gem install rogue

  5. ERROR: Loading command: install (RuntimeError) you may need to install the system OpenSSL library libssl - see https://github.com/oracle/truffleruby/blob/master/doc/user/installing-libssl.md (dlopen(/usr/local/opt/openssl/lib/libssl.1.0.0.dylib, 2): image not found) ERROR: While executing gem ... (NoMethodError) undefined method `invoke_with_build_args' for nil:NilClass

  6. The reference (https://github.com/oracle/truffleruby/blob/master/doc/user/installing-libssl.md) says about openssl on macOS:

We recommend installing libssl via Homebrew. brew install openssl

MacPorts should also work but is not actively tested. sudo port install openssl

  1. I did sudo port install openssl before Step 1.

Note 1: There is /opt/local/lib/libssl.1.1.dylib on the Mac which looks rather different from the /usr/local/opt/openssl/lib/libssl.1.0.0.dylib mentioned in the error. I bet the /opt/local/lib/libssl.1.1.dylib was added by the sudo port install openssl.

Note 2: TruffleSqueak 20.2.0 (without TruffleRuby) works OK on top of the 21.0.0 GraalVM.

Ducked again it seems:-|

fniephaus commented 3 years ago

Hi @jirir, I believe the only step you've missed is to call the following right after installing TruffleRuby:

$GRAALVM_HOME/languages/ruby/lib/truffle/post_install_hook.sh

This step is mentioned in the post installation notice of TruffleRuby. It needs to relink against your local openssl installation to function properly.

Good to hear that TruffleSqueak 20.2.0 works on GraalVM 21.0.0!

jirir commented 3 years ago

Ok. Now gem install rogue complains about issuer certificates.

  1. $GRAALVM_HOME/languages/ruby/lib/truffle/post_install_hook.sh
  2. $GRAALVM_HOME/bin/gem install rogue

ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20) ERROR: You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store

Now how do I add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to my local trusted store ?

fniephaus commented 3 years ago

Mh interesting... maybe try reinstalling TruffleRuby (remove it via bin/gu remove ruby and install it again). Here are some additional information on libssl and TruffleRuby, but it seems sudo port install openssl should be supported.

As a workaround, you could also just disable rouge-based highlighting by changing PolyglotTextStyler>>style:language: to:

style: aText language: aLanguageID
    ^  aLanguageID = Polyglot languageIdSmalltalk
            ifTrue: [ (stStyler ifNil: [ stStyler := SHTextStylerST80 new ]) styledTextFor: aText ]
            ifFalse: [ aText ]
jirir commented 3 years ago

This is a genuine nightmare adventure:-o Giving up.

fniephaus commented 3 years ago

I'm sorry to hear that. If you have any additional feedback (apart from that you'd like a bundle), please let me know.

It may be too late, but I'll try to finalize the TruffleSqueak release for 21.0.0 tomorrow.

fniephaus commented 3 years ago

The 21.0.0 release is now available. I'm going to close this for now... please re-open if there's anything else I can help with.

jirir commented 3 years ago

With the PolyglotTextyler>>style:language: changed (actually syntax highligt turned off I guess) the 21.0.0 stack works. I hope I'll be finally able to try demos with ruby/python/smalltalk interchage.

fniephaus commented 3 years ago

Great! If you'd like to reproduce our polyglot notebook demo, have a look at the notes from our ECOOP20 Tutorial. And feel free to ask any questions, here, under discussions, or in the #trufflesqueak channel of the GraalVM Slack.

PS: I just noticed that the website layout of "https://2020.ecoop.org/people-index" recently changed, so you either need to adapt the notebook's code or change the url to point to the web archive (e.g. "https://web.archive.org/web/20201024115530/https://2020.ecoop.org/people-index").

jirir commented 3 years ago

Too early to hope:-|

  1. Do fresh 21.0.0 stack install
  2. Open TruffleSqueak
  3. Change PolyglotTextStyler>>style:language:

style: aText language: aLanguageID ^ aLanguageID = Polyglot languageIdSmalltalk ifTrue: [ (stStyler ifNil: [ stStyler := SHTextStylerST80 new ]) styledTextFor: aText ] ifFalse: [ aText ]

  1. Type something in a Markdown cell
  2. OK
  3. Save and Quit
  4. Open TruffleSqueak
  5. Type something in a Markdown cell
  6. Crash:

% /Applications/graalvm/graalvm-ce-java11-21.0.0/Contents/Home/languages/smalltalk/bin/trufflesqueak ; exit; [trufflesqueak] Running Squeak/Smalltalk on GraalVM CE... [trufflesqueak] Image loaded in 3148ms. ERROR: java.lang.NullPointerException org.graalvm.polyglot.PolyglotException: java.lang.NullPointerException at java.base/java.util.Objects.requireNonNull(Objects.java:221) at de.hpi.swa.trufflesqueak.nodes.context.frame.FrameStackReadNode.create(FrameStackReadNode.java:44) at de.hpi.swa.trufflesqueak.nodes.bytecodes.PushBytecodes$PushTemporaryLocationNode.executeVoid(PushBytecodes.java:581) at de.hpi.swa.trufflesqueak.nodes.ExecuteBytecodeNode.interpretBytecode(ExecuteBytecodeNode.java:134) at de.hpi.swa.trufflesqueak.nodes.ExecuteBytecodeNode.execute(ExecuteBytecodeNode.java:70) at de.hpi.swa.trufflesqueak.nodes.StartContextRootNode.execute(StartContextRootNode.java:54) at PolyglotTextStyler>>style:language:(Unknown) at PNBCodeCellEditor>>applyStyle(PNBCodeCellEditor>>applyStyle:10:213-242) at MessageSend>>value(MessageSend>>value:14:262-298) at MorphicAlarm>>value:(MorphicAlarm>>value::22:415-433) at [] in WorldState>>triggerAlarmsBefore:([] in WorldState>>triggerAlarmsBefore::3:38-56) at SequenceableCollection>>do:(SequenceableCollection>>do::14:244-263) at WorldState>>triggerAlarmsBefore:(WorldState>>triggerAlarmsBefore::32:733-749) at WorldState>>runLocalStepMethodsIn:(WorldState>>runLocalStepMethodsIn::10:246-280) at WorldState>>runStepMethodsIn:(WorldState>>runStepMethodsIn::33:717-753) at PasteUpMorph>>runStepMethods(PasteUpMorph>>runStepMethods:3:33-63) at WorldState>>doOneCycleNowFor:(WorldState>>doOneCycleNowFor::23:605-633) at CTX WorldState>>doOneCycleFor: @69ba3f4e(WorldState>>doOneCycleFor::12:264-295)

... about 240 lines of error messages.

fniephaus commented 3 years ago

Thanks for reporting the crash, I will try to reproduce and address the crash. In the meantime, please try again without changing PolyglotTextStyler>>style:language: (ensure that rouge is installed: bin/gem install rouge).

jirir commented 3 years ago

Cannot get rogue installed:-/ It complains about SSL:

ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20) ERROR: You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store

I thought I would ignore the complaining rogue using the PolyglotTextStyler>>style:language: modification and get to the demo :-)

fniephaus commented 3 years ago

At this point, I'm afraid I can only make two suggestions:

1) Option

According to this,

MacPorts should also work but is not actively tested.

Is there any way you could install openssl via homebrew? I've been using homebrew and have never seen the error you reported. It may be a good idea to open an issue against TruffleRuby. It seems there are many issues with openssl.

2) Option

Unzip TruffleSqueakImage-21.0.0-rouge-disabled.zip) and replace the two files in $GRAALVM_HOME/Contents/Home/languages/smalltalk/resources/. The zip contains the 21.0.0 image/changes with rouge disabled. I only created it using an OpenSmalltalkVM (there may be a bug in the image saving logic of TruffleSqueak).

fniephaus commented 3 years ago

ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20) ERROR: You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store

According to @eregon, this doesn't seem like a TruffleRuby issue, but an issue with your OpenSSL installation. You may be able to install rouge via http, not https (this is obviously insecure and only a workaround):

bin/gem install rouge --source http://rubygems.org
fniephaus commented 3 years ago

To check if it's an issue with your OpenSSL installation, you could run:

openssl s_client -connect rubygems.org:443

and see whether there are any verification issues.

eregon commented 3 years ago

Note that the above should use the MacPorts openssl, so something like:

/opt/local/bin/openssl s_client -connect rubygems.org:443

It seems clear that your MacPorts openssl is missing certificates, please fix that, otherwise nothing on the system using MacPorts openssl will work.

eregon commented 3 years ago

Updating SSL Certificates with MacPorts from http://railsapps.github.io/openssl-certificate-verify-failed.html might be helpful to fix it.