# stef-levesque/vscode-perforce

Closed
opened this Issue Sep 18, 2017 · 31 comments

Projects
None yet
8 participants

### hessellund commented Sep 18, 2017

 Hi, I upgraded VS Code Yesterday to 1.16.1 and everything worked fine as usual. This morning I upgraded the "Perforce for VS Code" extension to 2.2.0 and then I started getting errors such as the following when running ALT + P, E for opening for edit command 'perforce.edit' not found What happened?
Owner

### stef-levesque commented Sep 18, 2017

 Can you try to create an empty .p4config file at the root of your workspace ? We are still in flux on how to properly support multiple workspaces
Owner

### stef-levesque commented Sep 18, 2017

 Otherwise, please specify the following in your vscode workspace or user settings: { "perforce.client": "your_client", "perforce.user": "your_user", "perforce.port": "example.com:1666", }
Author

### hessellund commented Sep 18, 2017

 Does it make a difference that I am running Windows?
Owner

### stef-levesque commented Sep 18, 2017

 No it shouldn't

### sigmer commented Sep 19, 2017

 I have the same problem beginning yesterday. No perforce commands were found. I added a blank .p4config at the root of my vscode project folder and now it works.
Owner

### stef-levesque commented Sep 19, 2017

 The autodetect might have a flaw in your case. If you install version 2.2.1, you can set perforce.activationMode to always. This will skip the autodetect part and always try to enable it.

### rhummer commented Sep 19, 2017 • edited

 The new version with perforce.activationMode set to always resolved the issue for me. I have a .p4config file higher up in my directory structure. My directory setup: c:\foo\.p4config <- this is where my config is c:\foo\bar\baz\workspaceroot\ <- this is where my project is.

### mattyork commented Sep 19, 2017

 Second what rhummer said.

### tivac commented Sep 19, 2017

 I use P4CONFIG=p4.ini and it's failing to detect the p4.ini file in the root of my vscode project folder. Also having the issue where my P4CONFIG file is usually several directories above the project folder, but this also seemed worth bringing up as a concern.
Owner

### stef-levesque commented Sep 19, 2017

 @tivac you should then use "perforce.activationMode": "always" In this mode, we let P4 do the hard job of find the config, but this will likely cause problem when VSCode will support multiple workspaces (i.e. need to support multiple SCM instances)
Owner

### stef-levesque commented Sep 19, 2017

 @vrachels we are currently looking at an hardcoded .p4config file. Would it make sense to look for the env vars P4CONFIG for the file to parse ?

### tivac commented Sep 19, 2017

 @stef-levesque yeah, I've switched over to always and that at least got me able to run the commands. The commands are now erroring out for me though, so I'm working to see if I can narrow that down and maybe file a new bug.

### rhummer commented Sep 19, 2017

 @stef-levesque You can't just look at the env vars, you also need to look at p4 set. At my office we set zero p4 vars as env vars, we rely on p4 set defining everything including our P4CONFIG file
Owner

### stef-levesque commented Sep 19, 2017

 @rhummer if you have a batch file or something that call some p4 set commands, you might want to open VSCode from that same command prompt, and use "perforce.activationMode": "always"
Contributor

