7

Firstly i'm a total beginer with Perforce, and i'm learning through its documentations mostly.

So, we are about to migrate from CVS to Perforce, and i recently learned a good way to avoid changing the P4CLIENT for each workspace, which is creating a P4CONFIG file inside the workspace root.

So i have used the command:

p4 set P4CONFIG=p4config

(and my current directory is my workspace root, and the p4config.txt is located there)

in my p4config file i have the following:

P4PORT=host:port
P4USER=user
P4CLIENT=myWorkspace

i have already created 'myWorkspace' with the command 'p4 client' mapping to myworkspace root and its alright.

However when i try the command

p4 info

it shows my 'client name:' as my hostname, showing that the variable haven't been set.

and when i try 'p4 set P4CONFIG' it prints:

P4CONFIG=p4config.txt (set) (config 'noconfig')

I've tried with my p4config.txt full path, and still gets the same...

Does anyone have any idea what the problem is?

By the way, it's running on Windows.

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
Bruno Brs
  • 673
  • 1
  • 6
  • 23

2 Answers2

16

If the file is 'p4config.txt', then you should do

p4 set P4CONFIG=p4config.txt

not

p4 set P4CONFIG=p4config

You'll know it's working when 'p4 set' prints "(config 'p4config.txt')".

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • 1
    Yes, i just wrote it wrong here... however i'm still getting same error. – Bruno Brs Aug 20 '13 at 11:26
  • 1
    I realized the problem... My physical file is 'p4config.txt', but perforce for some reason reads it as 'p4config.txt.txt'... Anyone has any idea why? By the tests i have done, when i try to add a file manually, it appends '.txt' to some of my filenames. – Bruno Brs Aug 20 '13 at 11:33
  • 5
    It's probably the Windows "Notepad" tool that is adding the ".txt" extension to your file names. Make sure that when you save the file in Notepad, you change the drop list from "Save as type: *.txt" to "Save as type: All Files". Then Notepad will leave the name of the file alone. – Bryan Pendleton Aug 20 '13 at 21:45
0

I had the same problem on Windows and I was finally able to figure it out. I kept on getting:

P4CONFIG=p4config.txt (set) (config 'noconfig')

But I had the variable set correctly as per the documentation.

Even though the P4V documentation states to add just the file name, I had to also include the full path to file. I had to do it for both P4CONFIG and P4IGNORE.

Now when I run p4 set I see all of the correct information.

chavab_1
  • 237
  • 2
  • 10
  • p4 looks for the P4CONFIG file in your current directory and its parents -- so if your P4CONFIG file is in C:\myroot and your current directory is C:\somewhereelse, p4 won't pick it up. This is so that you can have multiple P4CONFIG files (usually one per client root). – Samwise Jun 15 '17 at 17:32
  • Oh, OK that makes sense. I'm new to Perforce so I'm still getting the hang of it. So does this mean we need to create multiple P4CONFIG files? I only have one workspace and I use P4V to connect to it. I was setting up Sublime P4V plugin so I needed to make sure Sublime could connect to my workspace. After reading documentation I found that I had to set the P4 variables on my command prompt to make sure Sublime was able to use them. That is what lead to my problem. So my question now is, what directory should I have created this new P4CONFIG file to be used by Sublime? – chavab_1 Jun 15 '17 at 18:00
  • If you only have one workspace just use "p4 set" directly for all of your settings. P4CONFIG is an indirection that's only really useful if you're working in the shell and have multiple workspaces. If you're not working in the shell and there's no concept of a working directory, there's no way for the right config file to be chosen, and if you only have one workspace, there's no point in having multiple configurations anyway. – Samwise Jun 15 '17 at 20:18
  • Yeah, I understand that but the way the Sublime plugin works is that it communicates through the shell. And when I was using just `p4 set` Sublime wasn't able to communicate. It wasn't until I set the P4CONFIG file correctly that I got it to work. Maybe something else was causing the problem then. Either way, I got it to work finally. – chavab_1 Jun 16 '17 at 21:03
  • If P4CONFIG works then `p4 set` should work too -- the main difference is that `p4 set` always works globally regardless of current directory. (If you use both, P4CONFIG takes precedence.) – Samwise Jun 16 '17 at 21:23