Jump to content


P4Ruby API 17.1: error on gem installing / building under Windows

p4ruby p4api gem ruby

  • Please log in to reply
6 replies to this topic

#1 Warlock

Warlock

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 15 March 2018 - 02:09 PM

Hi All,

After upgrading p4 server from 13.2 to 17.2, in our internal software based on p4ruby 15.2, I've got an error "Unknown field name 'Type'.":
...
@p4.save_client(client)
Error in client specification.
Error detected at line 18.
Unknown field name 'Type'.'
...

I failed with get / built fresh p4ruby API 17.1.1609394 using 'gem install p4ruby', 'gem install p4ruby -- --with-p4api-dir=DIR' and even without some features 'gem install p4ruby -- --with-p4api-dir=c:/p4api_2017.1 --without-cryptolib --without-p4sslstublib'. Full build log attached. Instruction for install gem / build API is here http://www.rubydoc.i.../2017.1.1609394

c:\RubyDevKit>gem install p4ruby -- --with-p4api-dir=c:/p4api_2017.1 --without-cryptolib --without-p4sslstublib
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-p4api-dir=c:/p4api_2017.1 --without-cryptolib --without-p4sslstublib'
This could take a while...
ERROR: Error installing p4ruby:
ERROR: Failed to build gem native extension.

current directory: C:/Ruby23/lib/ruby/gems/2.3.0/gems/p4ruby-2017.1.1609394/ext/P4
C:/Ruby23/bin/ruby.exe -r ./siteconf20180315-105128-wr69ju.rb extconf.rb --with-p4api-dir=c:/p4api_2017.1 --without-cryptolib --without-p4sslstublib
p4osname MINGW32
p4osver
$CPPFLAGS -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT $(DEFS) $(cppflags)-DOS_MINGW32 -DOS_MINGW32 -DOS_MINGW32X86 -DOS_NT -DCASE_INSENSITIVE
$CFLAGS $(cflags)
checking for main() in -lsupc++... yes
$LDFLAGS -L.
P4API Path c:/p4api_2017.1
checking for main() in -lgdi32... yes
[b]checking for main() in -lfalse... no[/b]
[b]checking for main() in -lfalse... no[/b]
[b]*** extconf.rb failed ***[/b]
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
...

Attempt to build p4ruby 17.1 from source ended with the same error.

Is it possible to build p4ruby 17.1 for Windows at all?
Can it help me to solve "Unknown field name 'Type'." error' ?

My environment for build p4ruby API 17.1:
  • Windows 7 SP1
  • RubyInstaller - rubyinstaller-2.3.3-x32.exe
  • DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
  • p4api_17.1_mingw64x86.zip / p4api_17.1_mingwx86.zip / p4api_vs2015_static_17.1_x32.zip / p4api_vs2015_static_17.1_x64.zip Which one should I use?

Many thanks,
Alexey

Attached Files



#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 611 posts

Posted 15 March 2018 - 06:08 PM

I don't know much about the Ruby build problem, but I'm pretty sure the source of the "unknown field" error is a combination of:

1) P4Ruby uses its own hardcoded version of the client specdef rather than fetching the current one from the server (this is a pretty bad bug in P4Ruby if true IMO, but no help for it now)
2) the server doesn't filter out the Type field when sending a client spec to an old client (this is not great, and once upon a time we bent over backwards to preserve backwards compatibility by having per-client-version spec formatting, but an old client is *supposed* to handle this now by reading the specdef that's sent with the spec rather than trying to use an outdated specdef).

Assuming it's impossible to rebuild or fix P4Ruby, a kludgy workaround could be to set up a "form-out" trigger that strips the Text field from outgoing client specs (you'd probably want to come up with a way to only have it fire for your P4Ruby scripts), and a "form-in" trigger that restores it based on what's currently in the db.

#3 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 611 posts

Posted 15 March 2018 - 06:17 PM

I went poking around in the P4Ruby source and found this:

https://swarm.worksh...serruby.cpp#270

which suggests that you should get the right spec def the first time you fetch a spec of that type from the server.  Does your script get the current version of the client spec (or any client spec) before it tries to save a new one?  If not, try adding a dummy "fetch_client()" before you do your "save_client", and hopefully that'll provoke it into updating its cache.

#4 Warlock

Warlock

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 16 March 2018 - 10:11 AM

Hi Sambwise,
Thank you for help!

