I want to install JSON and Sinatra on my Mac that does not have an internet connection.
How can I download and install Sinatra and JSON with all their dependency packages from another machine and then install on my Mac?
I want to install JSON and Sinatra on my Mac that does not have an internet connection.
How can I download and install Sinatra and JSON with all their dependency packages from another machine and then install on my Mac?
JSON is already installed on Ruby 1.9.2+. If you're not running that already you should be as Mac OS comes with 1.8.7, which is pretty old now, and has been deprecated.
You don't want to try to install a newer version of Ruby on top of Apple's version of Ruby, as they installed it for their own use. Something like rbenv or RVM would be the suggested ways of installing something newer. However, if you're not attached to the internet then you'll have a lot of work ahead of you.
Rubygems can tell us what gems another gem depends on:
gem depend sinatra
Returns:
Gem sinatra-1.4.3
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3.4, ~> 1.3)
Those are the gems you'd have to download and copy over, and install prior to installing Sinatra. Be aware that each of those dependencies probably have their own dependencies also, so you'll need to walk through the list to get everything necessary.
gem fetch sinatra
will retrieve the Sinatra gem to the local directory. Once that's done you can copy it somewhere else convenient. Do the same for the other files you need/want.
Rubygems can install a gem from a local archive. Type gem help install
at the command-line for more information, or see "How can I install a local gem?" and "RubyGems Basics", in particular the "Fetching and Unpacking Gems" section for more information.
Honestly though, trying to do any development on a machine that isn't attached to the internet in some form is going to be very, very, painful. I consider an internet connection essential for my development work these days, and when I have to work on a machine that doesn't give me that at work I get pretty grumpy, even when the machine has network connections to other machines that are attached to the internet. That delay and extra step is a real pain.
You could use a networked machine and instruct bundler to install all required gems in a specific location.
$ bundle install --deployment
will install gems at vendor/cache
, whereas
$ bundle install --path path/to/directory
will install gems at the given path. Please refer to the bundler documentation.
This will allow you to install everything on a thumb drive (or other portable storage device) and copy the entire directory to your Mac.
If you have more complex requirements, such as controlling ruby versions with rbenv
, you can