Jump to content


[SOLVED] P4PASSWD invalid or not set - P4Ruby

p4ruby p4passwd invalid unset

  • Please log in to reply
9 replies to this topic

#1 RensterUK

RensterUK

    Member

  • Members
  • PipPip
  • 13 posts

Posted 12 March 2014 - 09:46 AM

Hi All,

I'm having trouble getting started with the P4Ruby API. I've been in touch with one of the guys at Perforce, but he so far hasn't been able to see what's wrong. He's proving helpful, so will continue trading messages with him, but with him seemingly in the US, and me in the UK, it's a one message each way a day situation - not ideal for such problems! Anyway.... I've tried a simple connect/sync test in Ruby (Rails), and in IRB:

irb(main):001:0> require "P4"
=> true
irb(main):002:0> p4 = P4.new
=> P4: [ssl:server:1666] steve_hall@fullmars (not connected)
irb(main):003:0> p4.debug = 1
=> 1
irb(main):004:0> p4.user = "steve_hall"
=> "steve_hall"
irb(main):005:0> p4.port = "ssl:server.com:1666"
=> "ssl:server:1666"
irb(main):006:0> p4.password = "<<ahem!>>"
=> "<<ahem!>>"
irb(main):007:0> p4.client = "fullmars"
=> "fullmars"
irb(main):008:0> p4.connect
[P4] Connecting to Perforce
=> true
irb(main):009:0> p4.run_login

[P4] Received input for next command
[P4] Executing "p4 login"
=> ["User Steve_Hall logged in."]
All good so far... Now...
irb(main):010:0> p4.run_sync