The fact is that p4ruby (P4RUBY 2015.2.1313860 P4API 2015.2 PATCHLEVEL 1311674  WITH_LIBS -lclient -lrpc -lsupp -lssl -lcrypto -lgdi32 -lsupc++) has changed behavior after (and only after) p4 server upgrade (13.2 -> 17.2) and start to add new field 'Type' and 'Backup' to client specification (and breaks with error 'Unknown field name ...'). Calling dummy p4.fetch_client() before p4.save_client() didn't help. As workaround I've removed 'Type' and 'Backup' fields before save_client():
client = @p4.fetch_client()
client.delete("Type")
client.delete("Backup")
@p4.save_client(client)

I've asked Perforce guys for fix p4ruby 17.1 gem for Windows by including precompiled p4.so library, like it was in p4ruby 15.2 gem or fix it compile. It should be the best solution.

#5 Warlock

Warlock

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 11 April 2018 - 09:48 AM

Perforce support is a quite slow and still did't make p4ruby 17.1 gem for Windows with precompiled binaries.
My attempts to compile p4ruby 17.1 or 15.2 was unsuccessfully:

The current error is in finding strange libraries 'true' and 'false': checking for main() in -ltrue... no
Does somebody know from where -ltrue and -lfalse dependencies come from and how to fix it?

c:\>gem install p4ruby -v 2015.2.1265122 --platform=ruby -- --with-p4api-dir=c:\p4api_2015.2_x86 --with-clientlib --with-rpclib --with-ssllib --with-cryptolib --with-plstublib --with-supc++lib --with-gdi32lib
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-p4api-dir=c:\p4api_2015.2_x86 --with-clientlib --with-rpclib --with-ssllib --with-cryptolib --with-p4sslstublib --with-supc++lib --with-32lib'
This could take a while...
ERROR: Error installing p4ruby:
ERROR: Failed to build gem native extension.

current directory: C:/Ruby23/lib/ruby/gems/2.3.0/gems/p4ruby-2015.2.1265122/ext/P4
C:/Ruby23/bin/ruby.exe -r ./siteconf20180411-21848-1v8gaym.rb extconf.rb --with-p4api-dir=c:\p4api_2015.2_x86 --with-clientlib --with-rpclib --with-ssllib --with-cryptolib --wit4sslstublib --with-supc++lib --with-gdi32lib
p4osname MINGW32
p4osver
$CPPFLAGS -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT $(DEFS) $(cppflags)-DOS_MINGW32 -DOS_MINGW32 -DOS_MINGW32X86 -DOS_NT -DCASE_INSENSITIVE
$CFLAGS $(cflags)
checking for main() in -ltrue... no
$LDFLAGS -L.
P4API Path c:\p4api_2015.2_x86
checking for main() in -ltrue... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby23/bin/$(RUBY_BASE_NAME)
--with-supc++lib
--with-p4api-dir
--with-p4api_dir
--with-p4api-dir
--with-p4api-dir
--with-p4api-include
--without-p4api-include=${p4api-dir}/include
--with-p4api-lib
--without-p4api-lib=${p4api-dir}/lib
--with-gdi32lib
extconf.rb:556:in `<main>': unhandled exception

To see why this extension failed to compile, please check the mkmf.log which can be found here:

C:/Ruby23/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/p4ruby-2015.2.1265122/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby23/lib/ruby/gems/2.3.0/gems/p4ruby-2015.2.1265122 for inspection.
Results logged to C:/Ruby23/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/p4ruby-2015.2.1265122/gem_make.out

c:\>

Thanks in advance.

#6 P4Jen

P4Jen

    Advanced Member

  • Staff Moderators
  • 135 posts

Posted 13 April 2018 - 10:22 AM

Hi,

I am currently looking in to this for a customer, so hopefully there will be some pre-compiled gems that work on Windows soon.

Regarding the issue with fields not known:
These fields were introduced to support working with data from graph depots.

When you are able to use the latest versions of P4Ruby, you should not experience this issue, as P4Ruby will be aware of the fields.

The 'type' field is optional, so perhaps as a work-around, you could try having a client spec in a text file that does not contain these fields.
You could then edit a copy of this to your liking, and parse it in to the server using the '-i' flag.

Note I have not tested this process with P4Ruby, at the time of writing.

Hope this helps,
Jen.


#7 Warlock

Warlock

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 16 April 2018 - 10:52 AM

Jen, thanks for information.

Possible I am the customer :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users