'Installing .gem and its dependencies offline

I am trying to install a plugin .gem file (logstash-output-apm-Release-APM-10.5.1-DxC-1.4-20170114.212431-8.gem), supplied by the vendor, but it failed with the error below, as I'm running the install command from a machine with NO Internet access:

[user@server_hostname bin]$ ./logstash-plugin install DigitalExperienceCollector-Release-APM-10.5.1-DxC-1.4-SNAPSHOT-2017_01_14_13_24/logstash/apm-logstash-plugin/logstash-output-apm-Release-APM-10.5.1-DxC-1.4-20170114.212431-8.gem

Validating DigitalExperienceCollector-Release-APM-10.5.1-DxC-1.4-SNAPSHOT-2017_01_14_13_24/logstash/apm-logstash-plugin/logstash-output-apm-Release-APM-10.5.1-DxC-1.4-20170114.212431-8.gem
Unable to download data from https://rubygems.org/
- Errno::ECONNREFUSED: Connection refused - Connection refused (https://api.rubygems.org/latest_specs.4.8.gz)

Is there a way to download the latest_specs.4.8.gz manually, and supply to the .gem file without modifying the .gem file?
Or will the vendor need to make some modification on the .gem file to load from a local copy?



Solution 1:[1]

You can install a gem locally by using the --local flag from the directory containing the gem.

For example, to install a my_gem-0.1.0.gem I downloaded previously to my /downloads/gems/ directory:

$ cd downloads/gems
$ gem install my_gem --local

The downside being that you still won't be able to fetch any of the runtime_dependency gems.

Solution 2:[2]

You should build and "offline plugin pack" It will include dependencies so that you will be able to install it offline.

Details here

bin/logstash-plugin prepare-offline-pack --output OUTPUT --overwrite [PLUGINS]

  • OUTPUT specifies the zip file where the compressed plugin pack will be written. The default file is /LOGSTASH_HOME/logstash-offline-plugins-8.0.1.zip. If you are using 5.2.x and 5.3.0, this location should be a zip file whose contents will be overwritten.
  • [PLUGINS] specifies one or more plugins that you want to include in the pack.
  • --overwrite specifies if you want to override an existing file at the location

then on the target machine:

bin/logstash-plugin install file:///path/to/logstash-offline-plugins-8.0.1.zip

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ashmaroli
Solution 2 user1767316