Skip to content
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

userHome is not correctly used in remote environments #83213

Closed
4 of 5 tasks
bpasero opened this issue Oct 24, 2019 · 6 comments
Closed
4 of 5 tasks

userHome is not correctly used in remote environments #83213

bpasero opened this issue Oct 24, 2019 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug remote Remote system operations issues
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Oct 24, 2019

While looking into how to support IEnvironmentService.userHome in web, I realized that most usages are wrong to begin with: if you are connected to a remote file system, the local userHome is typically not what you want. Rather, IRemoteAgentEnvironment.userHome should be used.

You can easily see this for example in quick open: type ~/.bash_profile and it will not show you a file in remote even if this file exists in the user home on the remote.

I see a bit of overlap with the recently introduced IRemotePathService where maybe this should be added too?

Locations:

I think a good example of a proper use is this code from terminalTaskSystem:

private async getUserHome(): Promise<URI> {
	const env = await this.remoteAgentService.getEnvironment();
	if (env) {
		return env.userHome;
	}
	return URI.from({ scheme: Schemas.file, path: this.environmentService.userHome }); //
}

I think a more generalized solution would be something along the lines of:

async resolveUserHome(): Promise<void> {

	// No remote: user home can only be local
	if (!this.environmentService.configuration.remoteAuthority) {
		this._userHome = URI.file(this.environmentService.userHome);
	}

	// Remote: resolve user home from remote
	else {
		const remoteAgentEnvironment = await this.remoteAgentService.getEnvironment();
		if (remoteAgentEnvironment) {
			this._userHome = remoteAgentEnvironment.userHome;
		}
	}
}
@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug remote Remote system operations issues labels Oct 24, 2019
@roblourens
Copy link
Member

Yeah I was looking at that too then got sidetracked by trying to decide whether RemotePathService should exist at all. @aeschli made a good point that maybe all path operations should happen in the remote.

From #82739 (comment) it sounds like we are also thinking about workspaces that mix different types of remotes, which require even fancier handling.

@bpasero
Copy link
Member Author

bpasero commented Jan 14, 2020

I added IRemotePathService.userHome and adopted it for the file quick open.

@isidorn
Copy link
Contributor

isidorn commented Jan 14, 2020

I acknowledge the issue, however it is a bit problemtic to change since it would make all the calls async since IRemotePathService.userHome is a Promise. This would spread to all the users of the labelService making them async and there is too much of those imho.
Thus I will make no changes atm.

@bpasero
Copy link
Member Author

bpasero commented Jan 14, 2020

@isidorn one way out here would be to resolve the user home in the remote service and provide a sync getter which is possibly undefined. You could then use that as a hint in the label service if defined. The service could even have an event when the value is resolved for labels to resolve again (though not sure that would be really needed).

@isidorn
Copy link
Contributor

isidorn commented Jan 14, 2020

Yes that makes sense.

@isidorn
Copy link
Contributor

isidorn commented Apr 7, 2020

This is a duplicate, you just reopend this same issue I bleive. Thus closing

@isidorn isidorn closed this as completed Apr 7, 2020
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug remote Remote system operations issues
Projects
None yet
Development

No branches or pull requests

4 participants