### vrachels commented Sep 19, 2017

 (#98) to check p4 set for P4Config (which does check for env variable, also)
Author

### hessellund commented Sep 20, 2017

 I upgraded to 2.2.1 and set "perforce.activationMode": "always". All my perforce workspaces have a p4.cfg file at the root. All our developer machines configures this by P4CONFIG=p4.cfg. Now the Perforce for VSCode extension can find the commands but they still fail? Here is the output when I attempt a login for instance: p4.exe info p4.exe login -s ERROR: "Error: Command failed: p4.exe login -s\nPerforce client error:\r\n\tConnect to server failed; check $P4PORT.\r\n\tTCP connect to depot:1666 failed.\r\n\tNo such host is known. \r\n" ERROR: "Perforce client error:\r\n\tConnect to server failed; check$P4PORT.\r\n\tTCP connect to depot:1666 failed.\r\n\tNo such host is known. \r\n" p4.exe login -s p4.exe login ERROR: "Command failed: p4.exe login\nPerforce client error:\r\n\tConnect to server failed; check \$P4PORT.\r\n\tTCP connect to depot:1666 failed.\r\n\tNo such host is known. \r\n"  Any ideas?
Author

### hessellund commented Sep 20, 2017

 One more observation about the above error. I can see that the failure is caused by the global P4PORT being incorrectly set to P4PORT=depot:1666 rather than P4PORT=depot.myactualhost.com:1666. In my p4.cfg file (in the root of my Perforce workspace), it is, however, configured correctly to P4PORT=depot.myactualhost.com:1666. In other words, on version 2.2.1 with "perforce.activationMode": "always", the Perforce for VSCode Extension can read the global configuration but it ignores the configuration file.
Owner

### stef-levesque commented Sep 20, 2017

 @hessellund can you open a Terminal in your VSCode workspace and run p4 set I suspect something is wrong with the P4CONFIG env vars

### Swoogan commented Sep 20, 2017

 I am having this issue too. I have P4CONFIG=.p4config and a .p4config further up in the directory tree of where my project is located. I didn't get the perforce integration until I set "perforce.activationMode": "always". However, I am still getting errors: ERROR: "Path 'filename' is not under client's root 'WRONG CLIENT NAME'.\r\n" When I ran Display client/server information I noticed the source of all the problems: Current directory: c:\Program Files (x86)\Microsoft VS Code All the perforce commands are being run from the VS code directory and not the project directory. That explains why the integration doesn't turn on with "autodetect" and why all commands fail. The workaround is to override the settings with { "perforce.client": "your_client", "perforce.user": "your_user", "perforce.port": "example.com:1666", } 
Owner

### stef-levesque commented Sep 20, 2017 • edited

 @vrachels the current directory issue sounds like a regression. All p4 commands had previously been, and should still be, run with the workspace path as the current directly. PerforceService.ts#L147 var child = CP.exec(cmdLine, { cwd: _config ? _config.localDir : undefined, maxBuffer: maxBuffer }, responseCallback); This might come from here. If the _config is undefined, or _config.localDir is empty, we should at least provide the current workspace path as cwd Thoughts ?

### tivac commented Sep 20, 2017

 Ah, good catch @Swoogan! @stef-levesque I'm seeing the same issue as well, the incorrect directory making all p4 commands fail because their built-in config file loading doesn't work.
Author

### hessellund commented Sep 20, 2017

 @stef-levesque I ran p4 set in the VS Code terminal. The output looks correct, i.e., like what I would expect from the configuration file. The commands, however, still don't work. The last couple of posts about the current directory sounds like a very likely suspect.
Owner

### stef-levesque commented Sep 20, 2017

 @hessellund you are right, the CWD seems like the real culprit
Contributor

 fixing
Contributor

### vrachels commented Sep 20, 2017

 the 'always' case isn't really a valid configuration with this fix (no p4 found, no client workspace configured, etc). do you want to leave it in?
Owner

### stef-levesque commented Sep 20, 2017

 The goal of always is to register the perforce commands, with or without a valid p4 configuration.
Contributor

### vrachels commented Sep 20, 2017 • edited

 (#99), also removes the pathstripping needed by p4dir unless p4dir is actually enabled. See also comment on req #94
Author

### hessellund commented Oct 12, 2017

 Hi again, is the fix coming out in a release. Do you have anything planned?
Owner

### stef-levesque commented Oct 17, 2017

 I pushed a new version of the extension (2.2.2) Let me know if it resolve your issue.

### tivac commented Oct 17, 2017

 @stef-levesque auto-open files for edit is working for me after installing 2.2.2! Thanks so much for all your work on this extension, it makes vscode + perforce sooooo smooth 😃

Author

### hessellund commented Oct 18, 2017

 Great work, @stef-levesque!! You rock. It solved the problem. Thanks a lot