ruby – 未安装gem依赖项
发布时间:2020-12-17 02:04:57 所属栏目:百科 来源:网络整理
导读:我确信这很明显,但我对ruby很新.我想使用rake / albacore来自动执行某些任务.我想打包它以使用bundler在我的构建服务器上使用.现在我想做一个使用mixlib- shellout冒充sys帐户的哑任务.为此,我有以下Gemfile: source 'http://rubygems.org'gem 'mixlib-shel
我确信这很明显,但我对ruby很新.我想使用rake / albacore来自动执行某些任务.我想打包它以使用bundler在我的构建服务器上使用.现在我想做一个使用mixlib-
shellout冒充sys帐户的哑任务.为此,我有以下Gemfile:
source 'http://rubygems.org' gem 'mixlib-shellout' gem 'rake' 和以下rake文件: 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 我跑 bundle install 我只看到rake正在安装…… Gemfile.lock dep树中没有其他依赖项……这是正常的吗? PS C:UsersBensrcruby_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. 然后我跑了 bundle exec rake 我得到了回报 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) 我使用的是ruby 2.0和bundler 1.3.5 任何帮助感激不尽. 解决方法
我建议使用* .gemspec文件设置gem.为此,您的Gemfile变得非常简单:
source 'https://rubygems.org' gemspec 然后写一个新文件“GEM_NAME.gemspec”.这是一个例子: 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 您需要为每个依赖gem添加单独的spec.add_runtime_dependency.上面的例子包括“ruby-terminfo”gem. 此外,您需要设置spec.files字段以反映您的gem的文件和文件夹结构. 有关详细信息,请参见RubyGem Guide. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |