Giter Site home page Giter Site logo

sous-chefs / pyenv Goto Github PK

View Code? Open in Web Editor NEW
27.0 19.0 28.0 232 KB

Development repository for the pyenv cookbook

Home Page: https://supermarket.chef.io/cookbooks/pyenv

License: Apache License 2.0

Ruby 98.24% Shell 1.76%
chef-cookbook chef-resource pyenv chef hacktoberfest managed-by-terraform

pyenv's Introduction

pyenv Chef Cookbook

Cookbook Version Build Status OpenCollective OpenCollective License Maintainability

Description

Manages pyenv and its installed Pythons.

Chef

This cookbook requires Chef 15.3+.

Platform family

  • Debian derivatives (debian, ubuntu)
  • Fedora
  • RHEL derivatives (RHEL, CentOS, Amazon Linux, Oracle, Scientific Linux)
  • openSUSE and openSUSE leap

Usage

Examples installations are provided in test/fixtures/cookbooks/test/recipes

A pyenv_install is required to be set so that pyenv knows which version you want to use, and is installed on the system.

Resources

System-Wide Mac Installation Note

This cookbook takes advantage of managing profile fragments in an /etc/profile.d directory, common on most Unix-flavored platforms. Unfortunately, Mac OS X does not support this idiom out of the box, so you may need to [modify][mac_profile_d] your user profile.

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

pyenv's People

Contributors

aogail avatar athiede-vendavo avatar axelrtgs avatar damacus avatar darwin67 avatar dependabot-preview[bot] avatar dependabot[bot] avatar frank-m avatar gabrielsandoval avatar gbagnoli avatar hirose31 avatar ian-park-kakao avatar jtschelling avatar kitchen-porter avatar ksnavely avatar lukeseawalker avatar markgibbons avatar nelsonjchen avatar petracvv avatar pierrerambaud avatar ramereth avatar renovate[bot] avatar sds avatar vytstank avatar whatcould avatar xorima avatar xorimabot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyenv's Issues

Add support for CentOS 8 (python 3)

๐Ÿคฏ Problem Statement

In CentOS 8 (RHEL 8, etc) python2 is deprecated and you should work with python 3 only. However there is no link for 'pip' to 'pip3'. This feature request is to look at the best way to disallow python 2 for centos 8 and update the places were necessary to use the native python3 / pip3 binaries.

โ” Possible Solution

I am currently working around it by doing this (requires Alternatives cookbook):

package 'python3-pip'

if node['platform_version'].to_i >= 8
  alternatives 'pip set version 3' do
    link_name 'pip'
    path '/usr/bin/pip3'
    priority 1
    action :install
  end
end

โคด๏ธ Describe alternatives you've considered

As RHEL 8 family is quite new and adoption might be low currently I suspect not many people noticed the cookbook not working out of the box. I considered going the python2 route on rhel 8 family, but strongly feel this is the incorrect way to move forward.
Especially as I read rhel 8 family has deprecated python 2, which means it might not be as maintained as one might want.

โž• Additional context

N/A

Set working default kitchen.yml values. Document test setup requirements.

Cookbook version

master

Chef-client version

ChefDK 3.11.3

Platform Details

Ubuntu 18.04

Scenario:

Run test suite before making PR.

Steps to Reproduce:

git clone ....
cd chef-pyenv
kitchen test

Expected Result:

Green tests

Actual Result:

Various errors related to Ominbus truck artifact repository. Example

ERROR 404
       Omnitruck artifact does not exist for version current on platform el
       
       Either this means:
          - We do not support el
          - We do not have an artifact for current
       
       This is often the latter case due to running a prerelease or RC version of chef
       or a gem version which was only pushed to rubygems and not omnitruck.
       
       You may be able to set your knife[:bootstrap_version] to the most recent stable
       release of Chef to fix this problem (or the most recent stable major version number).
       
       In order to test the version parameter, adventurous users may take the Metadata URL
       below and modify the '&v=<number>' parameter until you successfully get a URL that
       does not 404 (e.g. via curl or wget).  You should be able to use '&v=11' or '&v=12'
       succesfully.
       
       If you cannot fix this problem by setting the bootstrap_version, it probably means
       that el is not supported.
       
       Metadata URL: https://omnitruck.chef.io/stable/chef/metadata?v=current&p=el&pv=6&m=x86_64

