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

Pyenv user install fails when using pyenv-virtualenv due to dubious ownership #102

Open
dreambeyondorange opened this issue May 19, 2023 · 0 comments

Comments

@dreambeyondorange
Copy link

We are currently in the process of upgrading from 3.5.1 to 4.2.1. With the removal of the system and user installation resources, we have converted our python install to this

# frozen_string_literal: true

provides :install_pyenv
unified_mode true

# Resource:: to create a Python virtual environment for a given user

property :python_version, String
property :prefix, String
property :user_only, [true, false], default: false
property :user, String

default_action :run

action :run do
  python_version = new_resource.python_version || node['cluster']['python-version']

  if new_resource.user_only
    raise "user property is required for resource install_pyenv when user_only is set to true" unless new_resource.user

    pyenv_install 'user' do
      user new_resource.user
      prefix new_resource.prefix if new_resource.prefix
    end

  else
    prefix = new_resource.prefix || node['cluster']['system_pyenv_root']

    directory prefix do
      recursive true
    end

    pyenv_install 'system' do
      prefix prefix
    end

    # Remove the profile.d script that the pyenv cookbook writes.
    # This is done in order to avoid exposing the ParallelCluster pyenv installation to customers
    # on login.
    file '/etc/profile.d/pyenv.sh' do
      action :delete
    end
  end

  pyenv_python python_version do
    user new_resource.user if new_resource.user_only
  end

  pyenv_plugin 'virtualenv' do
    git_url 'https://github.com/pyenv/pyenv-virtualenv'
    user new_resource.user if new_resource.user_only
  end
end

With the user install we get git directory ownership errors, but it seems that the ownership should be consistent between the user pyenv install and the pyenv plugin call. But is there more to it than that?

[2023-05-19T16:25:53+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: install_pyenv[3.9.16] (aws-parallelcluster-scheduler-plugin::install_python line 19) had an error: Mixlib::ShellOut::ShellCommandFailed: pyenv_plugin[virtualenv] (aws-parallelcluster-scheduler-plugin::install_python line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: git[Install virtualenv plugin] (aws-parallelcluster-scheduler-plugin::install_python line 21) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
       ---- Begin output of git remote add origin https://github.com/pyenv/pyenv-virtualenv ----
       STDOUT: 
       STDERR: fatal: detected dubious ownership in repository at '/opt/parallelcluster/pyenv/plugins/virtualenv'
       To add an exception for this directory, call:
       
       	git config --global --add safe.directory /opt/parallelcluster/pyenv/plugins/virtualenv
       ---- End output of git remote add origin https://github.com/pyenv/pyenv-virtualenv ----
       Ran git remote add origin https://github.com/pyenv/pyenv-virtualenv returned 128

Here's a link to the build https://github.com/aws/aws-parallelcluster-cookbook/actions/runs/5026067699/jobs/9013883617?pr=2169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant