Portable Ruby on Rails Environment

Portable Ruby on Rails environment

I like InstantRails, very easy to use, no installer, and does not modify your system environment.

How to update rails offline?

You can download the necessary gems from a computer with internet access, transfer these to the computer you wish to update, and use gem install ... to install them.

There are instructions here: How to install Ruby on Rails on a windows PC

Another option might be to run Rails off a portable external hard drive (or flash drive) that can be moved from one PC to another. There are a couple of packages, Instant Rails, and Flash Rails, that allow you to have a portable version of Rails on Windows. Unfortunately they are both a bit out of date as far as Rails versions, so you'll still have some upgrading to do once you install them. See Portable Ruby on Rails environment.

Creating a Ruby on Rails environment on Windows, in a VM Vagrant Box

Installing osx in Vagrant is probably possible but it would likely be quite hard, and its not really what vagrant is designed for.

As for your other questions vagrant sounds like the perfect fit.

With Vagrant you could start up an ubuntu vm and get your rails setup going. Then you could just forward a port on your local machine to the vm and load the rails site as if it were running locally on your windows PC. A quick google gets this vagrant box that looks like it might work for you - https://github.com/amaia/rails-starter-box

To work with the site you can just share a folder between the vm and your local machine which will allow you to edit images and code with your windows apps (Photoshop, sublime) so you don't actually need to install these in the ubuntu vm at all, and can pretty much work as normal.

Git is much the same... I prefer to SSH into the vagrant box and use git on the command line in ubuntu but you can just as easily use gitbash or tortoisegit from windows in the repo folder... works just as well.

Packaging Ruby into a portable executable

I got so tired of this that I decided to make my own solution to it. After a couple of days I finally got this working.


I present: Ruby Ship

It's just what I needed, and hopefully someone else will get the benefit of it too!

It's really simple: Download the repo (which is quite big because of the binaries). Put it on a usb-drive, or wherever you want it, then do:

path/to/ruby_ship/bin/ruby_ship.sh -v
=> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

That's for linux and mac, or on windows:

path\to\ruby_ship\bin\ruby_ship.bat -v
=> ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-mswin32_100]

The ruby_ship wrapper acts just as your normal ruby, so you can pass in a script, or do anything you would use the normal ruby command for.

If you don't like the version that comes bundled with Ruby Ship, then simply use the compiling-script that is in the tools directory. Download the source code of you favourite version of Ruby, say X.Y.Z, then do this:

# *nix (osx/linux/...)
path/to/ruby_ship/tools/ruby_ship_build.sh path/to/ruby-X.Y.Z.tar.gz

# windows
path\to\ruby_ship\tools\ruby_ship_build.bat path\to\ruby-X.Y.Z.tar.gz

This will build your flavour of ruby and set up the wrappers correctly. Now you Ruby version X.Y.Z is portable! Copy paste this folder where you want it and you are ready to go! Remember though, it will only compile for your current platform, so if you need other platforms, go compile it on those platforms as well.

The compiling process has a few requirements. Look at the github site.

Anyways, hope that others might find this useful! If things are not quite working for you, please make an issue and I will look into it!

Is there a self contained Ruby (and Rails) solution that can be run from a flash drive?

To start, you will need two copies of Ruby on your USB drive: one for Windows and one for Mac OS X.

You will then need to create a script in each to add Ruby to the path and open a terminal.

I would structure it like this:

  • ruby

    • windows

      • bin, lib, etc...
      • start.bat
    • mac

      • bin, lib, etc...
      • start.sh

Windows

Content of start.bat

@echo off
set PATH=%CD%\bin;%PATH%
start cmd

Create a shortcut to start.bat with the working directory being ruby/windows

Mac OS X

Content of start.sh (Not sure of equivalent script file)

...

Then create a shortcut to execute the script.

Now, instead of starting a terminal up normally, use the shortcuts and Ruby will run from the USB drive.

Do you have a Rails development environment running under Windows you're happy with?

To add on to Omar: instead of dealing with VMWare, you could install Portable Ubuntu, which runs inside Windows. Though you will get a performance hit from doing so, it will give you a Linux environment to work in and you won't have to worry about installing another operating system.

Alternate for environment dependent global variables

Hopefully, there is a much better way. Find inspiration in YAML Configuration File.

Having all datas in YAML files is a really clean way to handle multiple cases.



Related Topics



Leave a reply



Submit