Hi partners,
I am try to use the chef-email-reporter
gem. In the documentation says:
Install the chef-email-reporter gem on the node:
/opt/chef/embedded/bin/gem install chef-email-reporter
but I am working on nodes with Windows 7 OS. Then, I use gem install chef-email-reporter
and this need the Development Kit which I install following the instructions in Development Kit · oneclick/rubyinstaller Wiki · GitHub.
To use chef-email-reporter
I have to put code like this in the client.rb file:
gem "chef-email-reporter"
require "chef-email-reporter"
Mail.defaults do
delivery_method :smtp, address: 'smtp.example.com'
end
email_sender "no.reply@example.com"
email_recipient "chef-notifications@example.com"
and run chef-client, obviously, the gem is installed already. However, I get this error:
FATAL: Configuration error Gem::MissingSpecError: Could not find 'chef-email-reporter' (>= 0) among 106 total gem(s) Checked in 'GEM_PATH=C:/Users/P465-B91/.gem/ruby/2.1.0;C:/opscode/chef/embedded/lib/ruby/gems/2.1.0', execute `gem env` for more information
FATAL: C:/chef/client.rb:10:in `from_string'
FATAL: Aborting due to error in 'C:/chef/client.rb'
I think that need execute this instruction (how documentation says):
/opt/chef/embedded/bin/gem install chef-email-reporter
but in windows is in other way that I do not know
The gem env
run:
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby23/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: C:/Users/P465-B91/.gem/ruby/2.3.0
- RUBY EXECUTABLE: C:/Ruby23/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby23/bin
- SPEC CACHE DIRECTORY: C:/Users/P465-B91/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- GEM PATHS:
- C:/Ruby23/lib/ruby/gems/2.3.0
- C:/Users/P465-B91/.gem/ruby/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- SHELL PATH:
- C:\Windows\system32\WindowsPowerShell\v1.0\
- C:\Windows\system32
- C:\Windows
- C:\Windows\System32\Wbem
- C:\Windows\System32\WindowsPowerShell\v1.0\
- C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\
- C:\Program Files\Microsoft SQL Server\120\Tools\Binn\
- C:\Program Files\Microsoft SQL Server\120\DTS\Binn\
- C:\Program Files\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\
- C:\Program Files\Java\jdk1.7.0_79\bin
- C:\Program Files\EPSON\OPOS for .NET\Lib
- C:\Program Files\OPOS\Epson2
- C:\opscode\chef\bin\
- C:\Ruby23\bin
Any help, thanks.
Looks like you have two rubies on your path. So you are installing it into the first non chef ruby and then the ruby embedded in chef is missing it.
Calling gem install
from the absolute path of the chef ruby would indeed fix this. The windows equivilent of /opt/chef/embedded/bin/gem
is c:\opscode\chef\embedded\bin\gem.bat
Thanks for your answer @Matt_Wrock, then I must run c:\opscode\chef\embedded\bin\gem.bat install chef-email-reporter
?
@Matt_Wrock, I get this error
PS C:\Windows\system32> c:\opscode\chef\embedded\bin\gem.bat install chef-email-reporter
Fetching: win32-process-0.7.3.gem (100%)
Successfully installed win32-process-0.7.3
Fetching: win32-api-1.5.1-universal-mingw32.gem (100%)
Successfully installed win32-api-1.5.1-universal-mingw32
Fetching: windows-api-0.4.2.gem (100%)
Successfully installed windows-api-0.4.2
Fetching: windows-pr-1.2.2.gem (100%)
Successfully installed windows-pr-1.2.2
Fetching: mixlib-shellout-1.6.1-x86-mingw32.gem (100%)
Successfully installed mixlib-shellout-1.6.1-x86-mingw32
Fetching: mime-types-1.25.1.gem (100%)
Successfully installed mime-types-1.25.1
Fetching: ffi-yajl-1.4.0.gem (100%)
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
ERROR: Error installing chef-email-reporter:
ERROR: Failed to build gem native extension.
current directory: C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/ffi-yajl-1.4.0/ext/ffi_yajl/ext/encoder
C:/opscode/chef/embedded/bin/ruby.exe -r ./siteconf20160809-188-1c8ctpn.rb extconf.rb
-IC:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/libyajl2-1.2.0/lib/libyajl2/vendored-libyajl2/include -IC:/opscode/
chef/embedded/include -O3 -march=i686 -DFD_SETSIZE=2048
-LC:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/libyajl2-1.2.0/lib/libyajl2/vendored-libyajl2/lib -L. -LC:/opscode/
chef/embedded/lib
creating Makefile
current directory: C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/ffi-yajl-1.4.0/ext/ffi_yajl/ext/encoder
make "DESTDIR=" clean
current directory: C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/ffi-yajl-1.4.0/ext/ffi_yajl/ext/encoder
make "DESTDIR="
generating encoder-i386-mingw32.def
compiling encoder.c
In file included from c:/opscode/chef/embedded/include/ruby-2.1.0/ruby/defines.h:217:0,
from c:/opscode/chef/embedded/include/ruby-2.1.0/ruby/ruby.h:29,
from c:/opscode/chef/embedded/include/ruby-2.1.0/ruby.h:33,
from encoder.c:1:
c:/opscode/chef/embedded/include/ruby-2.1.0/ruby/win32.h:320:44: warning: 'struct timespec' declared inside parameter li
st
c:/opscode/chef/embedded/include/ruby-2.1.0/ruby/win32.h:320:44: warning: its scope is only this definition or declarati
on, which is probably not what you want
c:/opscode/chef/embedded/include/ruby-2.1.0/ruby/win32.h:321:43: warning: 'struct timespec' declared inside parameter li
st
linking shared-object ffi_yajl/ext/encoder.so
c:/opscode/chef/embedded/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lyajldll
collect2: ld returned 1 exit status
make: *** [encoder.so] Error 1
make failed, exit code 2
Gem files will remain installed in C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/ffi-yajl-1.4.0 for inspection.
Results logged to C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/ffi-yajl-1.4.0/gem_make.out
Apologies for the delayed response. I have seen these ffi-yajl compilation errors on windows myself. I believe it has to do with the way we build chef and I am looking to ensure future versions don’t run into this.
In the meantime I believe you can get “unstuck” by installing the libyajl2 gem and then retrying your original gem install.
Hi @Matt_Wrock, I try to install libyajl2 but it harm the chef-client. I hope you can solve the issues.