New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command 'perforce.edit' not found #96

Closed
hessellund opened this Issue Sep 18, 2017 · 31 comments

Comments

Projects
None yet
8 participants
@hessellund
Copy link

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?
perforce-error

@stef-levesque

This comment has been minimized.

Copy link
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

@stef-levesque

This comment has been minimized.

Copy link
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",
}
@hessellund

This comment has been minimized.

Copy link
Author

hessellund commented Sep 18, 2017

Does it make a difference that I am running Windows?

@stef-levesque

This comment has been minimized.

Copy link
Owner

stef-levesque commented Sep 18, 2017

No it shouldn't

@sigmer

This comment has been minimized.

Copy link

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.

@stef-levesque

This comment has been minimized.

Copy link
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.

More info here: https://github.com/stef-levesque/vscode-perforce/blob/master/README.md#activation

@rhummer

This comment has been minimized.

Copy link

rhummer commented Sep 19, 2017

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

This comment has been minimized.

Copy link

mattyork commented Sep 19, 2017

Second what rhummer said.

@tivac

This comment has been minimized.

Copy link

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.

@stef-levesque

This comment has been minimized.

Copy link
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)

@stef-levesque

This comment has been minimized.

Copy link
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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

@stef-levesque

This comment has been minimized.

Copy link
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"

@vrachels

This comment has been minimized.

Copy link
Contributor

vrachels commented Sep 19, 2017

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

@hessellund

This comment has been minimized.

Copy link
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?

@hessellund

This comment has been minimized.

Copy link
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.

@stef-levesque

This comment has been minimized.

Copy link
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

This comment has been minimized.

Copy link

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",
}
@stef-levesque

This comment has been minimized.

Copy link
Owner

stef-levesque commented Sep 20, 2017

@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

This comment has been minimized.

Copy link

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.

@hessellund

This comment has been minimized.

Copy link
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.

@stef-levesque

This comment has been minimized.

Copy link
Owner

stef-levesque commented Sep 20, 2017

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

@vrachels

This comment has been minimized.

Copy link
Contributor

vrachels commented Sep 20, 2017

fixing

@vrachels

This comment has been minimized.

Copy link
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?

@stef-levesque

This comment has been minimized.

Copy link
Owner

stef-levesque commented Sep 20, 2017

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

@vrachels

This comment has been minimized.

Copy link
Contributor

vrachels commented Sep 20, 2017

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

@hessellund

This comment has been minimized.

Copy link
Author

hessellund commented Oct 12, 2017

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

@stef-levesque

This comment has been minimized.

Copy link
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

This comment has been minimized.

Copy link

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 😃

@hessellund

This comment has been minimized.

Copy link
Author

hessellund commented Oct 18, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment