Is there a way to distribute a Ruby gem without access to the internet, just bundling the gem's that are installed on the dev's pc ?
This is for deploying inside our organisation, access to internet is heavily restricted. All the pc's run Windows7 with Ruby1.9.3 and Bundler 1.11.2
I have little experience with git or bundler. Rails is not used but some other gems like activerecord and logger are.
What I tried:
I created a folder with my rb. scripts and a .gemspec file with the required gem's, then I executed bundle gem name_of_the_gem_i_want_to_make
but got an error Errno::ENOENT: No such file or directory - git config user.name
.
In the past I created a git account and did some experimenting bu I'd prefer not to use it.
In the past I experimented with jRuby and Warble to produce JAR's but in this case I'd like to stick with MRI Ruby.
I have internet connection on my dev pc but some of the pc's or servers I want to deploy the scripts - and more important the gem's they depend on - don't. Ruby is allready installed everywhere though.
I'd like a simple way to gather all the needed files from my dev pc and transfer these to the target pc's. I could zip my Ruby folder and extract it elsewhere but then I have a lot of files I don't need.
Can you give me the commands I need to use or give me a site that explains how to do this ? I read a lot about bundler online but have nowhere found this way of working. Can't imagine other devs haven't the same issues and a common solution is present.
EDIT:
I managed to create a gem by executing gem build mygem.gemspec
but it has only my own scripts in it, no required gem's.
EDIT: followed the suggestion of Mihai, removed the previous attempts.
Made a subfolder vendor/gems and copied the 2 gemfiles there.
Now I can do a bundle package
and a bundle install --no-deployment
with the following Gemfile.
gem 'active_record', '4.1.1', :path => 'vendor/gems'
gem 'logger', '1.2.8', :path => 'vendor/gems'
Question now: how to deploy this onto another pc ? Copy everything in the folder and on the target pc do a bundle install --local
? Or is there a way to bundle everything in a gem so that on the target pc I can do gem install mygem --local
? A gem build mygem doesn't include anything from the bundle.
You can do this in two ways.
a) Cache (package) the gems in your project's
vendor/cache
folderThis will generate/update
Gemfile.lock
and copy all the gems locally inside your project'svendor/cache
folder. Then you can copy your project files to your server and runb) Use a custom path, usually located outside your project
bundle install
supports local pathsThe
--local
flag is optional but it's useful in this case as it skips the lookup in the usual remote repositories.Subsequently you can specify the path in the Gemfile as well
Mihai's solution combined with the local gem folder and the --no-deployment option works to some point but there are a few problems: - on the target pc you need to do a
gem install bundler
first using a local copied gem, then abundle install --local
of the package you made and copied earlier - for the gems ruby-oci8 and activerecord-oracle_enhanced-adapter my solution for the other gems didn't work for some reason (something with the mingw32 platform)Since the work about the creating and afterward installing of the package and the problems still resting I decided -for the moment- to resort to the good old batch approach and made following batch script.
This is windows only -obviously- but I asume this can easily be adapter for other OS.
The gems are installed from the local copies, no internet connection necessary, the dependencies of activerecord also, no need to specify them but the gems need to be present.
The devkit is necessary for the i18n and json gems, both dependensies of activerecord.
Here a list of the gemfiles I needed, it depends on the versions you use on your dev pc.
You can find them under
C:\Rubyxxx\lib\ruby\gems\1.9.1\cache
Here the batch
I hope someone posts a solution for the bundler approach (or better) though.