3

I want to build and try out this github project https://github.com/cmedley/terraforming

I have installed the package (or gem? Apology I am not familiar with proper Ruby terminology) to an alternative location by running the setup script in the github repo:

./script/setup --path ../bin

I can see that the main script terraforming has been installed under bin. The path is bin/ruby/2.3.0/bin/terraforming in this case.

However when I ran it, I got this error:

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:241:in bin_path': can't find gem terraforming (>= 0.a) (Gem::GemNotFoundException) from ../bin/ruby/2.3.0/bin/terraforming:22:in'

What is the proper way to invoke this terraforming script from the alternative installation location.

Anthony Kong
  • 37,791
  • 46
  • 172
  • 304

2 Answers2

3

You may still need to gem install terraforming to install the gem.

The script/setup only installs dependencies -- you can see in its code that it just runs bundle install, which installs the gems in the included gemfile. This gemfile does not include the terraforming gem itself as it expects you to do this independently.

Andrew Schwartz
  • 4,440
  • 3
  • 25
  • 58
2

What kind of application are you using? Rails? Sinatra? Does it have a gemfile? If so, you should be able to explicitly set the path to the gem:

gem 'terraforming', path: '/bin/ruby/2.3.0/bin/terraforming'

For a command line utility you need to include the path to the gem using the $LOAD_PATH. You can read the Ruby docs about requiring code or there are other answers on StackOverflow that might be helpful like this one and this one.

calebkm
  • 1,013
  • 4
  • 17
  • The project is actually a command line utility. I suppose to run it in a shell like `terraforming s3 --profile hoge`. See https://github.com/cmedley/terraforming#prerequisites for details – Anthony Kong Nov 07 '19 at 05:54
  • if u use bundler to install your gem, you can try using deployment mode provided by it https://bundler.io/man/bundle-install.1.html#DEPLOYMENT-MODE in this case, the executable file would be in vendor/bundle/ruby/{version}/bin. In case you need to require it in your code, you need to add it onto the load path as well – darkash Nov 08 '19 at 08:30
  • I've updated my answer to include info about using the `$LOAD_PATH` to tell your system about the gem. I think that should get you what you need. – calebkm Nov 08 '19 at 19:14
  • I read the resources you quoted but I don't find them actionable. I export the LOAD_PATH but the cli still can't run. Same error message. – Anthony Kong Nov 11 '19 at 00:16