Simple way to install Ruby with gems on a customer site - ruby

What's the simplest way -- ideally a single click -- to set up a ruby (not rails) runtime environment on a local Windows system (not a web site), with specific gems?
I have code for a customer that runs on their local system. I've been sending them ocra executables, and that sorta, kinda, usually works, but is showing more problems all the time.
So I want to set up a native ruby environment there -- actually I want them to set it up -- so I can just send straight ruby code. But it's got to have the specific gems I use (FxRuby, several others).
Most important, it's gotta be dead simple for them -- ideally a single click. I'm trying to avoid a physical trip to their site.
Thanks.

As they are running Windows why not go to the ruby-lang.org website and download the windows installer - depending on the edition they do come with gems - some with FXRuby (which I use myself) you can then send the app to them and they can install Ruby - It is quiite simple to do.

In the ruby code before you make it an ocra file put
`gem install mygem`
`gem install myothergem`
in backsticks...
This will run in the command line of the receiving computer. Then require the gems later in your script.
Let me know if this works.

Related

Ruby for vscode without Gem and Ruby installed on the system

I am searching for simple Ruby gem that would be able to find definitions of methods.
First I installed this:
But it requires some gems(rubocop, ruby-debug-ide or solargraph) to be installed in order to work. It provides a lot of features as debugging etc, but I dont need them. I only want to be able to find methods definition.
I am using Vscode to access Rails project on network directory. So I don't want to install Ruby on my host OS (Windoiws 10 x64). Instead I provide a network directory to a guest Guiless Ubuntu (as Guest OS). The Rails server is run on the Ubuntu OS.
VSCode works perfectly well with network directories, but the extensions need Ruby environment that is pretty sad.
For example Sublime Text 3 does this painlessly and donesn't complain for gems. Even without having any Ruby stuff on the OS it is running on:
I want to stick with VSCode because it is the best I have used so far.
So the question is: Is there a Ruby extension for VSCODE that works without Ruby installed?
The only thing that can really parse Ruby is Ruby, so you need Ruby when working with Ruby code. Same goes for a lot of other languages in Visual Studio Code. Sublime provides a "good enough" reflector based on a very simplistic syntax parse. Visual Studio Code uses Solargraph which does way more.
If you don't like that requirement you can always use or write a different Ruby plugin that has no such dependencies. As someone who does a lot of Ruby work, though, the installation is a minor inconvenience for all the benefits it provides.
#Hairi have you tried the ruby-symbols extension?
https://github.com/rubyide/vscode-ruby/issues/40
Keyboard shortcut for Windows is Ctrl + Shift + O.
And for Macs, it's Cmd + Shift + O.

Ruby and Jekyll installation in Linux host without root

Can anyone help me installing ruby and jekyll packages in linux host under an application account without root access?
If you want to install ruby on a server where you only have a user account and no root privileges, you can build it from source. RVM is a tool that can help with this, that can be installed locally. You may run into issues with missing tools (like a compiler) or dependencies. Depending on what is missing, you may be able to upload it to your user directory some where and continue trying to build ruby. How much work this will be depends on how much is already present on this host.
Although, I will go a bit further and say, if you're planning to use jekyll to generate a static site and server the pages from this linux host, it's probably going to be easier to install ruby and jekyll locally and generate the static site from your development computer, and just upload the results to the server.

How can I run Win32OLE calls from ubuntu?

I have some simple sinatra apps that make use of the OTA COM dll for talking to Quality Center.
I want to move those sites into docker images, so I can host them on my docker server.
It occurred to me that theoretically I should be able to get this working with strategic use of wine.
Hint: I remember reading somewhere that to get Win32OLE working in Ruby from linux you can install the windows version of ruby using wine, then run your scripts through the windows version of ruby.
https://www.ruby-forum.com/topic/88576 says
i've managed this before. i installed the one-click installer under
crossover office and the used that. another option is installing
msys, compiling ruby under that, and then using that ruby. in any
case you need to install/build another ruby under the crossover environment.
and later
In the end I installed office 2000 with Crossover, then I used the
windows installer to install windows ruby into the same bottle as
office. Finally I put the following bash script in my /usr/bin directory
so I can run my ruby files with '#> wruby some_script.rb'
==/usr/bin/wruby
#!/usr/bin/env ruby
`/opt/cxofficebeta/bin/wine --bottle myBottle --cx-app ruby.exe #{ARGV.join(" ")}`
I know nothing about Wine or crossover or bottles(?), so I'm out of my depth.
How would I do this? What would a Dockerfile I could use as a base image look like?
Note: I found some docker images that claim to install wine (which may make a good starting point)
https://registry.hub.docker.com/u/ambakshi/wine-x11-vcpython27/
https://registry.hub.docker.com/u/monokrome/wine/
https://registry.hub.docker.com/u/yantis/wine/
http://www.perlmonks.org/?node_id=430194 talks about getting Win32::OLE working under ubuntu.
Don't forget to use a USER xx in your Dockerfile as it is important to use a non privileged user in wine. You will find in registry.hub.docker.com several examples of wine with such a user.

How can I prevent PATH errors while developing Ruby in Windows (7)? Am I doing something wrong?

It seems every week I have to clean up the environment variables, uninstall all gems (I've even memorized the one liner command by now) and reinstall Ruby, DevKit, Gems, Rails, Heroku, etc. Most of the time it works and it's ok for a few days, but it's not long before the "x is not recognized as an internal or external command" or "The native gem requires installed build tools" errors start creeping up, until development becomes impossible.
Surely this can't be normal, but as far as I know I'm not doing anything explicitly wrong. I do things the same way I used to do on my Mac, and it just worked. But I'm at the end of my rope with this OS.
Any ideas?
Really all you should need is to have the Ruby you're using's bin folder at the start of your PATH (start for safety sake). And make sure you don't have any others in there.
For the "requires installed build tools" I usually just add these to the system path, your equivalent:
C:\installs\devkit451\devkit451\bin;C:\installs\devkit451\devkit451\mingw\bin;
HTH.

Can I use RVM to maintain a single version of Ruby for all users?

I love RVM. I realize that the main use case for it is letting different users switch between different versions of Ruby. But let's say I'm deploying a Rails app to a server and I just want a single version of Ruby running. In particular, I want 1.9.2, which is a breeze to install with RVM but a pain without it. Is there a way that I can say "I want this to be the canonical Ruby installation for all users" (along with all of its gems) without having to create a bunch of symlinks by hand and change them every time I update to a newer Ruby release?
Install RVM as root and do a sudo rvm use 1.9.2 --default. Any user sourcing /usr/local/rvm/scripts/rvm will per default have 1.9.2.
I know this doesn't quite answer your question, but:
I ran into several problems with installing RVM globally and resorted to using one user account for deployment and for all Ruby / Rails processes -- that users account exists on all dev and production servers, and the .rvm directory is rsync'ed from one dev-server to all other servers.
How many different users on your App servers do really need to access Ruby 1.9.2?
Can't you just trim that down to just one user? That worked best for me.
Note:
One thing you probably want to avoid is to install RVM on your app server(s) manually and then install Ruby and Gems on the app server ... you don't want to keep tools like cc lying around on your production servers for security reasons! rsync'ing the .rvm directory is far safer! and the result is far more consistent!

Resources