Repository navigation
Release 1.4.5
·
126 commits
to master
since this release
Immutable
release. Only release title and notes can be modified.
- Windows: detected DLLs are now also bundled into bin, next to ruby.exe, whenever they are not already resolvable from where they get packed. The Windows loader resolves a native extension's imports from the extension's own directory, ruby.exe's application directory (bin) plus its ruby_builtin_dlls SxS assembly, and the system directories - PATH is not consulted on hardened systems, and the AddDllDirectory route gems take through ruby_installer/runtime does not exist in a packed app. A DLL loaded from a gem's own tree (e.g. FreeTDS, which tiny_tds ships under ports/), from a devkit's msys64 tree inside the Ruby prefix, or from outside the prefix entirely was packed only at that original location, which the loader never searches, so the packaged application died at require time with a misleading LoadError on machines where a rich PATH did not mask the gap - the out-of-prefix case was skipped entirely by a guard that made its copy_to_bin branch unreachable. DLLs from the Windows directory keep coming from the target system and are never bundled. Companion DLLs found next to native extensions (e.g. libssl-3-x64.dll beside openssl.so in archdir) go into bin as well: a copy in archdir only helps extensions in archdir itself, while the same extension packed at a gem path (openssl and psych are gems since Ruby 3.x) resolves its imports from bin.
--cosmo-ruby: a native gem now also counts as provided by the payload when the payload can resolve the gem's primary feature, not only when the payload has a gemspec of that name. A gemspec is not what makes a library requirable - an extension linked into the APE, or a library in the interpreter's embedded stdlib, answersrequirewith nothing under /zip/lib/ruby/gems/*/specifications - so gems such as cgi and pathname (both compiled into CosmoRuby, and both ordinary native gems on Ruby 3.4+) were reported incompatible and refused builds that work. The probe runs the payload once using $LOAD_PATH.resolve_feature_path, which searches exactly as require does, built-in extensions included, but executes none of the code it finds.- A Rails application with SQLite now packages into a single Actually Portable Executable with
--cosmo-rubyalone (no compiler at all), given an interpreter with sqlite3, nokogiri, puma, nio4r, bigdecimal and racc linked in: 39.0 MB, serving its first request 1.8s after launch, against 50.4 MB and 1.5s for the same application as a native OCRAN executable, and with nothing unpacked at run time. test/test_rails.rb drives the same HTTP assertions - scaffold CRUD through SQLite with CSRF token and session cookie, dynamically added controllers, persistence across a restart - through both builds. The one remaining limitation is cryptographic and belongs to the interpreter: its openssl is an MbedTLS shim with no cipher, HMAC or PBKDF2 surface, and Rails names those at load time, so the application must fill the gap itself, set SECRET_KEY_BASE, ship no config/credentials.yml.enc, and keep the session out of the (encrypted) cookie. See the Rails section of README.md. - New
--chdir-exe-diroption (issue #32): the packaged executable starts the script with its working directory set to the directory containing the executable itself, so relative file access (e.g. reading data files placed next to the .exe) works regardless of how the executable is invoked. Implemented as a new CHDIR_TO_EXE_DIR (0x40) stub header flag; the stub passes-C <exe dir>to the packed Ruby interpreter. Mutually exclusive with--chdir-first. - README: document that
__FILE__/__dir__/$0point into the temporary extraction directory at runtime (the cause of issue #32) and show the supportedENV["OCRAN_EXECUTABLE"]pattern for locating files next to the executable. --gemfile <path>now governs the dependency run too, not just the Gemfile scan that follows it. The script is loaded inside the OCRAN process, so whatever BUNDLE_GEMFILE the environment carried used to win: running OCRAN from inside another project'sbundle execmade the script's ownrequire "bundler/setup"activate that project's bundle, and gems only the application's Gemfile provides went missing. Local development gems declared withpath:orgemspecalways did, since they exist nowhere but that Gemfile, so packaging them (issue #34) failed with a LoadError before anything could be packed. OCRAN now points BUNDLE_GEMFILE at the given Gemfile before loading the script, and when a different bundle has already been set up through RUBYOPT it drops Bundler's memoized state so the application's Gemfile is the one that takes effect.- Test suite: build and run steps assert through a new assert_system helper that captures the child's stdout and stderr and puts them in the failure message. A failing build used to report nothing but "Expected false to be truthy" while its diagnostics scrolled past in the runner's output.
--cosmo-ruby <ruby.com>now packages without any compiler when the given cosmopolitan Ruby runs an embedded /zip/main.rb (issue #26). Instead of compiling an APE launcher stub, OCRAN copies the interpreter and injects the application into the interpreter's own ZIP store, so the executable IS the interpreter: no cosmocc, no make, and nothing is unpacked at run time. Startup drops from 0.79s to 0.23s on Linux and from 1.52s to 0.49s on Windows for a 4-gem CLI, no temporary directory is created at all (so none can be leaked when the process is killed), and the executable is about twice as large because it cannot be LZMA-compressed. The mode is selected automatically ---cosmo-ruby <ruby.com>alone remains the whole command line - by detecting the capability in the binary; interpreters without it still get the launcher stub, and an explicit--cosmo <toolchain>(or --output-dir/--output-zip/--innosetup/--macosx-bundle) forces it. No new command line option.- Behavior differences of the ZIP packaging mode, documented in README: the application runs from inside the executable, so $0, FILE and dir point into /zip/ocran/src instead of a temporary directory (files shipping next to the executable are still found via OCRAN_EXECUTABLE, which is unchanged); --chdir-first changes into the executable's directory; of RUBYOPT only -I and -r can be replayed; --icon and --debug-extract have no effect.
- ZIP packaging now passes the whole command line to the application and reports exact exit codes, including on Windows, given a cosmopolitan Ruby with the 2026-08 interpreter fixes. Previously the interpreter parsed leading option-shaped arguments as its own ("app.com --verbose" failed with "invalid option --verbose", only "app.com -- --verbose" worked) and multiplied Windows exit codes by 256 ("exit 3" arrived as 768). Both were interpreter bugs that also affected plain "ruby.com script.rb"; "--" is now an ordinary argument and interpreter options are reachable through RUBYOPT.
- The APE launcher stub sets COSMORUBY_WAIT_STATUS_EXIT=1 for the packaged interpreter. The stub is itself a cosmopolitan program: it fork/execs the interpreter and reads the result with WEXITSTATUS(), so with the interpreter's Windows exit-code fix in place an unmarked child's "exit 3" came back as 131 (128 + signal 3). The variable asks the interpreter to keep cosmopolitan's wait-status encoding for this one caller; the stub still reports the plain status to its own native parent.
- New Ocran::ZipWriter: a minimal, dependency-free ZIP appender (Zlib only) used to inject the application into the APE without shelling out to the zip command, which Windows build hosts do not have. It rewrites the central directory in place, refuses ZIP64 and archives with trailing data, rejects entries that would shadow an existing member, and writes UNIX file-type bits in the external attributes - without S_IFREG/S_IFDIR the members are readable but Ruby's load refuses to open them and directory listings come back empty.
- New experimental
--cosmo <path>option (alias--cosmo-toolchain): build the launcher stub from its C sources with a Cosmopolitan Libc toolchain (cosmocc) at packaging time and package the application with the resulting Actually Portable Executable (APE) stub instead of the pre-built stub (issue #26).<path>is the cosmocc executable or the toolchain directory (containing bin/cosmocc). Console applications only (--windowsis rejected); requires make and a Linux/macOS build host. The default output name uses the.comextension (APE convention); an explicit--outputis used verbatim. Compiled stubs are cached in ~/.cache/ocran keyed on the toolchain and stub sources; compile errors surface the compiler output. - Ship the stub C sources (src/) in the binary platform gems so
--cosmocan rebuild the stub from an installed gem, not only from a source checkout. --cosmo-ruby <ruby.com>is a complete command line on its own: the cosmocc toolchain that builds the APE launcher stub is now discovered on the build host instead of having to be named with--cosmo(issue #26). Search order: the COSMOCC environment variable (the cosmocc executable or its install directory; a value that does not resolve is an error, not a silent fallback), cosmocc in PATH, then the conventional install locations ~/.cosmocc//bin/cosmocc, ~/cosmocc//bin/cosmocc, /opt/cosmocc/*/bin/cosmocc, /opt/cosmo/bin/cosmocc and /usr/local/cosmocc/bin/cosmocc (newest version first).--cosmo <path>remains an explicit override that always wins and still works on its own. When no toolchain is found, option parsing fails - before the dependency run - with a message naming the environment variable, PATH, the conventional locations, the download URL and the--cosmoflag.- New experimental
--cosmo-ruby <ruby.com>option: package a cosmopolitan-built Ruby APE as the bundled interpreter instead of the host Ruby, so the produced.comcontains both an APE stub and an APE Ruby and runs with no host-native code (issue #26). The payload's embedded stdlib (in its /zip store) is used at runtime instead of the host's, its embedded gem directory is appended to GEM_PATH, pure-Ruby gems are packed as usual, and native-extension gems are skipped when the payload provides them (json, psych, ...) or abort the build otherwise. The payload is validated by running it once on the build host; a warning is printed when host and payload Ruby versions differ. Verified end-to-end on Linux; console-only, POSIX build hosts only.