Does the kitchen.yml actually do anything?

I had some success with kitchen.dokken.yml....

Will you accept a PR switchen them around?:
kitchen.yml -> kitchen.vagrant.yml
kitchen.dokken.yml -> kitchen.yml

upload to chef supermarket

Could you upload this cookbook to chef supermarket?
using github as the source to download this cookbook doesn't seem to resolve nicely when it's nested.

Add the option to provide the python_version on any command

Would be nice to add a param to the resources of the cookbook in order to override the version of python.

For example:

pyenv_pip 'requests' do
  version '2.18.3'
  python_version '2.7.15'
end

This would update the requests library inside the python version 2.7.15 (let's suppose that the python version number 2.7.15 is already installed)

How it sounds like?

In other words, it's just a matter of using "PYTHON_VERSION" environment variable before any python/pip command.

Chef 13 support

================================================================================
Recipe Compile Error in /home/gionn/.local/share/chef-client-cache/cache/cookbooks/pyenv/attributes/default.rb
================================================================================

NoMethodError
-------------
undefined method `platform' for #<Chef::Node::Attribute:0x0000000004619820>

Cookbook Trace:
---------------
  /home/gionn/.local/share/chef-client-cache/cache/cookbooks/pyenv/attributes/default.rb:21:in `from_file'

Relevant File Content:
----------------------
/home/gionn/.local/share/chef-client-cache/cache/cookbooks/pyenv/attributes/default.rb:

 14:  # list of additional Pythons that will be installed
 15:  default['pyenv']['pythons']      = []
 16:  default['pyenv']['user_pythons'] = []
 17:  
 18:  # whether to create profile.d shell script
 19:  default['pyenv']['create_profiled'] = true
 20:  
 21>> case platform
 22:  when 'redhat', 'centos', 'fedora', 'amazon', 'scientific'
 23:    default['pyenv']['install_pkgs'] = %w[
 24:      bzip2 bzip2-devel
 25:      git
 26:      grep
 27:      patch
 28:      readline-devel
 29:      sqlite sqlite-devel
 30:      zlib-devel

System Info:
------------
chef_version=13.4.19
platform=ubuntu
platform_version=16.04
ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
program_name=chef-client worker: ppid=17483;start=12:09:22;
executable=/opt/chefdk/bin/chef-client

Deprecation Warnings for the pyenv cookbook

๐Ÿ‘ป Brief Description

Fairly long list of deprecation warnings related to this cookbook after a 'kitchen converge':

         The pyenv_global resource in the pyenv cookbook should declare `unified_mode true` at 1 location:
           - /tmp/kitchen/cache/cookbooks/pyenv/resources/global.rb
          See https://docs.chef.io/deprecations_unified_mode/ for further details.
         The pyenv_pip resource in the pyenv cookbook should declare `unified_mode true` at 1 location:
           - /tmp/kitchen/cache/cookbooks/pyenv/resources/pip.rb
          See https://docs.chef.io/deprecations_unified_mode/ for further details.
         The pyenv_plugin resource in the pyenv cookbook should declare `unified_mode true` at 1 location:
           - /tmp/kitchen/cache/cookbooks/pyenv/resources/plugin.rb
          See https://docs.chef.io/deprecations_unified_mode/ for further details.
         The pyenv_python resource in the pyenv cookbook should declare `unified_mode true` at 1 location:
           - /tmp/kitchen/cache/cookbooks/pyenv/resources/python.rb
          See https://docs.chef.io/deprecations_unified_mode/ for further details.
         The pyenv_rehash resource in the pyenv cookbook should declare `unified_mode true` at 1 location:
           - /tmp/kitchen/cache/cookbooks/pyenv/resources/rehash.rb
          See https://docs.chef.io/deprecations_unified_mode/ for further details.
         The pyenv_script resource in the pyenv cookbook should declare `unified_mode true` at 1 location:
           - /tmp/kitchen/cache/cookbooks/pyenv/resources/script.rb
          See https://docs.chef.io/deprecations_unified_mode/ for further details.
         The pyenv_system_install resource in the pyenv cookbook should declare `unified_mode true` at 1 location:
           - /tmp/kitchen/cache/cookbooks/pyenv/resources/system_install.rb
          See https://docs.chef.io/deprecations_unified_mode/ for further details.
         The pyenv_user_install resource in the pyenv cookbook should declare `unified_mode true` at 1 location:
           - /tmp/kitchen/cache/cookbooks/pyenv/resources/user_install.rb
          See https://docs.chef.io/deprecations_unified_mode/ for further details.

๐Ÿฅž Cookbook version

3.4.2

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

17.2.29

๐ŸŽฉ Platform details

MacOS with an Ubuntu 20.04 LTS test-kitchen.

Steps To Reproduce

Steps to reproduce the behavior:

kitchen converge default-ubuntu-2004

๐Ÿš“ Expected behavior

No deprecation warnings

Deprecated features used!

Deprecated features used!
  pyenv_version nil currently does not overwrite the value of pyenv_version. This will change in Chef 13, and the value will be set to nil instead. Please change your code to explicitly accept nil using "property :pyenv_version, [MyType, nil]", or stop setting this value to nil. at 1 location:
    - /home/gionn/.local/share/chef-client-cache/cache/cookbooks/pyenv/recipes/user.rb:24:in `block (2 levels) in from_file'

pyenv_system_install needs to install support packages in order to install pyenv_version

Hi there! First of all, thanks for your package! I'm really glad for being using this on my daily cookbooks.
Running your cookbook I realize that to install a new python version some packages are necessary for being installed before compiling a new version.

I found that you haven't installed the mandatory packages in order to compile a new version of python causing an error

           STDERR: Downloading Python-3.7.1.tar.xz...                                                                                                                                                                                                                                                                                                              [584/1704]
           -> https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
           Installing Python-3.7.1...
           
           BUILD FAILED (CentOS Linux 7 using python-build 1.2.9-19-g7d02b24)
           
           Inspect or clean up the working tree at /tmp/python-build.20190306024128.19576
           Results logged to /tmp/python-build.20190306024128.19576.log
           
           Last 10 log lines:
           checking for --enable-universalsdk... no
           checking for --with-universal-archs... no
           checking MACHDEP... checking for --without-gcc... no
           checking for --with-icc... no
           checking for gcc... no
           checking for cc... no
           checking for cl.exe... no
           configure: error: in `/tmp/python-build.20190306024128.19576/Python-3.7.1':
           configure: error: no acceptable C compiler found in $PATH
           See `config.log' for more details
           ---- End output of "bash" -e "/tmp/chef-script20190306-19110-1j2ozvf" ----
           Ran "bash" -e "/tmp/chef-script20190306-19110-1j2ozvf" returned 1

As a suggestion to solve this issue I've created a workarount to the issue, installing the missing packages, as follows:

['autoconf', 'automake', 'binutils', 'bison', 'flex', 'gcc', 'gcc-c++', 'gettext', 'libtool', 'make', 'patch', 'pkgconfig', 'redhat-rpm-config', 'rpm-build', 'rpm-sign', 'libffi-devel'].each do |pkg|
  yum_package pkg
end

More info can be reached at:
https://www.cyberciti.biz/faq/centos-rhel-7-redhat-linux-install-gcc-compiler-development-tools/

remarks: I haven't tested on debian based environments, but I can do it if you wish.

Thank you!

`pyenv init -` no longer sets PATH.

๐Ÿ‘ป Brief Description

With the release of pyenv version 2.0.0 (https://github.com/pyenv/pyenv/releases/tag/v2.0.0) there are path issues when python is installed system wide via pyenv

๐Ÿฅž Cookbook version

3.4.1

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

16

๐ŸŽฉ Platform details

Operating system: RHEL CentOS 7

Steps To Reproduce

Steps to reproduce the behavior:

Just include the below three lines in your wrapper cookbook. After converge, whenever any user logs in, they get the error message:
WARNING: pyenv init - no longer sets PATH.
Run pyenv init to see the necessary changes to make to your configuration.

Along with this message, it won't set the python path to the version provided.

pyenv_system_install 'system'
pyenv_python python_ver
pyenv_global python_ver

๐Ÿš“ Expected behavior

The above warning should not appear.
default python version should be set to pyenv_global 'version#'

โž• Additional context

node.run_state['root_path'] conflicts with rbenv cookbook

๐Ÿ‘ป Brief Description

This is a companion issue to this rbenv issue: sous-chefs/ruby_rbenv#285

When using both the rbenv and pyenv cookbooks together and installing python and ruby versions for the same user, the resources from the 2nd cookbook do not work. This is because the same internal run_state attribute is used for tracking the root_path in both cookbooks.

๐Ÿฅž Cookbook version

3.2.0

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

14.13.11

๐ŸŽฉ Platform details

RHEL7

Steps To Reproduce

Steps to reproduce the behavior:

  1. Write cookbook that creates a user and installs a ruby and python version for that user:
     user 'jenkins' do
       manage_home true
     end

     rbenv_user_install 'jenkins'

     rbenv_ruby '2.7.1' do
       user 'jenkins'
     end

     pyenv_user_install 'jenkins'

     pyenv_python '3.8.2' do
       user 'jenkins'
     end
  1. Run the recipe against a node in test-kitchen or a test env.
  2. See the pyenv python installation fail

๐Ÿš“ Expected behavior

I expect that both the ruby and python versions are installed with no error.

โž• Additional context

I can work around the problem with a ruby block in between the pyenv and rbenv resources:

ruby_block 'unset run_state' do
  block do
    node.run_state['root_path'] = {}
  end
end

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

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

Deprecated method `set`

Seeing the following warning when running with chef-client v12.19 or later.

[2017-05-30T17:11:54-07:00] WARN: method access to node attributes (node.foo.bar) is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]["bar"]) (CHEF-4)/tmp/chefspec20170530-32194-13l8ipifile_cache_path/cookbooks/pyenv/attributes/default.rb:21:in `from_file'.

Pollutes sous-chefs/ruby_rbenv `RBENV_ROOT`

Thanks for porting the rbenv cookbook. Not sure where responsibility lies - opening here since rbenv cookbook seems to have priority.

Cookbook version

3.1.0

Chef-client version

14.13.11

Platform Details

localhost         platform=ubuntu
localhost         platform_version=18.04
localhost         ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]

Scenario:

Manage Python using this cookbook.
Manage Ruby using sous-chefs/ruby_rbenv

Steps to Reproduce:

Include user install recipe from chef-pyenv/test/fixtures/cookbooks/test/recipes/user_install.rb
Include user install recipe from sous-chefs/ruby_rbenv/test/fixtures/cookbooks/test/recipes/user_install.rb

Expected Result:

Installs proceed.

Actual Result:

Ruby install fails with "RBENV_ROOT"=>"/home/hedge/.pyenv" in the following:

localhost         Compiled Resource:
localhost         ------------------
localhost         # Declared in /var/chef/cache/coolocalhost         Compiled Resource:
localhost         ------------------
localhost         # Declared in /var/chef/cache/cookbooks/ruby_rbenv/resources/script.rb:39:in `block in class_from_file'
localhost         
localhost         bash("rbenv install 2.5.5 (hedge)") do
localhost           action [:run]
localhost           default_guard_interpreter :default
localhost           command nil
localhost           backup 5
localhost           interpreter "bash"
localhost           declared_type :bash
localhost           cookbook_name "desktop"
localhost           code "export RBENV_ROOT=\"/home/hedge/.pyenv\"\nexport PATH=\"${RBENV_ROOT}/bin:$PATH\"\neval \"$(rbenv init -)\"\nrbenv install 2.5.5\n"
localhost           environment {"RBENV_ROOT"=>"/home/hedge/.pyenv", "USER"=>"hedge", "HOME"=>"/home/hedge"}
localhost           domain nil
localhost         ------------
localhost         chef_version=14.13.11
localhost         platform=ubuntu
localhost         platform_version=18.04
localhost         ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
localhost         program_name=/usr/bin/chef-client
localhost         executable=/opt/chef/bin/chef-client
kbooks/ruby_rbenv/resources/script.rb:39:in `block in class_from_file'
localhost         
localhost         bash("rbenv install 2.5.5 (hedge)") do
localhost           action [:run]
localhost           default_guard_interpreter :default
localhost           command nil
localhost           backup 5
localhost           interpreter "bash"
localhost           declared_type :bash
localhost           cookbook_name "desktop"
localhost           code "export RBENV_ROOT=\"/home/hedge/.pyenv\"\nexport PATH=\"${RBENV_ROOT}/bin:$PATH\"\neval \"$(rbenv init -)\"\nrbenv install 2.5.5\n"
localhost           environment {"RBENV_ROOT"=>"/home/hedge/.pyenv", "USER"=>"hedge", "HOME"=>"/home/hedge"}
localhost           domain nil
localhost         ------------
localhost         chef_version=14.13.11
localhost         platform=ubuntu
localhost         platform_version=18.04
localhost         ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
localhost         program_name=/usr/bin/chef-client
localhost         executable=/opt/chef/bin/chef-client

python-build definitions out of date

And there doesn't appear to be any mechanism to update them.

Latest versions provided by cookbook:
2.7.6
3.4.0

Latest versions of python:
2.7.13
3.6.2

chef-pyenv should download the latest list before running any python installs.

pyenv_python needs umask option

pyenv_python needs the umask option. If the umask of the user that executes chef-client is wrong the pyenv won't be accessible by every user.

Orphan Virtualbox processes.

Possibly related to issue #36

Cookbook version

Wrapper cookbook.

Chef-client version

Chef 14.13.11

Platform Details

[Operating system distribution and release version. Cloud provider if running in the cloud]

Scenario:

Run chef recipes without orphan processes.

Steps to Reproduce:

VirtualBox 5.2. Ubuntu 18.04.
Ruby recipe file (ruby_rbnev cookbook version 2.1.3)

version = '2.5.5'

node['desktop']['users'].each do |user|

  # Keeps the rbenv install upto date
  rbenv_user_install user

  rbenv_plugin 'ruby-build' do
    git_url 'https://github.com/rbenv/ruby-build.git'
    git_ref 'v20190615' #v20190615
    user    user
  end

  rbenv_plugin 'rbenv-chefdk' do
    git_url 'https://github.com/docwhat/rbenv-chefdk.git'
    git_ref 'master' # Git reference of the plugin
    user    user     # Optional: if passed installs to the users rbenv. Do not set, to set installs to the system rbenv.
  end

  rbenv_rehash 'rehash' do
    user user # Optional: if passed rehashes the user Ruby otherwise rehashes the system rbenv
  end
  
  rbenv_ruby version do
    # Need to add environment due to:
    # https://github.com/darwin67/chef-pyenv/issues/36
    # Hmmmm still doesn't workaround the defect above
    environment ({"RBENV_ROOT"=>"/home/hedge/.rbenv", "USER"=>"hedge", "HOME"=>"/home/hedge"})
    user user
  end

  rbenv_global version do
    user user
  end

end

Python recipe (pyenv version 3.1.0):

version   = '2.7.16'

node['desktop']['users'].each do |user|

  venv_root = "/home/#{user}/venv_test"

  pyenv_user_install user

  pyenv_python version do
    pyenv_action 'install'
    user         user
    environment  ({'PYTHONWARNINGS' => 'ignore:DEPRECATION'})
  end

  pyenv_global version do
    user user
  end

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

  %w{requests matplotlib numpy pandas wheel}.each do |pkg|
    pyenv_pip pkg do
      user        user
      options     '-qq'
    end
  end
  
  # Install after requirements are in place.
  pyenv_pip 'quantiacstoolbox' do
    version     '3.0.1'
    user        user
    options     '-qq'
  end

end

Expected Result:

The command:

knife zero bootstrap localhost --policy-name desktop --overwrite --sudo

Should not leave orphan processes.

Actual Result:

These are some of the processes on my machine.

$ ps aux | grep '/usr/.*VBoxHeadless --comment kitchen-chef'
hedge    11975  0.0  0.0  14432  1016 pts/2    S+   08:00   0:00 grep --color=auto /usr/.*VBoxHeadless --comment kitchen-chef
hedge    29048  0.8  1.4 1632152 242904 ?      Sl   Jul31  19:20 /usr/lib/virtualbox/VBoxHeadless --comment kitchen-chef-pyenv-user-install-oracle-7-e8e21f95-c97d-4155-8783-082a1dab7cfb --startvm f919d8f3-4283-43be-ab66-bdb76926de6e --vrde config
hedge    29255  0.8  1.5 1641636 245404 ?      Sl   Jul31  18:39 /usr/lib/virtualbox/VBoxHeadless --comment kitchen-chef-pyenv-system-install-oracle-7-9e69ac31-b61f-408b-85f8-ae7718638465 --startvm 90ef2328-3b0f-4d01-8553-862f5871fbdc --vrde config
hedge    30070  0.7  0.2 1614052 33776 ?       Sl   Jul31  18:09 /usr/lib/virtualbox/VBoxHeadless --comment kitchen-chef-pyenv-system-install-debian-8-8ac56b39-33e0-4b97-b8c3-8ed536470a07 --startvm d320fc75-d292-4add-9509-24e7d37ac30f --vrde config
hedge    32584  0.9  1.7 2251340 281680 ?      Sl   Jul31  21:10 /usr/lib/virtualbox/VBoxHeadless --comment kitchen-chef-pyenv-user-install-fedora-29-98123a07-3ddc-4d64-b3c8-3d93c0e7a1d1 --startvm abaf7a19-85a8-4c58-8c52-4a4274166e31 --vrde config

Separate installation and initialization in `pyenv_user_install` resource

:person_frowning: Problem Statement

The installation and activation of pyenv_user_install resources is currently inseparable. This makes it impossible to create an environment without also activating it.

โ” Possible Solution

The pyenv_user_install resource should have an attribute (something along the lines of activate?) that can be used to prevent activation of the newly created resource.

Support ubuntu 22.04

Problem Statement

Ubuntu 22.04 doesn't have the python-openssl package anymore, and it's called python3-openssl now

Possible Solution

Install python3-openssl instead of python-openssl on ubuntu 22.04

Multiple 'user' installs conflict

๐Ÿ‘ป Brief Description

When running mutiple pyenv_install as a user in a recipe (instead of old pyenv_user_install), the file /etc/profile.d/pyenv.sh gets replaced multiple times per chef run, and the second install errors out.

I expect a user install to not add anything to /etc/profile.d/, instead the user's ~/.profile maybe?

The code in question:

%w(user1 user2).each do |user|
  pyenv_install 'user' do
    user user
    prefix_type 'user'
    update_pyenv true
  end
end

This fails with the following output:

      ================================================================================
      Error executing action `checkout` on resource 'git[/home/athiede/.pyenv]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '1'
      ---- Begin output of git ls-remote "https://github.com/pyenv/pyenv.git" "master*" ----
      STDOUT:
      STDERR: /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout.rb:221:in `getgrnam': can't find group for athiede (ArgumentError)
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout.rb:221:in `gid'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:164:in `set_group'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:336:in `block in fork_subprocess'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:321:in `fork'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:321:in `fork_subprocess'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:97:in `run_command'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout.rb:270:in `run_command'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/helper.rb:154:in `__shell_out_command'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/helper.rb:128:in `shell_out_compacted!'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/helper.rb:54:in `shell_out!'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:390:in `git'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:350:in `git_ls_remote'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:300:in `remote_resolve_reference'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:287:in `target_revision'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:80:in `block (2 levels) in define_resource_requirements'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/mixin/why_run.rb:229:in `run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/mixin/why_run.rb:322:in `block in run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/mixin/why_run.rb:321:in `each'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/mixin/why_run.rb:321:in `run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:257:in `process_resource_requirements'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:233:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:601:in `block in run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:628:in `with_umask'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:600:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:74:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `block in run_all_actions'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `each'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `run_all_actions'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection.rb:64:in `insert'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/dsl/declare_resource.rb:267:in `declare_resource'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/dsl/resources.rb:36:in `git'
      	from /var/cinc/cache/cookbooks/pyenv/resources/install.rb:71:in `block in class_from_file'
      	from (eval):2:in `block in action_install'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:304:in `instance_eval'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:304:in `compile_and_converge_action'
      	from (eval):2:in `action_install'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:245:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:601:in `block in run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:628:in `with_umask'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:600:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:74:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `block in run_all_actions'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `each'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `run_all_actions'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:132:in `block in converge'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/resource_list.rb:96:in `block in execute_each_resource'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/stepable_iterator.rb:54:in `each_with_index'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/resource_list.rb:94:in `execute_each_resource'
      	from /opt/cinc/embedded/lib/ruby/3.1.0/forwardable.rb:238:in `execute_each_resource'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:130:in `converge'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:852:in `block in converge'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:847:in `catch'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:847:in `converge'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:871:in `converge_and_save'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:289:in `run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application.rb:305:in `run_with_graceful_exit_option'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application.rb:281:in `block in run_chef_client'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/local_mode.rb:42:in `with_server_connectivity'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application.rb:264:in `run_chef_client'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application/base.rb:352:in `run_application'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application.rb:67:in `run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-bin-18.0.185/bin/cinc-client:25:in `<top (required)>'
      	from /bin/cinc-client:184:in `load'
      	from /bin/cinc-client:184:in `<main>'
      ---- End output of git ls-remote "https://github.com/pyenv/pyenv.git" "master*" ----
      Ran git ls-remote "https://github.com/pyenv/pyenv.git" "master*" returned 1

      Cookbook Trace: (most recent call first)
      ----------------------------------------
      /var/cinc/cache/cookbooks/pyenv/resources/install.rb:71:in `block in class_from_file'

      Resource Declaration:
      ---------------------
      # In /var/cinc/cache/cookbooks/pyenv/resources/install.rb

       71:   git new_resource.prefix do
       72:     repository new_resource.git_url
       73:     revision   new_resource.git_ref
       74:     user       new_resource.user
       75:     group      new_resource.group
       76:     depth      1
       77:     action     new_resource.update_pyenv ? :sync : :checkout
       78:     environment(new_resource.environment)
       79:     notifies :run, 'ruby_block[Add pyenv to PATH]', :immediately
       80:     notifies :run, 'execute[Initialize pyenv]', :immediately
       81:   end
       82:

      Compiled Resource:
      ------------------
      # Declared in /var/cinc/cache/cookbooks/pyenv/resources/install.rb:71:in `block in class_from_file'

      git("/home/athiede/.pyenv") do
        action [:checkout]
        default_guard_interpreter :default
        declared_type :git
        cookbook_name "vendavo-base-cfg"
        recipe_name "python"
        repository "https://github.com/pyenv/pyenv.git"
        revision "master"
        user "athiede"
        group "athiede"
        depth 1
        destination "/home/athiede/.pyenv"
      end

      System Info:
      ------------
      chef_version=18.0.185
      platform=centos
      platform_version=7.9.2009
      ruby=ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
      program_name=/bin/cinc-client
      executable=/opt/cinc/bin/cinc-client

๐Ÿฅž Cookbook version

4.2.0

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

18.0.185 (cinc)

๐ŸŽฉ Platform details

CentOS 7 in Azure

Steps To Reproduce

Steps to reproduce the behavior:

run a recipe with this in it:

%w(user1 user2).each do |user|
  pyenv_install 'user' do
    user user
    prefix_type 'user'
    update_pyenv true
  end
end

๐Ÿš“ Expected behavior

I expect there to be two identical pyenvs setup.

โž• Additional context

The second user fails at this step: * git[/home/user2/.pyenv] action sync

This worked on version 3.4.0.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • sous-chefs/.github 3.1.1
  • actions/checkout v4
  • actionshub/chef-install 3.0.0
  • actionshub/test-kitchen 3.0.0
.github/workflows/stale.yml
  • actions/stale v9

  • Check this box to trigger a request for Renovate to run again on this repository

"chef exec rspec ." fails

๐Ÿ‘ป Brief Description

It seems that rspec support has not been added for this cookbook. Lots of errors whenever "pyenv_user_install" resource is used.

๐Ÿฅž Cookbook version

3.4.2

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

17.2.29

๐ŸŽฉ Platform details

Operating system distribution and release version. Cloud provider if running in the cloud.

Steps To Reproduce

Steps to reproduce the behavior:

Create a cookbook which incorporates the pyenv community cookbook, with a recipe containing "pyenv_user_install ''"

Execute "chef exec rspec ." from the root of the cookbook folder.

๐Ÿš“ Expected behavior

If the "default_spec.rb" has been created correctly, the tests should pass.

Upgrade from 3.5.1 to 4.1.0, getting 'pyenv: cannot rehash'

๐Ÿ‘ป Brief Description

I'm in the process to update from version 3.5.1 to version 4.1.0.

I have changed the pyenv_system_install and pyenv_user_install into a pyenv_install., see changes (https://github.com/aws/aws-parallelcluster-cookbook/pull/1540/files#diff-53bf5a2a42cec9c76aca73559c9e0ed134e5a7943145fbb68054dca759357d4dR18-R32)

During execution of pyenv_python I'm now getting

#19 929.2     * pyenv_python[3.9.9] action install[2022-09-26T12:18:30+00:00] INFO: Processing pyenv_python[3.9.9] action install (/etc/chef/local-mode-cache/cache/cookbooks/aws-parallelcluster-install/resources/install_pyenv.rb line 40)
#19 929.2 [2022-09-26T12:18:30+00:00] INFO: Building Python 3.9.9, this could take a while...
#19 929.2 
#19 929.2       * pyenv_script[pyenv install  3.9.9] action run[2022-09-26T12:18:30+00:00] INFO: Processing pyenv_script[pyenv install  3.9.9] action run (/etc/chef/local-mode-cache/cache/cookbooks/pyenv/resources/python.rb line 27)
#19 929.2 
#19 929.2         * execute[pyenv install  3.9.9] action run[2022-09-26T12:18:30+00:00] INFO: Processing execute[pyenv install  3.9.9] action run (/etc/chef/local-mode-cache/cache/cookbooks/pyenv/resources/script.rb line 42)
#19 929.2 
#19 929.2           [execute] pyenv: cannot rehash: /opt/parallelcluster/pyenv/shims isn't writable
#19 929.4                     Downloading Python-3.9.9.tar.xz...
#19 929.4                     -> https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tar.xz
#19 930.1                     
#19 930.1                     BUILD FAILED (CentOS 7.9.2009 using python-build 20180424)
#19 930.2                     
#19 930.2                     Inspect or clean up the working tree at /tmp/python-build.20220926121830.132214
#19 930.2                     Results logged to /tmp/python-build.20220926121830.132214.log
#19 930.2                     
#19 930.2                     Last 10 log lines:
#19 930.2                     /tmp/python-build.20220926121830.132214 /
#19 930.2                     mv: cannot move 'Python-3.9.9.tar.xz' to '/opt/parallelcluster/pyenv/cache/Python-3.9.9.tar.xz': Permission denied
#19 930.2                     ln: failed to create symbolic link 'Python-3.9.9.tar.xz': File exists
#19 930.2           
#19 930.2           ================================================================================
#19 930.2           Error executing action `run` on resource 'execute[pyenv install  3.9.9]'
#19 930.2           ================================================================================

Full log at
https://github.com/aws/aws-parallelcluster-cookbook/actions/runs/3127440243/jobs/5074062828
and
https://github.com/aws/aws-parallelcluster-cookbook/actions/runs/3127440233/jobs/5074062111

๐Ÿฅž Cookbook version

4.1.0

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

17.2.29

๐ŸŽฉ Platform details

CentOS or Ubuntu

Steps To Reproduce

execute
pyenv_install 'user'
followed by a
pyenv_python

๐Ÿš“ Expected behavior

It was working with version 3.5.1

โž• Additional context

n/a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.