Skip to content

Install your own plugins on the intranet and configure UV account passwords and Nexus certificates using environment variables. #768

Description

@smartnolike

Self Checks

To make sure we get to you in time, please check the following :)

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • "Please do not modify this template :) and fill in all the required fields."

Is your feature request related to a problem? Please describe.
In dify-plugin-daemon/internal/core/local_runtime/setup_python_environment.go, [exec.CommandContext] creates a child process, but apend overwrites all environment variables of the main process. This prevents me from passing in my own Nexus account&pwd&certificate and related configuration parameters, such as UV_INDEX_NEXUS_USERNAME and UV_INDEX_NEXUS_PASWORD and SSL_CERT_FILE, which I cannot use correctly. Therefore, is it possible to enhance this so that UV can inherit the parent process's environment variables when it starts?
Source code:
`

log.Info("uv command", "cmd", uvPath, "args", args)
virtualEnvPath := path.Join(p.State.WorkingPath, ".venv")
uvCacheDir := path.Join(p.appConfig.PluginWorkingPath, ".uv-cache")
cmd := exec.CommandContext(ctx, uvPath, args...)
parent.SetAttributes(attribute.String("uv.path", uvPath), attribute.StringSlice("uv.args", args))
cmd.Env = append(cmd.Env, "VIRTUAL_ENV="+virtualEnvPath, "PATH="+os.Getenv("PATH"))
cmd.Env = append(cmd.Env, "UV_CACHE_DIR="+uvCacheDir)
if p.appConfig.HttpProxy != "" {
	cmd.Env = append(cmd.Env, fmt.Sprintf("HTTP_PROXY=%s", p.appConfig.HttpProxy))
}
if p.appConfig.HttpsProxy != "" {
	cmd.Env = append(cmd.Env, fmt.Sprintf("HTTPS_PROXY=%s", p.appConfig.HttpsProxy))
}
if p.appConfig.NoProxy != "" {
	cmd.Env = append(cmd.Env, fmt.Sprintf("NO_PROXY=%s", p.appConfig.NoProxy))
}
cmd.Dir = p.State.WorkingPath`

Describe the solution you'd like
Modify code:
`

log.Info("uv command", "cmd", uvPath, "args", args)
virtualEnvPath := path.Join(p.State.WorkingPath, ".venv")
uvCacheDir := path.Join(p.appConfig.PluginWorkingPath, ".uv-cache")
cmd := exec.CommandContext(ctx, uvPath, args...)
parent.SetAttributes(attribute.String("uv.path", uvPath), attribute.StringSlice("uv.args", args))
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "VIRTUAL_ENV="+virtualEnvPath, "PATH="+os.Getenv("PATH"))
cmd.Env = append(cmd.Env, "UV_CACHE_DIR="+uvCacheDir)
if p.appConfig.HttpProxy != "" {
	cmd.Env = append(cmd.Env, fmt.Sprintf("HTTP_PROXY=%s", p.appConfig.HttpProxy))
}
if p.appConfig.HttpsProxy != "" {
	cmd.Env = append(cmd.Env, fmt.Sprintf("HTTPS_PROXY=%s", p.appConfig.HttpsProxy))
}
if p.appConfig.NoProxy != "" {
	cmd.Env = append(cmd.Env, fmt.Sprintf("NO_PROXY=%s", p.appConfig.NoProxy))
}
cmd.Dir = p.State.WorkingPath`

`
Describe alternatives you've considered
If inheriting all parent class variables results in conflicts, is it possible to only import custom environment variables and skip the rest?

Additional context
Version: 0.6.3
My main reason is that I want to configure my account password in GCP Secret Manager and don't want it to be exposed, while also being able to use the company's own Nexus repository.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions