Windows: rails: installation error bson_ext

when I try to install bson_ext, I see an error ... installing json gem works fine, which also requires creating my own extensions - I tried to see all similar questions without a good answer

$ gem install bson_ext Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing bson_ext: ERROR: Failed to build gem native extension. c:/Ruby193/bin/ruby.exe extconf.rb checking for asprintf()... no checking for ruby/st.h... yes checking for ruby/regex.h... yes checking for ruby/encoding.h... yes creating Makefile make generating cbson-i386-mingw32.def compiling bson_buffer.c compiling cbson.c cbson.c:25:23: fatal error: arpa/inet.h: No such file or directory compilation terminated. make: *** [cbson.o] Error 1 Gem files will remain installed in c:/Ruby193/lib/ruby/gems/1.9.1/gems/bson_ext- 1.11.1 for inspection. Results logged to c:/Ruby193/lib/ruby/gems/1.9.1/gems/bson_ext-1.11.1/ext/cbson/ gem_make.out $ gem install json Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... Successfully installed json-1.8.1 1 gem installed Installing ri documentation for json-1.8.1... Installing RDoc documentation for json-1.8.1... 
+5
source share
4 answers

According to this post, <arpa/inet.h> not a window library, so winsock2.h should be used instead.

To change this link, I did the following **:

  • Go to the installation folder (c: /Ruby193/lib/ruby/gems/1.9.1/gems/bson_ext-1.11.1)
  • Fold the level to the cbson folder and find cbson.c
  • Open cbson.c in your favorite text editor and find the line that reads #include "<arpa/inet.h>"
  • Change this line to #include winsock2.h
  • Open a command prompt, go to the installation folder and run gem build bson_ext.gemspec
  • Move the newly created .gem file to a safe location (for example,% userprofile% \ Desktop).
  • Go up to the gem folder and delete the entire bson_ext folder
  • Return to the command prompt window, change the directory to where you placed the newly created .gem file (cd% userprofile% \ Desktop, if you follow these steps for sure)
  • Run gem install bson_ext-1.11.1.gem --local , and the pearl should now install successfully.

** Huge caveat: I'm just looking at mongodb for a rail guide, and I don't have any functional code to check this out. Although this fixes the installation error, I cannot determine if this fix is โ€‹โ€‹complete. This reference library is new to release 1.11.1. If you install version 1.10.2, this problem will not occur ( gem install bson_ext -v 1.10.2 ). I will leave it to you to decide which solution makes more sense to you.

Edit: based on a change in the bson-ruby project on github, the best fix would be a change that involves reading this:

 #ifdef _WIN32 #include <winsock2.h> #else #include <arpa/inet.h> #endif 
+9
source

The file is not needed when compiling on DevKit.

To prevent this error, just create an empty file in the expected location. If your DevKit was installed in C: \ DevKit, the file was expected in C: \ DevKit \ mingw \ include \ arpa \ inet.h

It should also fix other native stones. The reason is that definitions, usually coming from arpa / inet.h, already come from other included files, which are automatically included most of the time.

+5
source

I just upgraded my gem to an older version (from 2.4.6 to 2.3) and it worked.

0
source
 Use this command gem update --system 2.3.0 
0
source

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


All Articles