[P4] Executing "p4 sync"
P4Exception: [P4#run] Errors during command execution( "p4 sync" )

[Error]: Perforce password (P4PASSWD) invalid or unset.


from /usr/local/lib/ruby/site_ruby/1.9.1/P4.rb:110:in `run'
from /usr/local/lib/ruby/site_ruby/1.9.1/P4.rb:110:in `method_missing'
from (irb):10
from /usr/local/bin/irb:12:in `<main>'
My contact at perforce has suggested trying to connect directly to our P4 server bypassing the proxy. I wasn't aware we WERE using a proxy! Can anyone advise on how to check? I'm not sure it CAN be bypassed?

He also suggested "2. Please try the script after running "p4 login -a", does it still fail?":
irb(main):007:0> p4.client = "fullmars"
=> "fullmars"
irb(main):008:0> p4.connect
[P4] Connecting to Perforce
=> true
irb(main):009:0> p4.run("login","-a")
[P4] Executing "p4 login -a"
Fatal client error; disconnecting!
No user-input supplied.
=> []
If anyone can suggest what I'm getting wrong, it'd be most welcome!

Thanks

Steve

#2 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 12 March 2014 - 07:42 PM

I assume all these commands work from the command line in the same sequence? If so try running "p4 info" from the command line and comparing it to the output of "p4.run_info"

For 2 above try this:

p4.password = "12345"
p4.run_login("-a")

It's key to set the password right before running login; the value seems to get cleared after running a Perforce command(which is odd.)

#3 RensterUK

RensterUK

    Member

  • Members
  • PipPip
  • 13 posts

Posted 13 March 2014 - 09:33 AM

Hi Matt,

I tried doing a p4.password immediately before run_login as you suggested:
irb(main):010:0> p4.password="<<ahem!>>"
=> "<<ahem!>>"
irb(main):011:0> p4.run_login("-a")
=> ["User Steve_Hall logged in."]
irb(main):012:0> p4.run_sync
P4Exception: [P4#run] Errors during command execution( "p4 sync" )

[Error]: Perforce password (P4PASSWD) invalid or unset.


I also tried a p4 info (cmd line) vs p4.run_info (irb). Apologies for the formatting - I couldn't find a decent way of pasting from excel into here  

Quote


p4.run_info within irb brokerAddress <<Edited out, but matched>> brokerCertExpire Jun 12 16:26:30 2023 GMT brokerEncryption encrypted brokerVersion P4BROKER/LINUX26X86_64/2013.3/784164 caseHandling insensitive clientAddress 166.98.70.90 clientCwd /home/steve clientHost Steve-Mint16 clientLock none clientName fullmars clientRoot /home/steve externalAuth enabled peerAddress 127.0.0.1:44928 security enabled serverAddress localhost:1667 serverDate 2014/03/13 02:10:25 -0700 PDT serverLicense <<Edited out, but matched>> serverLicense-ip 169.254.254.253 serverRoot /p4/1/root serverServices standard serverUptime 87:58:02 serverVersion P4D/LINUX26X86_64/2013.3/784164 (2014/02/07) userName steve_hall

  

Quote


p4 info from cmd line Broker address <<Edited out, but matched>> Broker cert expires Jun 12 16:26:30 2023 GMT Broker encryption encrypted Broker version P4BROKER/LINUX26X86_64/2013.3/784164 Case Handling insensitive Client address 166.98.70.90 Client host Steve-Mint16 Client name fullmars Client root /home/steve Current directory /home/steve Peer address 127.0.0.1:47551 Server address localhost:1667 Server date 2014/03/13 02:10:36 -0700 PDT Server license <<Edited out, but matched>> Server license-ip 169.254.254.253 Server root /p4/1/root Server uptime 87:58:13 Server version P4D/LINUX26X86_64/2013.3/784164 (2014/02/07) User name steve_hall



I also discovered the following
steve@Steve-Mint16 ~ $ . ./.p4config
steve@Steve-Mint16 ~ $ irb
irb(main):001:0> require "P4"
=> true
irb(main):002:0> p4 = P4.new
=> P4: [ssl:server:1666] steve_hall@fullmars (not connected)
irb(main):003:0> p4.connect => true
irb(main):004:0> system("p4 login") Enter password:
User Steve_Hall logged in.
=> true
irb(main):005:0> p4.run_sync
P4Exception: [P4#run] Warnings during command execution( "p4 sync" )
[Warning]: File(s) up-to-date.
So if I read my .p4config before starting IRB, and make a call out to the p4 login command, then the values for P4PASSWD seem to get set / persist. It's only when I set them within P4Ruby that I have problems. Unfortunately, while this IS a workaround, it's no good - this is all for use within a Rails / web project, so can't have such prompts there!

I sense I am oh-so-close. Yet definitely lacking a cigar still :)

Many thanks again

Steve

#4 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 13 March 2014 - 05:54 PM

Did you try the login -a with p4ruby using the syntax I suggested? If that fails it's a helpful clue.

#5 RensterUK

RensterUK

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 March 2014 - 08:57 AM

Not sure if you mean "p4.run_login("-a")" or "p4.run("login", "-a")"... So I just tried both to double check:

irb(main):001:0>	 require "P4"
=> true
irb(main):002:0>	 p4 = P4.new
=> P4: [perforce:1666] steve@Steve-Mint16 (not connected)
irb(main):003:0>	 p4.port = "ssl:server:1666"
=> "ssl:server:1666"
irb(main):004:0>	 p4.client = "fullmars"
=> "fullmars"
irb(main):005:0>	 output = `p4 set`
=> ""
irb(main):006:0>	 p output
""
=> ""
irb(main):007:0>	 p4.connect
=> true
irb(main):008:0>	 p4.user = "steve_hall"
=> "steve_hall"
irb(main):009:0>	 p4.password = "<<AHEM!>>"
=> "<<AHEM!>>"
irb(main):010:0>	 p4.run_login ("-a")
=> ["User Steve_Hall logged in."]
irb(main):011:0>

As opposed to

irb(main):001:0>	 require "P4"
=> true
irb(main):002:0>	 p4 = P4.new
=> P4: [perforce:1666] steve@Steve-Mint16 (not connected)
irb(main):003:0>	 p4.port = "ssl:server:1666"
=> "ssl:server:1666"
irb(main):004:0>	 p4.client = "fullmars"
=> "fullmars"
irb(main):005:0>	 output = `p4 set`
=> ""
irb(main):006:0>	 p output
""
=> ""
irb(main):007:0>	 p4.connect
=> true
irb(main):008:0>	 p4.user = "steve_hall"
=> "steve_hall"
irb(main):009:0>	 p4.password = "<<AHEM!>>"
=> "<<AHEM!>>"
irb(main):010:0>	 p4.run("login", "-a")
Fatal client error; disconnecting!
No user-input supplied.
=> []
irb(main):011:0>

the latter of course is equivalent to "p4 login -a" at the bash command line... which the prompts for PW - I guess this explains the "no user input" error...

Even with the apparently successful log in of the first:

irb(main):001:0> require "P4"
=> true
irb(main):002:0> p4 = P4.new
=> P4: [perforce:1666] steve@Steve-Mint16 (not connected)
irb(main):003:0> p4.port = "ssl:server:1666"
=> "ssl:server:1666"
irb(main):004:0> p4.client = "fullmars"
=> "fullmars"
irb(main):005:0> output = `p4 set`
=> ""
irb(main):006:0> p output
""
=> ""
irb(main):007:0> p4.connect
=> true
irb(main):008:0> p4.user = "steve_hall"
=> "steve_hall"
irb(main):009:0> p4.password = "<<AHEM!>>"
=> "<<AHEM!>>"
irb(main):010:0> p4.run_login ("-a")
=> ["User Steve_Hall logged in."]
irb(main):011:0> p4.password = "<<AHEM!>>"
=> "<<AHEM!>>"
irb(main):012:0> # puts system("p4", "set")
irb(main):013:0* puts p4.run_sync
P4Exception: [P4#run] Errors during command execution( "p4 sync" )

[Error]: Perforce password (P4PASSWD) invalid or unset.


#6 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 14 March 2014 - 05:01 PM

Ok this is... peculiar. Here's what I would try next(I tried to repro the issue but failed, so I have to flail remotely though you).

In your home directory you will have a file called '.p4tickets'. This is where the token generated by 'p4 login' is stored. Delete it or move it aside, and then do the login -a sequence above. We should see a new entry get created in that .p4tickets file. If there is, it would be interesting to see what hostname it associates with the ticket.

Another thing to try:
ticket=p4.run_login("-a", "-p")
p4.passwd=ticket
p4.run_sync

On the off chance that for some reason your ruby app can't write or read from the tickets file, you can grab the ticket and use it directly as the password.

#7 RensterUK

RensterUK

    Member

  • Members
  • PipPip
  • 13 posts

Posted 17 March 2014 - 09:05 AM

Morning Matt,

STOP THE PRESS! your "Another thing to try" seems to be the answer! Final code:

	require "P4"
	p4 = P4.new
	p4.port = "ssl:perforce.ourserver.com:1666"
	p4.client = "fullmars"
	p4.connect
	p4.user = "steve_hall"
	p4.password = "<<AHEM!>>"
	ticket = p4.run_login("-a", "-p")
	p4.password = ticket.first # Ruby gets tickets as an array - albeit of size 1!
	puts p4.run_sync
	p4.disconnect

If it helps - the ownership/permissions of the created .p4tickets is 400, steve:steve. Note the local user is "steve" while the remote server username is "steve_hall"... Could this have any significance?

Anyway, we're up and running it seems! Fantastic stuff, thanks Matt!

#8 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 17 March 2014 - 04:03 PM

View PostRensterUK, on 17 March 2014 - 09:05 AM, said:

If it helps - the ownership/permissions of the created .p4tickets is 400, steve:steve. Note the local user is "steve" while the remote server username is "steve_hall"... Could this have any significance?

The usernames shouldn't have any impact, but I have seen a number of cases where the account running the web application doesn't have a home directory to write the ticket to, leading to tears. I'm glad to hear you're up and running.

#9 mrose

mrose

    Member

  • Members
  • PipPip
  • 10 posts

Posted 09 September 2014 - 01:17 AM

View PostP4Matt, on 12 March 2014 - 07:42 PM, said:

It's key to set the password right before running login; the value seems to get cleared after running a Perforce command(which is odd.)

I think I am running into a similar problem. I am issuing p4 command through perl system calls in a jenkins job. The pseudocode looks something like:
From shell script:
1. p4 login
2. p4 login -s (to verify that it worked)
3. Run perl script
  From perl script:
  1. p4 workspaces (works)
  2. p4 client (works)
  3. p4 where (works)
  4. p4 where (works)
  5. p4 changes (works)
  6. p4 sync -n (Error: Perforce password (P4PASSWD) invalid or unset.)
  7. p4 files (Error: Perforce password (P4PASSWD) invalid or unset.)
  8. p4 opened (Error: Perforce password (P4PASSWD) invalid or unset.)
4. p4 logout (Error: Perforce password (P4PASSWD) invalid or unset.)

After a couple hours of bashing my head against the monitor, I tried setting P4TICKETS to a location on the local hard drive (we have our home directories NFS mounted). I haven't seen any password errors since doing this, though I still don't know why it was happening in first place. Thoughts?

Also I am on a 2013.3 Perforce server.

#10 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 10 September 2014 - 04:26 PM

Not a clue. I'll put it front of the server team and see if they have any thoughts.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users