coffee
coffee

Reputation: 251

How to log in as a user in p4

I have an issue where users are trying to log in to their Perforce account using p4 command line (not p4v visual client), but it seems to start at a default account without permissions. When they try to logout with

p4 logout

the users get following error

"Access for user "foo" has not been enabled by 'p4 protect'".

What is the standard way of logging out and logging in via p4 command line?

Upvotes: 23

Views: 56756

Answers (4)

aflat
aflat

Reputation: 4329

For ease of use, make sure to set your username via the P4USER environment variable first, then use p4 login and p4 logout You could also use p4 -u <username> login

Upvotes: 19

Helmut Granda
Helmut Granda

Reputation: 4705

The following command fixed my problems. It is definitely what a flat described above but I am spelling it out for those who get confused with the extra comments and information.

For Windows and Mac OS X user

p4 set P4USER=<username>

For Linux users as there is no registry to store values of environment variables

export P4USER=<username>

you can then use

p4 info

to verify that the new username is being used.

Upvotes: 17

JohnGH
JohnGH

Reputation: 843

To fix

*"Access for user 'foo' has not been enabled by 'p4 protect'."

Edit the permissions table and give the group that they're in access to read something.

If you're on Unix you can login as an admin account and run:

p4 protect

This will open the "Protections:" table in a text editor.

Add this at the bottom:

read group foo-group * //foo/...

(where foo-group is a group that foo is in, and //foo/... is a depot you want foo-group to have read access to)

NOW the user foo should be able to login.

Upvotes: 3

user1527651
user1527651

Reputation: 405

For me p4 -u username login worked, but when I tried to run other commands like p4 sync it was using the local username, so I used p4 -u username sync, it appears to work. I think every p4 command should start with p4 -u username

Upvotes: 5

Related Questions