Not installed

I'm sure this is really obvious, but I'm brand new to rubies. I want to use rake / albacore to automate some tasks. I want to pack it for use on my build server using bundler. Now I want to do one stupid task that personifies the sys account using mixlib-shellout. For this, I have the following gemfile:

source 'http://rubygems.org' gem 'mixlib-shellout' gem 'rake' 

and the following rake file:

 require 'rubygems' require 'bundler/setup' require 'mixlib/shellout' task :default do whomai = Mixlib::ShellOut.new("whoami.exe", :user => "username", :domain => "DOMAIN", :password => "password") whoami.run_command end 

I ran

 bundle install 

and I only see that the rake is installed ... none of the other dependencies in the Gemfile.lock descriptor tree ... is this normal?

 PS C:\Users\Ben\src\ruby_test> bundle install Fetching gem metadata from http://rubygems.org/........... Fetching gem metadata from http://rubygems.org/.. Resolving dependencies... Installing rake (10.1.0) Using bundler (1.3.5) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. 

Then i ran

 bundle exec rake 

and I get in return

 rake aborted! cannot load such file -- mixlib/shellout C:/Users/Ben/src/ruby_test/rakefile.rb:4:in `require' C:/Users/Ben/src/ruby_test/rakefile.rb:4:in `<top (required)>' (See full trace by running task with --trace) 

I am using ruby ​​2.0 and bundler 1.3.5

Any help gratefully received.

+4
source share
1 answer

I recommend setting up your gem with a * .gemspec file. To do this, your Gemfile becomes very simple:

 source 'https://rubygems.org' gemspec 

Then write the new file "GEM_NAME.gemspec". Here is an example:

 Gem::Specification.new do |spec| spec.name = GAME_NAME spec.version = VERSION spec.authors = AUTHORS spec.email = EMAILS spec.summary = SUMMARY spec.description = DESCRIPTION spec.homepage = HOMEPAGE spec.files = Dir['rakefile.rb', '*.gemspec'] spec.files += Dir['bin/**', 'lib/**/*.rb'] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.add_runtime_dependency "ruby-terminfo", "~> 0.1" spec.add_development_dependency "bundler", "~> 1.7" spec.add_development_dependency "rake", "~> 10.0" end 

You need to add a separate spec.add_runtime_dependency for each dependent gem. The example above contains the ruby-terminfo gem.

In addition, you need to configure the spec.files field to display your file and folder structure.

See the RubyGem Guide for more information .

+1
source

Source: https://habr.com/ru/post/1493521/


All Articles