[ruby-talk:443099] How to pack and distribute ruby software to users with no ruby environment?

I can write some CLI softwares in ruby(for example a curricular scheduler), and run them on my own computer. However when distributing them to other computers, They don’t have a ruby environment, some even aren’t connected to internet. So I had to rewrite it in C++,compile it, and distribute it in binary form.(maybe now I would do the same in crystal)

Is there a way to pack the ruby interpreter, required gems, and source code into a single executable file, so users can simply execute it within one click? There is PyInstaller for python to do that job, I’m wondering for an equivalent in Ruby.
从 Windows 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986&gt;发送

See:
https://phusion.github.io/traveling-ruby/

···

On 11/1/22 11:33, 王 卓强 wrote:

and distribute it in binary form.(maybe now I would do the same in crystal)

Is there a way to pack the ruby interpreter, required gems, and source code into a single executable file, so users can simply execute it within one click? There is PyInstaller for python to do that job, I’m wondering for an equivalent in Ruby.

Other than traveling-ruby and ruby-packer:

I've used mruby to compile a few small, simple utilities (custom Nagios
plugins):

For systems with Java, I have packaged some utilities as jar files:

I've never used it, but Glimmer has a packaging option that uses warbler
and jpackage to create DMG/PKG, MSI/EXE, and/or DEB/RPM packages (again
depending on a Java runtime on the target):

···

On 11/1/22, 王 卓强 <HOMODELUNA@outlook.com> wrote:

I can write some CLI softwares in ruby(for example a curricular scheduler),
and run them on my own computer. However when distributing them to other
computers, They don’t have a ruby environment, some even aren’t connected to
internet. ...

a unique Ruby implementation, compiled to C++ (WIP):

$ cat examples/hello.rb
puts 'hello world'

$ bin/natalie examples/hello.rb -c hello
$ ./hello
hello world

$ ls -lh hello
-rwxr-xr-x 1 user user 19M Nov 1 15:01 hello
$ file hello
hello: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
BuildID[sha1]=c298736e605dcebaf676bb363fad3f092e93c9ea, for GNU/Linux
3.2.0, with debug_info, not stripped
$ ldd hello
  linux-vdso.so.1 (0x00007fff78dc1000)
  libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007a1aee57e000)
  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007a1aee43a000)
  libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007a1aee420000)
  libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007a1aee3fe000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007a1aee239000)
  /lib64/ld-linux-x86-64.so.2 (0x00007a1aeeaa7000)

···

On 11/1/22, 王 卓强 <HOMODELUNA@outlook.com> wrote:

I can write some CLI softwares in ruby(for example a curricular scheduler),
and run them on my own computer. However when distributing them to other
computers, They don’t have a ruby environment, some even aren’t connected to
internet. So I had to rewrite it in C++,compile it, and distribute it in
binary form.

If the system has Java, I agree that JRuby is a good option (assuming you don't use native gems). I wrote a post here on how to package Ruby scripts into JAR files at this page: JRuby on Windows: Day 2 - Creating Executable JARS

It's part of my series of posts on JRuby all of which are linked from the write-up on Why JRuby here: Why we like to use JRuby

Best Regards,
Mohit.

···

On 2022-11-1 11:27 pm, Frank J. Cameron wrote:

On 11/1/22, 王 卓强 <HOMODELUNA@outlook.com> wrote:

I can write some CLI softwares in ruby(for example a curricular scheduler),
and run them on my own computer. However when distributing them to other
computers, They don’t have a ruby environment, some even aren’t connected to
internet. ...

Other than traveling-ruby and ruby-packer:

I've used mruby to compile a few small, simple utilities (custom Nagios
plugins):

GitHub - hone/mruby-cli: mruby-cli is a platform to build native command line applications for Linux, Windows, and OS X. It provides the tools necessary for building a standalone binary of your application from any machine. Take advantage of the power of Ruby without the cross-platform dependency headaches that go with it.

For systems with Java, I have packaged some utilities as jar files:

GitHub - jruby/warbler: Warbler chirpily constructs .war files of your Ruby applications.

I've never used it, but Glimmer has a packaging option that uses warbler
and jpackage to create DMG/PKG, MSI/EXE, and/or DEB/RPM packages (again
depending on a Java runtime on the target):

glimmer-dsl-swt/GLIMMER_PACKAGING_AND_DISTRIBUTION.md at master · AndyObtiva/glimmer-dsl-swt · GitHub

I've never used it, but Glimmer has a packaging option that uses warbler
and jpackage to create DMG/PKG, MSI/EXE, and/or DEB/RPM packages (again
depending on a Java runtime on the target):

Glimmer DSL for SWT packaging does not depend on a Java runtime on the
target. It actually packages the JRE too (Java Runtime Environment), so
when users install the app, all of Java, JRuby, and Ruby Gems are
automatically installed on their machine into the application directory,
and the users won't even know that Java or JRuby were installed when
launching the app. They'll just think they're launching a native
application.

···

On Wed, Nov 2, 2022 at 4:13 AM Mohit Sindhwani <mo_mail@onghu.com> wrote:

On 2022-11-1 11:27 pm, Frank J. Cameron wrote:
> On 11/1/22, 王 卓强 <HOMODELUNA@outlook.com> wrote:
>> I can write some CLI softwares in ruby(for example a curricular
scheduler),
>> and run them on my own computer. However when distributing them to other
>> computers, They don’t have a ruby environment, some even aren’t
connected to
>> internet. ...
> Other than traveling-ruby and ruby-packer:
>
> I've used mruby to compile a few small, simple utilities (custom Nagios
> plugins):
>
> GitHub - hone/mruby-cli: mruby-cli is a platform to build native command line applications for Linux, Windows, and OS X. It provides the tools necessary for building a standalone binary of your application from any machine. Take advantage of the power of Ruby without the cross-platform dependency headaches that go with it.
>
> For systems with Java, I have packaged some utilities as jar files:
>
> GitHub - jruby/warbler: Warbler chirpily constructs .war files of your Ruby applications.
>
> I've never used it, but Glimmer has a packaging option that uses warbler
> and jpackage to create DMG/PKG, MSI/EXE, and/or DEB/RPM packages (again
> depending on a Java runtime on the target):
>
>
glimmer-dsl-swt/GLIMMER_PACKAGING_AND_DISTRIBUTION.md at master · AndyObtiva/glimmer-dsl-swt · GitHub

If the system has Java, I agree that JRuby is a good option (assuming
you don't use native gems). I wrote a post here on how to package Ruby
scripts into JAR files at this page:
JRuby on Windows: Day 2 - Creating Executable JARS

It's part of my series of posts on JRuby all of which are linked from
the write-up on Why JRuby here:
Why we like to use JRuby

Best Regards,
Mohit.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Andy Maleh

LinkedIn: https://www.linkedin.com/in/andymaleh
<https://www.linkedin.com/in/andymaleh&gt;
Blog: http://andymaleh.blogspot.com
GitHub: AndyObtiva (Andy Maleh) · GitHub
Twitter: @AndyObtiva <https://twitter.com/AndyObtiva&gt;