Skip to content

Commit 98e6146

Browse files
eregonansalond
authored andcommitted
Initialize $0 to a String as RubyGems expects it to
(cherry picked from commit 754db2b)
1 parent b6b3e80 commit 98e6146

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ Bug fixes:
88
* Temporary variables are no longer visible in the debugger.
99
* Setting breakpoints on some lines has been fixed.
1010
* The OpenSSL C extension is now always recompiled, fixing various bugs when using the extension (e.g., when using Bundler in TravisCI) (#1676, #1627, #1632).
11+
* Initialize `$0` when not run from the 'ruby' launcher, which is needed to `require` gems (#1653).
12+
13+
Compatibility:
14+
15+
* `do...end` blocks can now have `rescue/else/ensure` clauses like MRI (#1618).
16+
17+
# 1.0 RC 16, 19 April 2019
18+
Changes:
19+
20+
* `TruffleRuby.sulong?` has been replaced by `TruffleRuby.cexts?`, and `TruffleRuby.graal?` has been replaced by `TruffleRuby.jit?`. The old methods will continue to work for now, but will produce warnings, and will be removed at a future release.
1121

1222
# 1.0 RC 16
1323

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,10 @@ private void afterLoadCoreLibrary() {
849849
assert Layouts.CLASS.isClass(eagainWaitWritable);
850850

851851
findGlobalVariableStorage();
852+
853+
// Initialize $0 so it is set to a String as RubyGems expect, also when not run from the RubyLauncher
854+
DynamicObject dollarZeroValue = StringOperations.createString(context, StringOperations.encodeRope("-", USASCIIEncoding.INSTANCE, CodeRange.CR_7BIT));
855+
getContext().getCoreLibrary().getGlobalVariables().getStorage("$0").setValueInternal(dollarZeroValue);
852856
}
853857

854858
@TruffleBoundary

0 commit comments

Comments
 (0)